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

📄 main.asm

📁 胎压检测发送端汇编源码-tpms-transmitters
💻 ASM
字号:
loadall

;/*****************************************************************************/
;/* PROJECT : Mosport State Machine Mimic   MODULE : MAIN                     */
;/*****************************************************************************/
; Initial version: Jeff Burgess

RAMStart        EQU     $0080
RomStart        EQU     $7880
VectorStart     EQU     $FFF2


$Include        'hardef.h'
$Include        'rk2regs.h'
$Include        'rom1.h'
$Include        'daytona_hardware_def_ADOR.h'
                                        ; Daytona Hardware Pin Definitions

        org     RAMStart+8
$Include        'ram.h'
$Include        'daytona_ram_variables.h'
                                        ; Daytona Serial and SAR variables
        org     $7800
$Include        'Device_ID.inc'

        org     RomStart
$Include        'util.asm'
$Include        'emis1.asm'
$Include        'makeframe_moroso.asm'
$Include        'check_battery.asm'
$Include        'it.asm'
$Include        'Transmit_Frame.asm'

; $Include        'init_ASK.asm'
$Include        'init_FSK.asm'

; $Include        'daytona_routines_avg_L22B.asm' ; needs fix
; $Include        'daytona_routines_L22B.asm'
; $Include        'daytona_routines_avg_L90J.asm' ; needs fix
$Include        'daytona_routines_L90J.asm'
; $Include        'daytona_routines_moving_avg_2_L90J.asm' ; needs fix
                                        ; Daytona routines

; Note: to switch the transmission frequency, you must change the DATACLK
;  option in the file rom1.h

Main:

        mov     #$33,CONFIG             ; LVISTOP disabled!!!
        jsr     Init                    ; Initialize Module, clear counters/variables.
        jsr     IDLE                    ; Place Daytona in IDLE mode and
        stop                            ; wait here for falling edge at DOUT.

KB_entry:

        rsp
        bset    1,INTKBSR               ; Disable keyboard Interrupts.

        jsr     Daytona_NoTx_Read       ; Read pressure data (not temperature)

        lda     Tx_count                ; Increment Tx counter
        inca
        sta     Tx_count
        cmp     #!9                     ; Check if time to transmit yet.
        beq     Prepare_Tx

        jsr     init_KBI                ; Don't transmit yet, re-enable KBD interrupts
	jsr	init_ports		; Initialize ports
        jsr     IDLE                    ; and wait for next wake-up.
        stop

Prepare_Tx:

        jsr     Check_battery           ; Check out the LVISR.
        lda     Max_Pres                ; Determine whether there is an issue with the pressure,
        sub     Min_Pres                ; and if fast transmission mode is required.
        cmp     #!5		        ; 12.5 kPa
        bhi     Fast_Data_Mode

Normal_Data_Mode:

        lda     #1                      ; No problem, transmit one data frame.
        sta     Tx_count
        bra     Next_Frame

Fast_Data_Mode:

        lda     #$FF                    ; Problem detected; transmit 255 data frames at ~800ms
        sta     Tx_count                ; intervals.
        bset    4,STATUS                ; Indicates to receiver that there is a potential problem.

Next_Frame:

        jsr     Daytona_Tx_Read         ; Read temperature and pressure data.
        jsr     Random_delay            ; Add a random delay (~0 - 100 ms).
        jsr     Transmit_Frame          ; Process and transmit the data.

        lda     Tx_count
        deca
        sta     Tx_count
        cmp     #$01
        bne     Notlastframe
        bclr    4,STATUS

Notlastframe:
        lda     Tx_count
        beq     asleep_tx

        jsr     delay_800_ms            ; Wait for 0.8 seconds.
        bra     Next_Frame

asleep_tx:

        jsr     init                    ; Re-initialize all variables and KBD interrupts, and
        jsr     IDLE                    ; wait for wake-up.
        stop

        org     VectorStart

$Include        'vector.asm'

⌨️ 快捷键说明

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