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 16F648A mcu operation when ROM=63 %

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



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

Weird 16F648A mcu operation when ROM=63 %
PostPosted: Mon Jul 24, 2006 11:35 pm     Reply with quote

Hi,

PCM: 3.169
MCU: 16F648A

I have noticed that whenever ROM used is more than 63% the mcu operation becomes un-predictable and random...

For example in the code I am developing , the mcu starts transmitting some pulses on the USART. But when I remove some code from the main duty cycle it runs well.

I have noticed these problems in other mcus as well , 16F877 etc. When ROM used is less (say 30 %) they work well.

Kindly advise what's wrong here... I could post the code if required.

thanks
arunb
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 24, 2006 11:49 pm     Reply with quote

Quote:

I have noticed that whenever ROM used is more than 63% the mcu
operation becomes un-predictable and random...

Read these two threads. Check if you're doing any of the things
that they talk about:
http://www.ccsinfo.com/forum/viewtopic.php?t=26793
http://www.ccsinfo.com/forum/viewtopic.php?t=24548&start=21
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Tue Jul 25, 2006 1:28 am     Reply with quote

Hi,

Here is an extract from the LST file...

CCS PCM C Compiler, Version 3.169, 16542

Filename: SLA7062-Controller.LST

ROM used: 1762 (43%)
Largest free fragment is 2048
RAM used: 74 (42%) at main() level
109 (62%) worst case
Stack: 9 worst case (4 in main + 5 for interrupts)


Does 'worst case' mean I am using 9 stack locations or is it just a warning ???

thanks
arunb
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 25, 2006 1:49 am     Reply with quote

It is a prediction that you program will crash at some point.
The 16F648A only has 8 stack levels. If you use more than that,
expect the program to crash.

Because the .LST file shows more than 8 levels are used, this
tells me that you are using the #separate directive.

Also, you have 5 stack levels for interrupts. This tells me that
you don't have simple interrupt code. You are calling functions
that call other functions, and they call functions, and so on.

You have to get the stack levels down to 8 or less.

Ideally, you should completely remove all usage of #separate
from your program. However, it may not compile in that case.
You could try to change the size of your functions and the structure
of your program. Or, you could try to remove #separate from
certain functions, and then re-compile and watch the .LST file
until it gets to 8 or less stack levels.

Once you start using #separate, the compiler will not automatically
limit the number of stack levels to 8. It will just use however many
are required, even if the amount used will exceed 8 and cause the
program to crash. That's why I said it's ideal if you can remove
all the #separate statements from your program.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Tue Jul 25, 2006 2:05 am     Reply with quote

Hi,

Thank you for the help.

I remove the extra code from the interrupts. So now the stack shows 5 Worst case (4 in main+1 in interrupt).

How are function calls within a function made ??? Is this OK ??


Code:


void funcB()
{


}

void funcC()
{


}


void funcA()
{

  funcB();
  funcC();

}


void main()
{
 
  do
  {
     funcA();
   
   }while(TRUE);


}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 25, 2006 4:29 am     Reply with quote

Yes, that's OK.
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