# Writing to EEPROM on a 12F675 in PicBasic ?

Status
Not open for further replies.

#### mind

##### New Member
Hi

Does anyone have working code to write a word to the EEPROM on a PIC 12F675 and read it back again ? My basic code is as follows:

Pause 25
write 0, value.byte0
write 0, value.byte1

This seems to be compiled into asm in the list file exactly as the datasheet describes, but does not seem to work correctly. ie: the value is not retained on power cycle.

Compiled asm:

bsf STATUS, RP0
movwf EEDATA
bsf EECON1, WREN
movlw 55h
movwf EECON2
movlw 0AAh
movwf EECON2
bsf EECON1, WR
wrlp btfsc EECON1, WR
goto wrlp

Anyone have any ideas ? Thanks !

-Richard

#### tommyc2000

##### New Member
444

you must set up the address where to write and the value for data, before you do that

EEDATA= (value)

#### mind

##### New Member

Hi

They are already set. As follows from the compiler symbol table:

EEDATA 0000009A

-Richard

#### evandude

##### New Member
make sure the CPD bit is SET in the configuration bits. if not, you can't write to data EEPROM.

#### ivancho

##### New Member
By doing this
Code:
ADCIN 0, value
Pause 25
write 0, value.byte0
write 0, value.byte1
You are writting twice into the same memory location. The EEPROM data memoryallows byte read and write. A byte write automatically erases the location and writes the new value.

Code:
ADCIN 0, value
Pause 25
write 0, value
And read the value when you need it.

Good Luck

Ivancho

#### mind

##### New Member
*thanks*

Hi

Thanks for the reply. Sorted me out. I was using code that someone else posted as the "right" way to do it.

-R

Status
Not open for further replies.