DOWNLOAD MAIN
PIC_EEPROM_Data_Write macro
; by Randy Gamage
; Writes a byte to the PIC's on-board
; EEPROM space (256 bytes available)
; INPUT: FlashAddr0 (bank1) = address to write to
; W = Data to write
; OUTPUTS: Auto-increments the write
; address (FlashAddr0 var)
bank3
btfsc EECON1^0x180,WR
goto $ - 1
bank2
movwf EEDATA^0x100
bank0
movf FlashAddr0,W
bank2
movwf EEADR^0x100
bank3
bcf EECON1^0x180,EEPGD
bsf EECON1^0x180,WREN
bcf INTCON, GIE
movlw 0x55
movwf EECON2^0x180
movlw 0xAA
movwf EECON2^0x180
bsf EECON1^0x180,WR
bcf EECON1^0x180,WREN
btfsc EECON1^0x180,WR
goto $ - 1
bank0
incf FlashAddr0
bsf INTCON, GIE
endm
|