blueroomelectronics
Well-Known Member
This works in the MPLAB simulator but not on the 18F1320. Any idea what I'm doing wrong?
Code:
#define MyJune "Junebug Hi",0 ; Junebug name <= 16 bytes
list p=18F1320
include <p18F1320.inc>
CONFIG OSC=INTIO2,WDT=OFF,LVP=OFF
org 0x0000 ; Junebug bootloader vector
Start bcf INTCON,GIE ; interrupts OFF
movlw low(Name)
movwf TBLPTRL
movlw high(Name)
movwf TBLPTRH ; point to Name table
clrf EEADR
Loop tblrd*+ ; read table and increment
tstfsz TABLAT ; is it 0x00
bra WriteEE ; no then repeat
bra Exit
WriteEE bcf PIR2,EEIF ; clear EE flag
movff TABLAT,EEDATA ; EEDATA = TABLAT
bcf EECON1,EEPGD
bsf EECON1,WREN ; enable EEPROM writes
movlw 0x55
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1,WR
btfss PIR2,EEIF
bra $-2
incf EEADR
bra Loop
Exit bcf EECON1,WREN
bra $ ; stop
Name data MyJune
END