![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Need some help guys.
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 ?? |
|
|
|
|
|
|
(permalink) |
|
It's all explained in the datasheet!.
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). |
|
|
|
|
|
|
(permalink) | |
|
Quote:
First set your eeprom address. Code:
;EEprom data address ;=================== EEMCNT1 equ h'00' 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 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
__________________
InfinityCreation - Where creations goes to infinity! |
||
|
|
|