How do I write my data to the EEPROM. For eg: In a PIC 16F84 during processing I want to transfer data into the EEPROM. Can someone please send me a short code(in assembly :wink: ) to do a simple EEPROM transfer.
Another thing, how are the EEPROM address computed. I mean they start from 2000H or something ,how ??
You access the internal EEPROM through special data registers, basically one for the address (0-63 in your case) and one for the data. But it's all explained in the datasheet, including the special methods required to write to it.
If you check my tutorials, the IR one shows how to read and write the EEPROM (for storing and restoring the last remote control operation).
How do I write my data to the EEPROM. For eg: In a PIC 16F84 during processing I want to transfer data into the EEPROM. Can someone please send me a short code(in assembly :wink: ) to do a simple EEPROM transfer.
Another thing, how are the EEPROM address computed. I mean they start from 2000H or something ,how ??
Ok, here is how u do it.
First set your eeprom address.
Code:
;EEprom data address
;===================
EEMCNT1 equ h'00'
then to do a read from the eeprom address,
Code:
;eeprom read
;-----------
eemodrd bsf status,rp0 ;Change to Bank1
movlw EEMCNT1
movwf eeadr ;copy to eedata
bsf eecon1,rd ;read data from eeprom address
movf eedata,w
bcf status,rp0 ;Change to Bank0
movwf mCnt1 ;this is where you move the retrive eeprom data to other address
To write to an eeprom,
Code:
;eeprom write
;------------
eemodwr movf mCnt1,w ;this is where the data you wish to write to eeprom
bsf status,rp0 ;Change to Bank1
bsf eecon1,wren ;enable eeprom write
movwf eedata ;copy to eedata
movlw EEMCNT1
movwf eeadr ;copy to eeadr
movlw h'55'
movwf eecon2
movlw h'aa'
movwf eecon2
bsf eecon1,wr ;write data to eeprom
btfsc eecon1,wr ;loop till write process is finish
goto $-1
bcf status,rp0 ;Change to Bank0
Once you declare the eeprom address to a variable, you can easily write and read from it. The code i provide will do general read & write function for eeprom. You just need to replace "mCnt1" to your own desire variable for reading and writing. You can leave the rest of the code and it should work. If you still in doubt, feel free to ask more