PIC16F818/819
EXAMPLE 3-4:
ERASING A FLASH PROGRAM MEMORY ROW
BANKSEL EEADRH
; Select Bank of EEADRH
;
; MS Byte of Program Address to Erase
MOVF
MOVWF
ADDRH, W
EEADRH
MOVF
MOVWF
ADDRL, W
EEADR
;
; LS Byte of Program Address to Erase
ERASE_ROW
BANKSEL EECON1
; Select Bank of EECON1
BSF
BSF
BSF
EECON1, EEPGD ; Point to PROGRAM memory
EECON1, WREN
EECON1, FREE
; Enable Write to memory
; Enable Row Erase operation
;
BCF
INTCON, GIE
55h
EECON2
AAh
EECON2
EECON1, WR
; Disable interrupts (if using)
;
; Write 55h
;
; Write AAh
; Start Erase (CPU stall)
MOVLW
MOVWF
MOVLW
MOVWF
BSF
NOP
; Any instructions here are ignored as processor
; halts to begin Erase sequence
; processor will stop here and wait for Erase complete
; after Erase processor continues with 3rd instruction
; Disable Row Erase operation
; Disable writes
NOP
BCF
BCF
BSF
EECON1, FREE
EECON1, WREN
INTCON, GIE
; Enable interrupts (if using)
2004 Microchip Technology Inc.
DS39598E-page 29