Searching \ for '[PIC]: RAM banks in CC5x?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/memory.htm?key=bank
Search entire site for: 'RAM banks in CC5x?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: RAM banks in CC5x?'
2002\02\12@130826 by Alan Gorham

flavicon
face
Hello again CC5x users.
How do I correctly use the #pragma rambank statement to locate my functions and variables?

My code has the following structure:

#includes

macro defs

ISR

function prototypes
function prototypes
more function prototypes

main
{
   call functions
}

As I added yet another function prototype I obviously filled up the RAM in bank 0.
I get this message from the compiler:

Missing 4 byte(s) for local variables, rambank 1
(It is recommended to let all local variables reside in one block
if possible. Note that #pragma rambank will locate local and
global variables)

I've tried to put the #pragma rambank 1 statement just before the last function prototype that caused the compiler to squawk,
but without any joy. I suspect it is a bit more fiendish than my simple approach.

What am I doing wrong?

Thanks

Alan Embedded Systems Engineer
Microtima Ltd
Ouseburn Mews
3-7 Stepney Bank
Newcastle upon Tyne
NE1 2PW

Tel: 0191 2304411
Fax: 0191 2304422

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\02\13@042523 by Steven Allard

flavicon
picon face
Hello Alan

#pragma rambank locates VARIABLES ONLY in the required rambank. To assign functions to a given page use #pragma codepage (see
page 43 of manual).

I prefer to use the following syntax for placing functions and variables:

variables --  bank0 uns8 var_name;
functions --  page0 void function_name (void);

I can see straight away where they are located, and to build a header file to include in other modules I just copy and paste the
prototypes putting 'extern' in front of them all.

Hope this helps.

Steve



Alan Gorham wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\02\13@082909 by Alan Gorham

flavicon
face
SA>#pragma rambank locates VARIABLES ONLY in the required rambank. To assign
functions to a given SA>page use #pragma codepage (see
SA>page 43 of manual).


AG>> Missing 4 byte(s) for local variables, rambank 1
AG>> (It is recommended to let all local variables reside in one block
AG>> if possible. Note that #pragma rambank will locate local and
AG>> global variables)


Steve
Thanks for the reply. Looking back at my original post and your response, do
you not agree that it is actually
variable space that I'm running short on? Most of my functions use several
local variables - so how can I ensure that the function and it's local
variables end up on the same codepage. Is this necessary?

Thanks

Alan

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\02\13@120147 by Steven Allard

flavicon
picon face
Alan

It does sound like a shortage of data memory, what processor are you using ?

Try taking a look at the *.occ file generated by the compiler (see page 13 of manual) this maps out the RAM usage of your program.

Local variables are destroyed when a function ends and their memory locations are made available for reuse. If you are running low
on RAM look at reducing the number of global variables which are permanently assigned to memory locations.

Functions and variables are never in the same space. Functions are in program memory - ROM/Flash/EPROM whatever, variables are in
RAM/data memory/register files etc. These are completely seperate in pics unlike some other designs of processor.

Keeping all variables in one bank does slightly improve efficiency - but not a great deal - it just means the bank selection bits
are not manipulated by the code the compiler produces.

Steve

Steven Allard wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\02\13@132909 by Alan Gorham

flavicon
face
>It does sound like a shortage of data memory, what processor are you using
?

PIC16F874

>Try taking a look at the *.occ file generated by the compiler (see page 13
of manual) this maps out the RAM usage of your program.


I looked at this and saw that I'm only using about half of the available
RAM. What I had been doing is completely filling one RAM bank and I think
that this problem was made worse by the compilers reuse
of certain locations in RAM for successive local variables.

>Local variables are destroyed when a function ends and their memory
locations are made available for reuse. If you are running low on RAM look
at reducing the number of global variables which are permanently assigned to
memory locations.


I only have 5 globals!

>Functions and variables are never in the same space. Functions are in
program memory - >ROM/Flash/EPROM whatever, variables are in
>RAM/data memory/register files etc. These are completely seperate in pics
unlike some other designs of >processor.


OK!, I appreciate this a bit more now. I seem to have solved the problem by
placing all the variables in the method you described. Took a bit of thought
:-( !!

>Keeping all variables in one bank does slightly improve efficiency - but
not a great deal - it just means the >bank selection bits
>are not manipulated by the code the compiler produces.
>


Thanks for the hints, worked a treat once I got my brain into gear!

Alan

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...