English
Language : 

AN247 Datasheet, PDF (18/32 Pages) Microchip Technology – A CAN Bootloader for PIC18F CAN Microcontrollers
AN247
; *****************************************************************************
_STARTUPCODE 0x00
; *****************************************************************************
bra
_CANInit
bra
_StartWrite
; *****************************************************************************
_INTV_H CODE 0x08
; *****************************************************************************
#ifdef NEAR_JUMP
bra
HIGH_INT_VECT
#else
goto HIGH_INT_VECT
#endif
; *****************************************************************************
_INTV_L CODE 0x18
; *****************************************************************************
#ifdef NEAR_JUMP
bra
LOW_INT_VECT
#else
goto LOW_INT_VECT
#endif
; *****************************************************************************
; *****************************************************************************
_CAN_IO_MODULE CODE
; *****************************************************************************
; Function: VOID _StartWrite(WREG _eecon_data)
;
; PreCondition: Nothing
; Input: _eecon_data
; Output: Nothing. Self write timing started.
; Side Effects: EECON1 is corrupted; WREG is corrupted.
; Stack Requirements: 1 level.
; Overview: Unlock and start the write or erase sequence to protected
;
memory. Function will wait until write is finished.
;
; *****************************************************************************
_StartWrite:
movwf EECON1
btfss MODE_WRT_UNLCK
; Stop if write locked
return
movlw 0x55
; Unlock
movwf EECON2
movlw 0xAA
movwf EECON2
bsf
EECON1, WR
; Start the write
nop
btfsc EECON1, WR
; Wait (depends on mem type)
bra
$-2
return
; *****************************************************************************
DS00247A-page 18
 2003 Microchip Technology Inc.