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.
This is the routine :
;---------------------------------------------
; the value to write is in variable sup
; the address si in register w
;--------------------------------------------
Scrivi_Dato
BSF STATUS, RP1
BCF STATUS, RP0 ; Bank 2
movwf EEADR ; EEADR<=w
Banksel sup
Movf sup,0 ;w<=sup
BSF STATUS, RP1
BCF STATUS, RP0 ; Bank 2
movwf EEDATA ;EEDATA<=w
BSF STATUS,RP0 ; Banco 3
BCF EECON1,EEPGD ;Punta alla Data Memory
BSF EECON1,WREN ;Abilito la scrittura
In addition to the global interrupt enable GIE, I think you need to enable EEIE bit in PIR2 to get an interrupt to come out of SLEEP. You also have to have an interrupt service routine at location 4 to clear the EEIF bit.
I don't use this routine myself. Since writing to the eeprom takes a long time, I simply return from this eeprom write routine and clear the WREN bit elsewhere. Anyway, a simpler routine instead of using SLEEP and interrupts is as follows:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.