English
Language : 

AN247 Datasheet, PDF (24/32 Pages) Microchip Technology – A CAN Bootloader for PIC18F CAN Microcontrollers
AN247
; *****************************************************************************
; Function: VOID _PMRead()
;
VOID _PMEraseWrite()
;
; PreCondition:WREG1 and FSR0 must be loaded with the count and address of
;
the source data.
; Input: None.
; Output: None.
; Side Effects: N/A.
; Stack Requirements: N/A
; Overview: These routines are technically not functions since they will not
;
return when called. They have been written in a linear form to
;
save space.Thus 'call' and 'return' instructions are not
;
included, but rather they are implied.
;
;
These are the program memory read/write functions. Erase is
;
available through control flags. An automatic erase option
;
is also available. A write lock indicator is in place to
;
ensure intentional write operations.
;
;
Note: write operations must be on 8-byte boundaries and
;
must be 8 bytes long. Also erase operations can only
;
occur on 64-byte boundaries.
;
; *****************************************************************************
#ifdef ALLOW_GET_CMD
_PMRead:
tblrd*+
movff TABLAT, POSTINC0
decfsz WREG1, F
bra
_PMRead
; Fill the buffer
; Not finished then repeat
bra
#endif
_CANSendResponce
_PMEraseWrite:
btfss MODE_AUTO_ERASE
bra
_PMWrite
_PMErase:
movf TBLPTRL, W
andlw b'00111111'
bnz
_PMWrite
_PMEraseJp1
movlw b'10010100'
rcall _StartWrite
_PMWrite:
btfsc MODE_ERASE_ONLY
; Erase if auto erase is requested
; Check for a valid 64 byte border
; Setup erase
; Erase the row
; Don't write if erase only is requested
#ifdef ALLOW_GET_CMD
bra
_CANSendAck
#else
bra
_CANMain
#endif
movf
andlw
bnz
movlw
movwf
TBLPTRL, W
b'00000111'
_CANMain
0x08
WREG1
; Check for a valid 8 byte border
DS00247A-page 24
 2003 Microchip Technology Inc.