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

addition not working with read_eeprom

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



Joined: 18 Mar 2009
Posts: 38

View user's profile Send private message

addition not working with read_eeprom
PostPosted: Mon Dec 27, 2010 4:30 pm     Reply with quote

Hello,

In the following code the incrementation of wdt_counter does not work.
The value stay at 0.
Does that have something to do with the read_eeprom instruction ?
Any suggestion ?

Thanks !!

Pic 18f2525 and compiler 4.065

Code:
 if (temp == WDT_TIMEOUT)
   { 
    printf("\r\nwatchdog timeout!\r\n");
    write_eeprom(816,87);  // store 'w'
    wdt_counter = read_eeprom (817) + 1;
    write_eeprom(817,wdt_counter);
   }   
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 27, 2010 4:48 pm     Reply with quote

There's no way for us to test this code fragment. You don't initialize
eeprom address 817. We don't know its initial value.

Also, your code doesn't read address 817 and display it. So how do you
know what the initial state is ? What if the initial state is 0xFF ?
(0xFF = erased eeprom, possibly done by the ICD programmer).
If you add 1 to 0xFF, then you get 0x00.
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