View previous topic :: View next topic |
Author |
Message |
morris888
Joined: 23 Oct 2009 Posts: 1 Location: Costa Rica
|
Write a Float variable in the internal EEPROM memory |
Posted: Fri Oct 23, 2009 2:54 pm |
|
|
Hello, I'm trying to save a float variable, that I'm using in a program in the internal EEPROM memory. I found this example in CCS FAQ, but I still don't know how to save my float variable.
Code: |
WRITE_FLOAT_EXT_EEPROM(long int n, float data) {
int i;
for (i = 0; i < 4; i++)
write_ext_eeprom(i + n, *((int8*)&data + i) ) ;
}
float READ_FLOAT_EXT_EEPROM(long int n) {
int i;
float data;
for (i = 0; i < 4; i++)
*((int8*)&data + i) = read_ext_eeprom(i + n);
return(data);
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 23, 2009 3:48 pm |
|
|
Use the routines from this CCS driver file. It has routines for internal eeprom:
Quote: | c:\program files\picc\drivers\internal_eeprom.c |
The routines have instructions:
Quote: |
// Purpose: Write a floating point number to internal eeprom
// Inputs: 1) An eeprom address. Four eeprom locations will be used.
// 2) The floating point number to write to internal eeprom
// Outputs: None
void write_float_eeprom(INT_EEPROM_ADDRESS address, float data)
// Purpose: Read a floating point number from internal eeprom
// Inputs: An eeprom address
// Outputs: The floating point number read from the internal eeprom
float read_float_eeprom(INT_EEPROM_ADDRESS address)
|
|
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
i had the same question |
Posted: Sat Oct 24, 2009 7:07 am |
|
|
thanks PCM programmer |
|
|
|