Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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 ?
 

Pommie

Well-Known Member
Most Helpful Member
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.
 

haxan

New Member
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:

Pommie

Well-Known Member
Most Helpful Member
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.
 

Pommie

Well-Known Member
Most Helpful Member
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.

Latest threads

Top