A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
stupid question - PBPro - meriachee - Feb 19 21:50:34 2007
Hi folks,
Can somebody please help me get a routine together that will allow me
to write a word sized variable to the memory of a 16f819 and be able
to read it back when the chip powers up. I know this is not rocket
science, but for whatever reason I cannot for the life of me figure it
out.
Thanks
Gary

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: stupid question - PBPro - Charles Linquist - Feb 20 0:11:12 2007
I believe that writing to EEPROM will do what you
want. Your chip has 256 bytes.
To WRITE:
WRITE 0,Variable.HighByte,Variable.Lowbyte
To READ:
READ 0,Variable.HighByte,Variable.Lowbyte
Charles Linquist
meriachee wrote:
>
> Hi folks,
>
> Can somebody please help me get a routine together that will allow me
> to write a word sized variable to the memory of a 16f819 and be able
> to read it back when the chip powers up. I know this is not rocket
> science, but for whatever reason I cannot for the life of me figure it
> out.
>
> Thanks
> Gary
>
>

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: stupid question - PBPro - redbinaryx - Feb 20 7:21:56 2007
Here is some code I use in a 16F627A:
void writeEEPROMbyte(uns8 argAdr, uns8 argByt) {
GIE = 0; // disable interrupts - the
write seq requires a specific number of cycles or will fail
while (GIE) {
// make sure interrupts are disabled
}
EECON1.2 = 1; // set write enable flag WREN (EECON
bit 2)
EEADR = argAdr; // select eeprom address
EEDATA = argByt; // load data register byte
EECON2 = 0x55; // write sequence mystery #1
EECON2 = 0xAA; // write sequence mystery #2
EECON1.1 = 1; // set write trigger WR
(EECON bit 1)
while (EECON1.1) {
// wait for WR to be cleared by PIC
}
EECON1.2 = 0; // clear WREN
EEIF = 0; // clear EEIF
GIE = 1; // enable interrupts
}
void readEEPROM() {
EEADR = 0; // select eeprom address 0
EECON1.0 = 1; // set read enable flag RD
N_COL = EEDATA;
EEADR = 1; // select eeprom address 1
EECON1.0 = 1; // set read enable flag RD
N_LIN = EEDATA;
}
Hope this helps some.
--
Best regards,
Patrick Griffin
www.RedBinary.com
--- In p...@yahoogroups.com, "meriachee"
wrote:
>
> Hi folks,
>
> Can somebody please help me get a routine together that will allow me
> to write a word sized variable to the memory of a 16f819 and be able
> to read it back when the chip powers up. I know this is not rocket
> science, but for whatever reason I cannot for the life of me figure
it
> out.
>
> Thanks
> Gary
>

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )