Continue to Site

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.

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:

ADCIN 0, value
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
 
444

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

EEADR = (value)
EEDATA= (value)
 
data already there tho!

Hi

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

EEADR 0000009B
EEDATA 0000009A


-Richard
 
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.

Instead you should:
Code:
ADCIN 0, value 
Pause 25 
write 0, value

And read the value when you need it.

Good Luck

Ivancho
 
*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.

Latest threads

New Articles From Microcontroller Tips

Back
Top