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

Inter-SEGMENT Transition Issue, or STACK overflow?

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








Inter-SEGMENT Transition Issue, or STACK overflow?
PostPosted: Mon Jan 25, 2010 4:44 am     Reply with quote

I am working in a project with a 16F876A.
The project is taking a 46% of the ROM (3.68KB out of 8KB).
The thing is that when a new function is added, the program stops working as it should.
This miss-behavior cannot be blamed on the new funcionallity. To be more concise: This new function is outside the “infinite loop” of the program, is a display presentation that is only executed once, and works nice.
After that, the infinite loop is entered and it is there where the behavior goes erratic and garbled.

I thought it had to be with some inter-SEGMENT transition, or some piece of code too large to be located in one segment.
I went through the output files of the compiler to look for something suspicious, but I didn’t.

MAIN = 22% ROM
1 unused SEGMENT
The rest of funcions range from 1% to 14% (mostly 1 to 6%)


In case is of some help to any kind of genius, this is a comparison between the two compilations, first with the added function and second without it:

Code:

   WITH ADDED FUNCTION             WITHOUT NEW FUNCTION
    -------------------             --------------------
 Segment     Used  Free          Segment     Used  Free 
-----------  ----  ----         -----------  ----  ---- 
00000-00003     4  0            00000-00003     4  0     
00004-00039    54  0            00004-00039    54  0     
0003A-007FF  1985  5            0003A-007FF  1936  54   
00800-00FFF  1420  628          00800-00FFF  1637  411   
01000-017FF   926  1122         01000-017FF     0  2048 
01800-01EFF     0  1792         01800-01EFF     0  1792 


I also tried to add a #SEPARATE directive above each function in order to prevent the linker from doing INLINEs, but the result keeps being the same.

I also thought about some stack overflow issue, but the CALL TREE states that only 7 levels are used:

7 worst case (6 in main + 1 for interrupts)

I keep thinking that some of these are the root of the problem, but I can’t think a way to find it out.
Please, some advice on this?

COMPILER VERSION: CCS PCM C Compiler, Version 4.068, 11166
Ttelmah
Guest







PostPosted: Mon Jan 25, 2010 4:58 am     Reply with quote

I'd be looking at the possibility of a _RAM_ problem. What you describe,is 'semi-classic', for something using a pointer/array, and overwriting a variable, that it shouldn't touch, which then results in the part of the program that does use that variable, receiving unexpected values....
Classic things would be 'forgetting' that a string needs space for the terminating character, and only assiging 10 locations for a 10 character string, resulting in the next variable getting overwritten.

Best Wishes
Guest








PostPosted: Mon Jan 25, 2010 6:04 am     Reply with quote

Yes, you are right, that could be happening.
Nevertheless the new function is not adding more than 14 variables.

Code:
RAM used: 140 (39%) at main() level
          198 (55%) worst case


Of course it could also be a dormant error that has arises when this function has been added. Nothing to do with amount of RAM available.

Anyway, I would like to have any argument to discard the possibility of the SEGMENT issue or the STACK. I don’t know if the information provided by the .STA file is reliable enough to forget about the matter, or on the contrary, some other precautions and checks have to be done.
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