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 allocation

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







ram allocation
PostPosted: Tue Jan 23, 2007 4:05 pm     Reply with quote

Hi everybody,

I would like to know how the CCS compliler allocate ram data.

Does it allocate it in sequential way?

When data are put in the accesse area, the bank0 or bank1?

It is a way to have a control on it?

The goal of it is to put the variable mostly used in the bank 0 or in the accesse area the optimise bank switching.

thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 23, 2007 4:30 pm     Reply with quote

Look at the #locate directive in the manual. Here are
three good threads on the topic:
http://www.ccsinfo.com/forum/viewtopic.php?t=27996
http://www.ccsinfo.com/forum/viewtopic.php?t=19945
http://www.ccsinfo.com/forum/viewtopic.php?t=20605
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Jan 23, 2007 4:50 pm     Reply with quote

The one link says to put large array at end of variable definitions.
This is to reduce bank swaping.

I seem to put them in the begining. my thinking is that the compiler finds space for these first. then put the little variable in the open holes.

Do I understand both issues corectly?
Ttelmah
Guest







PostPosted: Wed Jan 24, 2007 3:16 am     Reply with quote

You need to be a bit careful about the beginning of RAM. The compiler puts quite a few important things of it's own here. If you have PCW, then in device editor, look under the 'memory' tag, at the entry 'C scratch RAM'. This is the location, where the compiler puts it's own temporary variables (normally five used), and if you overwrite this, you'll be in problems.
It is worth also realising, that the compiler uses 'temporary' memory allocation if it can. So a variable in a subroutine, that is not 'static', uses a memory area, that another subroutine (provided it is not called from 'inside' the first), can re-use. If you physically fix too many variables in the low bank, it prevents subroutines from being able to use these areas, and can actually make things worse...
Generally variables use memory in the order they are declared. If you do a search back through the forum, there were also a number of threads in the past about how best to organise variables, to reduce bank switching on the 16 chips (I think PCM programmer posted a very informative section about this?).

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