⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_hyperterm.asm

📁 胎压检测接收端汇编源码--tpms-rx
💻 ASM
字号:
* Main.asm

**********************************************************************
* Contains the main control program for the TPMS receiver module.    *
**********************************************************************

RAMStart        EQU     $0040
RomStart        EQU     $E000
FLASHVARS       EQU     $E000                           ;Variables that need to be in NVM are stored here (first page of Flash)
VectorStart     EQU     $FFDC

NB_DATA         EQU     !8                              ;8 bytes of real data in the frame.

$Include        'kx8regs.inc'

                ORG     RamStart
$Include        'Ram.inc'

                ORG     FLASHVARS

                DB      $2A                             ;Default pressure threshold (ambient)
                DB      $33,$33,$33,$00                 ;Default LF tire ID
                DB      $41,$42,$43,$44                 ;Default RF tire ID
                DB      $81,$82,$83,$84                 ;Default LR tire ID
                DB      $C1,$C2,$C3,$C4                 ;Default RR tire ID

                ORG     RomStart+$40                    ;Leave some room for FLASH page r/w.
$Include        'Init_Hyperterm.asm'
$Include        'LEDCont.asm'
$Include        'SPI.asm'
$Include        'Delay.asm'
$Include        'SCI_ASCII.asm'
$Include        'Timer_ISR.asm'
$Include        'TBM_ISR_Hyperterm.asm'
$Include        'Flash.asm'


Main_Start:     RSP
                JSR     INIT

**********************************************************************
* Main                                                               *
* Under normal conditions, this is the general program flow.         *
* Timebase interrupts are all that will interrupt this flow.         *
**********************************************************************
Main:           MOV     #%01110111,Write_SPI            ;434MHz, FSK, SOE=Yes, SR=7, DME=Yes, HE=Yes.
                MOV     #%11111111,Write_SPI+1          ;ID Byte=$FF
                MOV     #%11001000,Write_SPI+2          ;9600bps, MG=0, MS=0, PG=1.
                JSR     RomeoConfig

                JSR     BlinkLEDs                       ;Let the user know everything is going okay.
Loop:           JSR     GetSPIData                      ;Go get the received data from the Romeo2 SPI.
;                BSR     CheckSum                        ;Validate the received data.
;                JSR     ProcessData                     ;Show the user what's going on with the LEDs.
                JSR     Blink_Rx
                JSR     SCI_Send                        ;Send the data out the serial port.
                BRA     Loop                            ;Get next data frame.

**********************************************************************
* CheckSum                                                           *
* Calculate the checksum and compare it to the checksum received.    *
**********************************************************************
CheckSum:       CLRA
                CLRH

                LDX     #NB_DATA
Check_Next:     ADD     DATA-1,X
                DBNZX   Check_Next
                TSTA
                BNE     Check_Bad
                RTS                                     ;The checksum is good.

Check_Bad:      RSP                                     ;PC value from previous subroutine not needed anymore.
                BRA     Loop                            ;No need for further data processing: go get
                                                        ;the next data frame.

**************************************************************
* DUMMY_ISR - Dummy Interrupt Service Routine.               *
*             Just does a return from interrupt.             *
**************************************************************
dummy_isr:      rti           ; return

**************************************************************
* Vectors.                                                   *
**************************************************************
                ORG     VectorStart
$Include        'Vector.inc'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -