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 CCS Technical Support

internal eeprom initialize. problem

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



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

internal eeprom initialize. problem
PostPosted: Fri Jul 14, 2017 2:42 am     Reply with quote

Hi,

ccs compiler/ide - 5.073
pic microcontroller: PIC16F1825

Please see this code. I am initializing the internal EEPROM and data in debugger
shows values that are different. Can someone please explain.

Code:

#rom getenv("EEPROM_ADDRESS")={
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75}

int8 taskCount;
int8 wdEEPROM[256];


for (taskCount=0; taskCount==255; taskCount++)
   {
       WDeeprom[taskCount] = read_eeprom(taskCount);                   
   }                 


When debugging, the WDeeprom shows = {75.....till 253 count and after
that for 254 and 255, I always get a constant value of 50.

Thanks,
Jai.
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

PostPosted: Fri Jul 14, 2017 4:50 am     Reply with quote

I added a bit of delay in the loop reading eeprom and it is working ok.
I always thought you need delay only for writing. - well maybe someone can explain.

thanks.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jul 14, 2017 4:57 am     Reply with quote

A quick thought...
the #ROM defaults to a 16 bit value but in your program you retrieve the data as an int8.
you are allowed to #ROM int8 ..... according to the manual, so I'd add int8 to #ROM and see what happens...

others who use this everyday may know the real solution....

Jay
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

PostPosted: Fri Jul 14, 2017 6:59 am     Reply with quote

I figured it out.
for some reason for loop is not working. i try a while loop and it works just
fine. is it a bug or am i not doing the for loop properly.

Some one can please clarify.

thanks
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

Re: internal eeprom initialize. problem
PostPosted: Fri Jul 14, 2017 7:12 am     Reply with quote

jaikumar wrote:
Code:

int8 taskCount;
int8 wdEEPROM[256];

for (taskCount=0; taskCount==255; taskCount++)
   {
       WDeeprom[taskCount] = read_eeprom(taskCount);                   
   }                 



Your for() loop is a little weird in that the test is usually to see if the index is less than or greater than some value; you have a test for if it's equal to 255. I've just never seen it structured in that manner.

Try declaring taskCount as an int16 and change the test on it to be < 256. See what that does.
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

PostPosted: Fri Jul 14, 2017 7:30 am     Reply with quote

yes newguy it works when i do it like below:

Code:

for (loop=0; loop < (int16)256; loop++)
  {
   data = read_eeprom((int8)loop);
   printf("Data:%u  %u \n\r",(int8)loop, data);
  }


I realize it's not used that way. but logic seems correct. i will check it in
visual c++ tomorrow.

Thanks.
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