View previous topic :: View next topic |
Author |
Message |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
Memory allocation? |
Posted: Tue Nov 02, 2010 10:25 am |
|
|
Hi,
Is there a way to see how RAM is being allocated in a project? A file perhaps?
I am working with a 16F648a device and I'm unexpectedly getting a "not enough RAM" error. My code contains two 80 character arrays, and about 10 int8 variables, so the 264 bytes of RAM in the 16F648a should be enough, I think? Am I missing something?
Suggestions?
Thanks!
John |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Tue Nov 02, 2010 10:38 am |
|
|
Look at the .STA and .SYM files in the same directory as your project. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: Memory allocation? |
Posted: Tue Nov 02, 2010 10:40 am |
|
|
ezflyr wrote: | ... so the 264 bytes of RAM in the 16F648a | The PIC16F648a has 256 bytes of ram, not 264.
Quote: | Is there a way to see how RAM is being allocated in a project? A file perhaps? | There is the symbol file <projectname>.sym
You might have to enable creation of this file in the Compiler's options menu.
If you search this forum you will find the 'Out of RAM' error is very common. The problem is caused because the compiler defaults to creating as compact as possible code without RAM bank switching. When RAM usage exceeds the free RAM in the first page, 86 bytes, you get this error.
Enable the use of RAM bank switching by adding the line |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Nov 02, 2010 3:44 pm |
|
|
Hi all,
Thanks for the input!
The addition of the #device *=16 directive did not solve my problem. A look at the .sym file indicates that the compiler is indeed trying to use more RAM memory than I have available.
Let me step back and describe my situation. I am re-writing a GPS NMEA receive routine based on the EX_SISR.c example program (circular receive buffer). Originally, I had the program working nicely with a linear buffer, but in only worked properly when all NMEA messages were turned off except the one I wanted ($GPRMC). I really wanted a more flexible solution, so I decided to implement the circular buffer strategy.
My original program contained a receive buffer of 80 characters. The re-written version uses an 80 character circular receive buffer (written to only allow the desired string to enter), and an 80 character message buffer. Is there a general rule-of-thumb as to how big the circular buffer needs to be relative to the message buffer? Obviously, I want to have the circular buffer long enough to avoid overwriting characters before they can be processed......
Given the description of what I need to accomplish, is my buffer (circular and message) allocation OK? Do I just need to find a PIC with more RAM?
Thanks,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Nov 02, 2010 4:35 pm |
|
|
Hi PCM,
I'm not declaring any variables as 'static', so I'm not sure how those threads effect my problem? I believe that the compiler is free to reuse RAM for non-static variables, correct?
As I said, maybe I'm just going about the design of my program incorrectly - I've never implemented a circular buffer before. I've got an 80 character free-running circular receive buffer being filled by my INT_RDA interrupt, and an 80 character message buffer (the NMEA message of interest is about 76 characters long) being processed in Main. Does that sound about right?
So, at least in my mind, I've got two primary questions:
1. Is my program design appropriate, ie. are my buffer allocations reasonable?
2. What is the minimum number of actual RAM locations I need for a correctly designed circular buffer implementation requiring the receipt of a 76 character message?
Thanks,
John |
|
|
|