Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 17th December 2003, 04:00 AM   (permalink)
Default Memory on a PIC

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!
brentonw2004 is offline  
Old 17th December 2003, 04:51 AM   (permalink)
Default

it's called eeprom
panic mode is offline  
Old 17th December 2003, 07:21 AM   (permalink)
Default

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.
Nigel Goodwin is offline  
Old 18th December 2003, 01:13 AM   (permalink)
Default

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.
The Real MicroMan is offline  
Old 18th December 2003, 04:06 PM   (permalink)
Default

Quote:
Originally Posted by The Real MicroMan
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 is offline  
Old 18th December 2003, 09:44 PM   (permalink)
Default

Quote:
Originally Posted by Exo
Quote:
Originally Posted by The Real MicroMan
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".
The Real MicroMan is offline  
Old 18th December 2003, 09:56 PM   (permalink)
Default

Quote:
Originally Posted by The Real MicroMan
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.
Nigel Goodwin is offline  
Old 19th December 2003, 01:30 PM   (permalink)
Default

Quote:
Originally Posted by The Real MicroMan
Quote:
Originally Posted by Exo
Quote:
Originally Posted by The Real MicroMan
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.
Exo is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 03:43 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker