PIC Memory varaibles declaration

Status
Not open for further replies.

haxan

New Member
Hi. I just want to know one simple thing.

How to define variable in Program Memory and Data memory separately using C language and C18 compiler.

Also does putting static give any memory saving advantage or is it just a programming practice to avoid overwriting ?
 
You define the two with ROM and RAM directives.

Static generates a global variable whose scope is limited to where it is defined and so it uses more memory than a non static variable as that memory can't be reused.

Mike.
 
Thank you Pommie.

The problem with ROM is that it cannot be overwritten (but i guess thats what ROM means).

Also when we declare variable like unsigned char , It is defined in RAM ?
 
Last edited:
Normally yes, ROM = read only. However, on pics it can be written to and C18 does most of the code for you. It sets up all the registers but doesn't do the actual write.

Mike.
 
if the variable are by default defined in RAM, whats the use of writing RAM before variables then?
 
Just for clarity, so someone working on your code in 10 years time has a better idea of what the variable is.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…