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

Variables in ram being overwritten

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



Joined: 16 Sep 2003
Posts: 21

View user's profile Send private message

Variables in ram being overwritten
PostPosted: Mon Apr 30, 2007 9:02 am     Reply with quote

Ram variables being overwritten in my 18F2525 code (or 18F2520)

in the .lst file the Compiler make this assignment
.................... MY_IP_BYTE4=210;
1710: MOVLW D2
1712: MOVWF xFB <- MY_IP_BYTE4 assigned to ram location xFB

Looking though the .lst file there is only 2 more uses of this register. Both are just reading the location.

Yet after about an hour, or several hours, the value this location has changed to x54 (from xD2)! This over written value has been consistently changed to x54.

This also can happen to other variables but the "adjusted" values are not as consistent. I am assuming that I have only one problem but it may be more than one effect. Focusing on the this one since the altered value is repeatable.

All interrupts are off (I think)
#fuses H4,NOWDT,PROTECT,NOWRT,NOLVP

CCS PCH C Compiler, Version 3.249, 31890
ROM used: 31182 bytes (65%)
Largest free fragment is 15568
RAM used: 590 (15%) at main() level
699 (18%) worst case
Stack: 16 location

I am using my code, which has been solid for a year, combined with the some CCS example code for driving the ENC28J60. The example code, or my code when run alone did not seem to have this problem.

ANY suggestions on what might be happening here?

Eric
Ttelmah
Guest







PostPosted: Mon Apr 30, 2007 9:47 am     Reply with quote

Are you using pointers anywhere?.
What array accesses are you using?.
What is listed in the sym file, immediately in front of the corrupted value(s)?. Is this accessed by either a pointer, or as an array?.
The commonest cause of this, is failure to 'bounds check' an index value for an array, or used with a pointer (the compiler does not do this, and the chip has no hardware protection for this), so the wrong value gets accessed.

Best Wishes
eric



Joined: 16 Sep 2003
Posts: 21

View user's profile Send private message

PostPosted: Mon Apr 30, 2007 10:07 am     Reply with quote

Thanks for the reply- I will check out your suggestions today.

Eric
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