View previous topic :: View next topic |
Author |
Message |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
weird eeprom behaviour |
Posted: Wed Mar 02, 2011 12:21 pm |
|
|
Hi There,
I am storing default values (SIGNED int16) in the eeprom on start up, that looks like:
Code: | for(i=0;i<VARNUM;i++){
by1=store[i] & 0xFF;
by2=(store[i] >> 8) & 0xFF;
write_eeprom(i*2,by1);
write_eeprom(i*2+1,by2);
} |
and for some reason all the data get written properly except when i is equal to 10. The value at eeprom 20 (i*2) is fine but 21 is always 0... I can't explain why that would be... :(.
Any hints or suggestions?
Thanks a lot! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Wed Mar 02, 2011 3:25 pm |
|
|
You don't say which PIC you're using, any chance it doesn't have EEPROM at that location ? |
|
|
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Wed Mar 02, 2011 3:28 pm |
|
|
Sorry, missed that it's 18f87k22. It says 1K eeprom and i assumed that's from 0 to 1024... |
|
|
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Wed Mar 02, 2011 3:40 pm |
|
|
Uh, nevermind, I think I finally found the problem in my code... man, if i had just looked there a few hrs ago... lol, nevermind but thanks for your time anyways! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Mar 02, 2011 3:43 pm |
|
|
As a comment, look at the make8 function, or using a union. A lot faster than fiddling around shifting and 'and'ing....
Best Wishes |
|
|
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Wed Mar 02, 2011 4:54 pm |
|
|
Ttelmah wrote: | As a comment, look at the make8 function, or using a union. A lot faster than fiddling around shifting and 'and'ing....
Best Wishes |
Uh, make8() looks like a cool function...thx bud! |
|
|
|