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.

Memory on a PIC

Status
Not open for further replies.

brentonw2004

New Member
Hello everyone! I am working on a project using a PIC. The project is a circuit for a car, and I need to retain a variable that the user can set. I have the unit come stock with a certain value for a variable, but then you should be able to adjust the value of the variable. I know how to do all of this, but what I don't know is how to retain the variable after the power is removed from the pic. I assume that my variable will just go back to the normal. Does the pic have any type of permanent memory that you can write the variable to? Also, I still need to find out how to program a 16f819 with PicBasic Pro. What is a good compiler? I have tried to use MicroCode Studio Plus, but it doesn't work with this certain chip. Any advice on either of these questions would be greatly appreciated.
Thanks!
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Many of the PIC's have in-built EEPROM, the 16x84 series have 64 bytes, and the 16F628 has 128 bytes. Check the specs at MicroChip and pick a chip that includes it.
 
in your code, just don't set the intiial value. as long as you don't change it in your code. it will still be there. Think of it this way your program memory stays, so shall any register you changed.
 

Exo

Active Member
The Real MicroMan said:
in your code, just don't set the intiial value. as long as you don't change it in your code. it will still be there. Think of it this way your program memory stays, so shall any register you changed.

Not true. All normal RAM files are just like the ram in your computer. When power is removed all data is lost. program memory stays because it is eeprom or flash memory.

You should save the file to EEPROM when it is changed and get it out of EEPROM every time the pic powers up.
 
Exo said:
The Real MicroMan said:
in your code, just don't set the intiial value. as long as you don't change it in your code. it will still be there. Think of it this way your program memory stays, so shall any register you changed.

Not true. All normal RAM files are just like the ram in your computer. When power is removed all data is lost. program memory stays because it is eeprom or flash memory.

You should save the file to EEPROM when it is changed and get it out of EEPROM every time the pic powers up.

example: For those of you who don't know anything about Micros

int help;

main()
{
printf("%c", help);
help=getc();
}

if I run this program and enter "f" as my getc(), then disconnect power, after I reconnect power help will still be "f".
 

Nigel Goodwin

Super Moderator
Most Helpful Member
The Real MicroMan said:
if I run this program and enter "f" as my getc(), then disconnect power, after I reconnect power help will still be "f".

But it's not guaranteed to always be that! - data registers in a PIC are in volatile memory, hardly something to reply on! - and I would suspect may only be valid for a fairly short time (if at all).

Many PIC's have data EEPROM built-in, it's trivial to store any settings you want there and reload them during program initialisation - and it's guaranteed to be maintained - for many years - guaranteed minimum specs are available from the MicroChip website.
 

Exo

Active Member
The Real MicroMan said:
Exo said:
The Real MicroMan said:
in your code, just don't set the intiial value. as long as you don't change it in your code. it will still be there. Think of it this way your program memory stays, so shall any register you changed.

Not true. All normal RAM files are just like the ram in your computer. When power is removed all data is lost. program memory stays because it is eeprom or flash memory.

You should save the file to EEPROM when it is changed and get it out of EEPROM every time the pic powers up.

example: For those of you who don't know anything about Micros

int help;

main()
{
printf("%c", help);
help=getc();
}

if I run this program and enter "f" as my getc(), then disconnect power, after I reconnect power help will still be "f".

Maybe your C compiler uses EEPROM to store your int. You don't know what's happening in the background. Maybe it is like nigel pointed out, some remanent charge keeping the ram active for a little while afther power off, or maybe some capacitor in your circuit keeping enough charge to hold the pics memory. But the normal registers of a pic are RAM and will lose the data on power off, sooner or later. Why else would they put EEPROM into some pics.
 
Status
Not open for further replies.

Latest threads

Top