I have a problem about writing int32 values to the internal EEPROM.
I use the ICD2 for debug and I can see that the "adr" and "data" is loaded correct, but after writing to EEPROM I can read the EEPROM and see that the data isen't there.
The code I use looks like this:
int32 data; // data to EEPROM
int8 adr; // adresse to EEPROM
void write_int32_eeprom(adr, int32 data) // rutine to write 32 bit
{ // remember to have 4 free
// EEPROM adresses over used
int8 i;
for (i = 0; i < 4; i++)
write_eeprom(i + adr, *(((int8*)&data) + i) ) ;
Can anyone tell what wrong?
(I'am new in C-programming)
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Tue May 08, 2007 1:32 am
Show the code that calls the write_int32_eeprom() function.
Show a few lines of it.
Mortenc
Joined: 22 Feb 2007 Posts: 55
Posted: Tue May 08, 2007 4:15 am
Thanks for helping, but I think I now have found the problem.
The problem was that I don't should take variables to the write rutine because it's diffined as global variables. My write rutine should therefore look like this instead. Sorry of my bad knowledge of C yet.
(however I could see that you look for the same mistake)
void write_int32_eeprom() // rutine to write 32 bit
{ // remember to have 4 free
// EEPROM adresses over used
int8 i;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum