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.

Using Internal Data EEPROM on PIC16F877

Status
Not open for further replies.

lee_man_tbu

New Member
Hi everyone

I am trying too load the internal Data EEPROM on my PIC and it doesn't seem too be working. Can someone take a look at my code and tell me if it look ok or if you might see any problems

Thanks

Lee

P.S.
I have the data and address all ready loaded in ADDR and Temp_Data before calling the Proc.

Write_EEPROM

BSF STATUS, RP1
BSF STATUS, RP0 ;Bank 3
BTFSC EECON1, WR ;Wait for write to finish
GOTO $-1

BCF STATUS, RP0 ;Bank 0 ( ADDR at Bank 0)
BCF STATUS, RP1
MOVF ADDR, W ;Address to write to
BSF STATUS, RP1 ;Bank 2
MOVWF EEADR ;Save Address

BCF STATUS,RP1;Bank 0 ( Temp data at Bank0 )
MOVF Temp_Data, W ;Data to write
BSF STATUS,RP1 ;Bank 2
MOVWF EEDATA ;Save Data

BSF STATUS, RP0 ;Bank 3
BCF EECON1, EEPGD ;Point to Data memory
BSF EECON1, WREN ;Enable writes

MOVLW 0x55 ;Write 55h to EECON2
MOVWF EECON2
MOVLW 0xAA ;Write AAh to EECON2
MOVWF EECON2
BSF EECON1, WR ;Start write operation

BCF EECON1, WREN ;Disable writes

BCF STATUS,RP0 ;Bank 0
BCF STATUS,RP1

return
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top