you might simplify the init seq to this, using labels to point to the isr vectors would be safer in the long term
Code:
ASM
Vector_Table_Init:
MOVLW 0x00 ;Vector Table Start Address: 00 4008h
MOVWF IVTBASEU, ACCESS
MOVLW 0x40
MOVWF IVTBASEH, ACCESS
MOVLW 0x08
MOVWF IVTBASEL, ACCESS
MOVLW 0x00 ;TMR1_INT = Vector #32
MOVWF TBLPTRU, ACCESS ;4008h + [(32d) 20h * 2] = 4048
MOVLW 0x40
MOVWF TBLPTRH, ACCESS
MOVLW 0x48
MOVWF TBLPTRL, ACCESS
MOVLW 0x30 ;T1ISR >> 2; 08C0h >> 2 = 0230h
MOVWF TABLAT, ACCESS
TBLWT*+
MOVLW 0x02
MOVWF TABLAT, ACCESS
TBLWT*+
MOVLW 0x18
MOVWF TBLPTRL, ACCESS
MOVLW 0x38 ;INT0ISR >> 2; 08E0h >> 2 = 0238h
MOVWF TABLAT, ACCESS
TBLWT*+
MOVLW 0x02
MOVWF TABLAT, ACCESS
TBLWT*+
BANKSEL NVMCON1
MOVLW 0x84 ;Setting to write to PFM
MOVWF NVMCON1
MOVLW 0x55 ;Required unlock sequence
MOVWF NVMCON2
MOVLW 0xAA
MOVWF NVMCON2
BSF NVMCON1, WR ;Start writing to PFM
BTFSC NVMCON1, WR ;Wait for write to complete
GOTO $-2
RETURN 1
ENDASM
caveat what is the label size for pbp3.1 ? might limit location to first 64k block
Bookmarks