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

Memory allocation?

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



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

Memory allocation?
PostPosted: Tue Nov 02, 2010 10:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 02, 2010 10:38 am     Reply with quote

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

View user's profile Send private message

Re: Memory allocation?
PostPosted: Tue Nov 02, 2010 10:40 am     Reply with quote

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
Code:
#device *16
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Nov 02, 2010 3:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 02, 2010 4:15 pm     Reply with quote

Quote:

A look at the .sym file indicates that the compiler is indeed trying to use
more RAM memory than I have available.

See these threads on re-use of RAM locations by the compiler.
http://www.ccsinfo.com/forum/viewtopic.php?t=29278
http://www.ccsinfo.com/forum/viewtopic.php?t=18296
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Nov 02, 2010 4:35 pm     Reply with quote

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
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