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

RAM PIC18F46J50 ISSUE

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



Joined: 09 May 2020
Posts: 126

View user's profile Send private message

RAM PIC18F46J50 ISSUE
PostPosted: Thu May 21, 2020 7:37 am     Reply with quote

Hi all,

I'm using PIC18F46J50 with CCS v5.090 compiler.
I'm facing some strange behaviours of my devices and I suspect the problems could be caused by a RAM issue.
When I build my program I see that in the worst case the Pic uses 99% of the available RAM:

Memory usage: ROM=84% RAM=82% - 99%
0 Errors, 93 Warnings.
Build Successful.

It could be a problem ?

Please help me, I'm debugging an important project and I've already check the warnings, the problem is not there...

Another question: RTC wakeup from deep sleep causes RAM variables to reset ?

Marco
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu May 21, 2020 8:36 am     Reply with quote

Honestly the warnings could be a problem.
However there is one critical word in what you say. "debugging". Does
this mean you are using a debugger?. The debugger uses two stack levels
on this chip. How many stack levels are used by your code?.
The most likely thing really, is that if the variables are really tightly packed
you have made a mistake somewhere in size for an array, and something
is overwriting a variable next door.
Walk through the .SYM, and check the sizes.
Look in particular at what is going wrong, and what is variables are just
in front of this.
Marco27293



Joined: 09 May 2020
Posts: 126

View user's profile Send private message

PostPosted: Thu May 21, 2020 9:10 am     Reply with quote

Thank you Ttelmah,

If in main.h file:
Code:
//Global variables
int flag=True;

In main.c I have:
Code:

#include "main.h"
void main()
{
if(flag)
{
//do instructions
}
flag=False;
GotoDeepsleep(RTC_Wakeup_after_10_sec);
}

When a RTC wakeup occurs flag variable will be False or True?
Will it execute the if clause block or not ?

Marco
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Thu May 21, 2020 9:21 am     Reply with quote

You must study the data sheet carefully to understand what happens during deep sleep and after.
Waking from deep sleep does a power on reset and since you are initializing the flag to true, it will get initialized after deep sleep wake.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 21, 2020 9:16 pm     Reply with quote

1. Look at the top of the .LST file. It shows the number of
stack levels used. Post it.

2. Post your 93 warnings.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: RAM PIC18F46J50 ISSUE
PostPosted: Fri May 22, 2020 9:19 am     Reply with quote

Marco27293 wrote:

When I build my program I see that in the worst case the Pic uses 99% of the available RAM:

Memory usage: ROM=84% RAM= 82% - 99%
0 Errors, 93 Warnings.
Build Successful.

I asked CCS support to explain the wide range of RAM usage. They said:
CCS support wrote:

It is 82% RAM while executing in main() and 99% used when in the worst
case function (maybe the bottom of the call tree).

When the worst case function is executing, local variables in all the
functions on the call stack are active and that RAM is not available.

The cause is simply a large number of bytes in local variables.


Marco27293 wrote:

It could be a problem ?

In my opinion, if you push the compiler to the limits, problems may occur.
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