imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 822
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,533
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include <avr/io.h> #include <avr/eeprom.h> //declare an eeprom variable float EEMEM my_eeprom_float; // declare a ram variable float my_ram_float; int main(void) { // assign a value my_eeprom_float = 1.234567; // save to eeprom eeprom_write_float(&my_eeprom_float, my_eeprom_float); // restore from eprom my_ram_float = eeprom_read_float(&my_eeprom_float); while(1); }
3.2 is 3 char minimum to be printed and two decimal. If the value to be printed is shorter than this number, the result is padded with blank spaces so 1.2 will be shown as " 1.20"
void Print (float f)
{
char x,a,b,c,d,buff[10];
sprintf(buff , %f , f);
a=buff[0];
b=buff[1];
c=buff[2];
d=buff[3];
if(b = '.')
{
if(y==3) dp is on when segment 3 is on.==> 1.23
DP_ON;
}
else if(c = '.')
{
if(y==2) dp is on when segment 2 is on.==> 12.3
DP_ON;
}
}
char my_float_array[] ="12.345";
Update checks the content of the eeprom and if the value you intend to write is the same as the existing one it skips the write, this can extend the eeprom life (since the write cycles are limited).What is difference between "eeprom_write" and "eeprom_update"?
If I want to store ADC values on EEPROM ,the ADC values are float in nature.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #include <avr/io.h> #include <avr/eeprom.h> //declare an eeprom variable char EEMEM my_eeprom_array[10]; // declare a ram variable char my_ram_array[10] = "123456789"; char my_ram_array2[10]; char my_ram_array3[10]; int main(void) { // save to eeprom five characters of my_ram_array starting from position 20 eeprom_write_block(my_ram_array, 20, 5); // save to eeprom five characters of my_ram_array in location of my_eeprom_array eeprom_write_block(my_ram_array, &my_eeprom_array, 5); // restore from eeprom in my_ram_array2 five characters read from eeprom location of my_eeprom_array eeprom_read_block(my_ram_array2, my_eeprom_array, 5); // restore from eeprom in my_ram_array3 five characters read from eeprom location 20 eeprom_read_block(my_ram_array3, 20, 5); while(1); }
I said,
If I want to store ADC values on EEPROM ,the ADC values are float in nature.
You asked,
Really? I always thought that the ADC result was a 10bit value , 0-1023
float fvalue;
fvalue= 1.2345;
unsigned char *p;
unsigned char Adress; // adresse for eeprom (in case of size=256bytes)
// or use unisgned int if size is over
p=&fvalue; // p pointe sur le flottant
Eeprom_Write(Adress,*(p));
Eeprom_Write(Adress+1,*(p+1));
Eeprom_Write(Adress+2,*(p+2));
Eeprom_Write(Adress+3,*(p+3));
Adress=Adress+4; // for the next float to store
Oh,sorry I wanted to say that input of ADC pin is float values like temperature,volts,amps etc.
Vadc= ADC * 5000 / 1023
Thank you for reply.
Dear alexan_e,
I am using three 7-segment displays instead of four segments.
I am not only show mV values also value in Volts.
for example: 0.00 to 9.99 ==> 10.0 to 99.9 ==> 100 to 999.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?