CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

weird eeprom behaviour

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

weird eeprom behaviour
PostPosted: Wed Mar 02, 2011 12:21 pm     Reply with quote

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: 9182
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 3:25 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 3:28 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 3:40 pm     Reply with quote

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: 19391

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 3:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 4:54 pm     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group