View previous topic :: View next topic |
Author |
Message |
Marco27293
Joined: 09 May 2020 Posts: 126
|
RAM PIC18F46J50 ISSUE |
Posted: Thu May 21, 2020 7:37 am |
|
|
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
|
|
Posted: Thu May 21, 2020 8:36 am |
|
|
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
|
|
Posted: Thu May 21, 2020 9:10 am |
|
|
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
|
|
Posted: Thu May 21, 2020 9:21 am |
|
|
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
|
|
Posted: Thu May 21, 2020 9:16 pm |
|
|
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
|
Re: RAM PIC18F46J50 ISSUE |
Posted: Fri May 22, 2020 9:19 am |
|
|
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. |
|
|
|