📄 canio.lst
字号:
00417
00418 ; *****************************************************************************
00419 ; This routine is essencially a polling loop that waits for a
00420 ; receive event from RXB0 of the CAN module. When data is
00421 ; received, FSR0 is set to point to the TX or RX buffer depending
00422 ; upon whether the request was a 'put' or a 'get'.
00423 ; *****************************************************************************
00006C 00424 _CANMain:
00006C 9E60 00425 bcf RXB0CON, RXFUL ; Clear the receive flag
00426
00006E AE60 00427 btfss RXB0CON, RXFUL ; Wait for a message
000070 D??? 00428 bra $ - 2
00429
000072 0004 00430 clrwdt
00431
00432 #ifdef ALLOW_GET_CMD
00433 btfss CAN_PG_BIT ; Put or get data?
00434 bra _CANMainJp1
00435
00436 lfsr 0, TXB0D0 ; Set pointer to the transmit buffer
00437 movlw 0x08
00438 movwf _bootCount ; Setup the count to eight
MPASM 03.20.08 Intermediate CANIO.ASM 2-3-2003 15:42:14 PAGE 12
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00439 movwf WREG1
00440 bra _CANMainJp2
00441 #endif
00442
000074 00443 _CANMainJp1
000074 EE0F F066 00444 lfsr 0, RXB0D0 ; Set pointer to the receive buffer
000078 5065 00445 movf RXB0DLC, W
00007A 0B0F 00446 andlw 0x0F
00007C 6E?? 00447 movwf _bootCount ; Store the count
00007E 6EF4 00448 movwf WREG1
000080 E0?? 00449 bz _CANMain ; Go back if no data specified for a put
00450
000082 00451 _CANMainJp2
00452 ; *****************************************************************************
00453
00454
00455
00456 ; *****************************************************************************
00457 ; Function: VOID _ReadWriteMemory()
00458 ;
00459 ; PreCondition: Enter only after _CANMain().
00460 ;
00461 ; Input: None.
00462 ;
00463 ; Output: None.
00464 ;
00465 ; Side
00466 ; Effects: N/A.
00467 ;
00468 ; Stack
00469 ; Requirements: N/A
00470 ;
00471 ; Overview: This routine is technically not a function since it will not
00472 ; return when called. It has been written in a linear form to
00473 ; save space. Thus 'call' and 'return' instructions are not
00474 ; included, but rather they are implied.
00475 ;
00476 ; This is the memory I/O engine. A total of eight data
00477 ; bytes are received and decoded. In addition two control
00478 ; bits are received, put/get and control/data.
00479 ;
00480 ; A pointer to the buffer is passed via FSR0 for reading or writing.
00481 ;
00482 ; The control register set contains a pointer, some control bits
00483 ; and special command registers.
00484 ;
00485 ; Control
00486 ; <PG><CD><ADDRL><ADDRH><ADDRU><_RES_><CTLBT><SPCMD><CPDTL><CPDTH>
00487 ;
00488 ; Data
00489 ; <PG><CD><DATA0><DATA1><DATA2><DATA3><DATA4><DATA5><DATA6><DATA7>
00490 ;
00491 ; PG bit Put = 0, Get = 1
MPASM 03.20.08 Intermediate CANIO.ASM 2-3-2003 15:42:14 PAGE 13
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00492 ; CD bit Control = 0, Data = 1
00493 ; *****************************************************************************
000082 00494 _ReadWriteMemory:
000082 B064 00495 btfsc CAN_CD_BIT ; Write/read data or control registers
000084 D??? 00496 bra _DataReg
00497
00498
00499 ; *****************************************************************************
00500 ; This routine reads or writes the bootloader control registers.
00501 ; Then is executes any imediate command received.
000086 00502 _ControlReg
000086 EE?? F0?? 00503 lfsr 1, _bootCtlMem
00504
00008A 00505 _ControlRegLp1
00506 #ifdef ALLOW_GET_CMD
00507 btfsc CAN_PG_BIT ; or copy control registers to buffer
00508 movff POSTINC1, POSTINC0
00509 btfss CAN_PG_BIT ; Copy the buffer to the control registers
00510 #endif
00008A CFEE FFE6 00511 movff POSTINC0, POSTINC1
00512
00513
00008E 2EF4 00514 decfsz WREG1, F
000090 D??? 00515 bra _ControlRegLp1
00516
00517 #ifdef ALLOW_GET_CMD
00518 btfsc CAN_PG_BIT
00519 bra _CANSendResponce ; Send responce if get
00520 #endif
00521 ; *********************************************************
00522
00523 ; *********************************************************
00524 ; This is a no operation command.
000092 50?? 00525 movf _bootSpcCmd, W ; NOP Command
000094 E0?? 00526 bz _SpecialCmdJp2 ; or send an acknowledge
00527 ; *********************************************************
00528
00529 ; *********************************************************
00530 ; This is the reset command.
000096 0A01 00531 xorlw CMD_RESET ; RESET Command
000098 B4D8 00532 btfsc STATUS, Z
00009A 00FF 00533 reset
00534 ; *********************************************************
00535
00536 ; *********************************************************
00537 ; This is the Selfcheck reset command. This routine
00538 ; resets the internal check registers, i.e. checksum and
00539 ; self verify.
00009C 50?? 00540 movf _bootSpcCmd, W ; RESET_CHKSM Command
00009E 0A02 00541 xorlw CMD_RST_CHKSM
0000A0 E1?? 00542 bnz _SpecialCmdJp1
00543
0000A2 6A?? 00544 clrf _bootChksmH ; Reset chksum
MPASM 03.20.08 Intermediate CANIO.ASM 2-3-2003 15:42:14 PAGE 14
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0000A4 6A?? 00545 clrf _bootChksmL
0000A6 90?? 00546 bcf ERR_VERIFY ; Clear the error verify flag
00547 ; *********************************************************
00548
00549 ; *********************************************************
00550 ; This is the Test and Run command. The checksum is
00551 ; verified, and the self-write verification bit is checked.
00552 ; If both pass, then the boot flag is cleared.
0000A8 00553 _SpecialCmdJp1
0000A8 50?? 00554 movf _bootSpcCmd, W ; RUN_CHKSM Command
0000AA 0A03 00555 xorlw CMD_CHK_RUN
0000AC E1?? 00556 bnz _SpecialCmdJp2
00557
0000AE 50?? 00558 movf _bootChkL, W ; Add the control byte
0000B0 26?? 00559 addwf _bootChksmL, F
0000B2 E1?? 00560 bnz _SpecialCmdJp2
0000B4 50?? 00561 movf _bootChkH, W
0000B6 22?? 00562 addwfc _bootChksmH, F
0000B8 E1?? 00563 bnz _SpecialCmdJp2
00564
0000BA B0?? 00565 btfsc ERR_VERIFY ; Look for verify errors
0000BC D??? 00566 bra _SpecialCmdJp2
00567
0000BE 68A9 00568 setf EEADR ; Point to last location of EEDATA
0000C0 68AA 00569 setf EEADRH
0000C2 6AA8 00570 clrf EEDATA ; and clear the data
0000C4 0E04 00571 movlw b'00000100' ; Setup for EEData
0000C6 D??? 00572 rcall _StartWrite
00573
0000C8 00574 _SpecialCmdJp2
00575 #ifdef ALLOW_GET_CMD
00576 bra _CANSendAck ; or send an acknowledge
00577 #else
0000C8 D??? 00578 bra _CANMain
00579 #endif
00580 ; *****************************************************************************
00581
00582
00583
00584 ; *****************************************************************************
00585 ; This is a jump routine to branch to the appropriate memory
00586 ; access function. The high byte of the 24-bit pointer is used
00587 ; to determine which memory to access. All program memorys
00588 ; (including Config and User IDs) are directly mapped.
00589 ; EEDATA is remapped.
00590 ;
00591
0000CA 00592 _DataReg
00593
00594 ; *********************************************************
0000CA 00595 _SetPointers
0000CA 50?? 00596 movf _bootAddrU, W ; Copy upper pointer
MPASM 03.20.08 Intermediate CANIO.ASM 2-3-2003 15:42:14 PAGE 15
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0000CC 6EF8 00597 movwf TBLPTRU
0000CE 0BF0 00598 andlw 0xF0 ; Filter
0000D0 6EF3 00599 movwf WREG2
00600
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -