Dears,
I need help on a code to write to the PIC16F628 EEPROM.
I should write decimal '11' in the first two bytes of the EEPROM
address.
I have tried a sample code but I need confirmation of the Interrupt
controls EEIF and EEIE have and where to put them; main program or
in the Interrupt Service Routine program.
BSF STATUS,RP0 ;select bank1
MOVLW 0x00 ;EEPROM address
MOVWF EEADR
MOVF 0x01,w ;EEPROM Data
MOVWF EEDATA
BSF EECON1,wren ;enable write
BCF INTCON, GIE ;Disable interrupts
MOVLW 0x55 ;unlock codes sequence
MOVWF EECON2
MOVLW 0xaa
MOVWF EECON2
BSF EECON1,WR ;write begins
SRE1: BTFSC EECON1,WR ;wait for "write" to complete
GOTO SRE1
BCF EECON1,wren ;disable other writes
BSF INTCON, GIE ;Enable interrupts
;BSF PIE1, EEIE ;Set interrupt flag in PIE1
;BCF PIR1, EEIF ;Clear Interrupt flag in PIR1
Thanks all.
Shaaks.
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
No comments:
Post a Comment