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

📄 daytona_routines_l90j.asm

📁 胎压检测发送端汇编源码-tpms-transmitters
💻 ASM
字号:
;/* Daytona control routines                    */
;/* V0.1   4/22/00  Ador Reodique               */
;/* Modified by Gilles Rimauro (04/27/01)       */
;/* Modified by Jeff Burgess (Feb 2002)         */
;/* - Added longer sampling cap charge time (Px)*/
;/* - Optimized ROM space used                  */
;/* (c) 2000 Motorola                           */

;/* Daytona control start */
Daytona_NoTx_Read:
                psha

                jsr     READPRESS               ; Sample pressure
                ldhx    #wait_0_5ms             ; and hold.
                jsr     tempo

                jsr     READOUT                 ; Place Daytona in conversion mode,
                bsr     SERSAR                  ; perform A/D conversion,
                lda     SAR                     ; get converted value and store
                sta     PRESSURE                ; Pressure data.

                jsr     IDLE

Chk_max:        cmp     Max_Pres                ; Determine whether this pressure measurement
                blo     Chk_min                 ; is the maximum within the last 54 seconds.
                sta     Max_Pres

Chk_min:        cmp     Min_Pres                ; Determine whether the pressure measurement
                bhi     Not_Min                 ; is the minimum within the last period.
                sta     Min_Pres                ; These are used to determine whether to go
                                                ; to fast transmission mode.
Not_Min:        pula
                rts

;/* Daytona read end */

Daytona_Tx_Read:
                psha
                jsr     READTEMP                 ; Sample temperature
                ldhx    #wait_0_2ms              ; and hold.
                jsr     tempo

                jsr     READOUT                  ; Place Daytona in output mode,
                jsr     SERSAR                   ; perform A/D conversion,
                lda     SAR                      ; get converted value and store
                sta     TEMPERATURE              ; Temperature data.

                jsr     READPRESS                ; Sample pressure
                ldhx    #wait_0_5ms              ; and hold.
                jsr     tempo

                jsr     READOUT                  ; Place Daytona in output mode,
                jsr     SERSAR                   ; perform A/D conversion,
                lda     SAR                      ; get converted value and store
                sta     PRESSURE                 ; Pressure data.

                bsr     IDLE

                pula
                rts

********************************************************************************
* Software serial interface (SPI) routine to send DATA MSB first               *
* Called with:  mov #XX,DATABUFF    -- DATABUFF contains 8-bit word to be sent *
*               jsr    SEND_BYTE                                               *
* Returns:      none                                                           *
* Variables:                                                                   *
* BITCOUNT = 8 bit counter                                                     *
* SDATA = DATA pin connected to PORTA                                          *
* DCLK = CLK pin connected to PORTA                                            *
********************************************************************************

SEND_BYTE:      PSHX                            ; Store the XR.
                BCLR   DCLK,PORTA               ; Clock is initially low.
                MOV    #$08,BITCOUNT            ; Initialize number of bits to be sent (1 byte).
                LDX    DATABUFF                 ; DATABUFF contains the byte to be sent serially
                                                ;  to Daytona.
Send_Nextbit:   ROLX                            ; Rotate x left and watch the Carry bit.
                BCC     ZERO                    ; Send a '1' if Carry set else send a '0.'
ONE:            BSET    SDATA,PORTA             ; SDATA = '1.'
                BRA     TOGGLE_CLOCK

ZERO:           BCLR    SDATA,PORTA             ; SDATA = '0.'

TOGGLE_CLOCK:   BSET    DCLK,PORTA              ; Shift SDATA state into DAR by toggling clock.
                BCLR    DCLK,PORTA              ;
                DBNZ    BITCOUNT,Send_Nextbit   ; Determine if there are more bits to be sent.
                PULX                            ; Restore the XR.
                RTS                             ; Return.

**************************************************
* Daytona Serial SAR routine (SSAR)              *
*                                                *
* Called with:    jsr SERSAR                     *
* Returns: 8 bit converted value in SAR variable *
* Calls          SEND_BYTE                       *
* Variables:                                     *
* T2 = 8-bit temporary variable                  *
* SAR = Result variable                          *
*                                                *
* OUTB pin is connected to PORTA3                *
**************************************************

SerSAR:         PSHA                            ; Save accumulator
Init_DAC:       CLR     SAR                     ; SAR will contain the result of the conversion.
                MOV     #$80,T2                 ; Intial DAC weight $80 ~ 1/2 FS

Conv_Wait:      LDA     T2                      ;
                ORA     SAR                     ; Place guess in SAR, the result register.
                STA     DATABUFF                ; DATABUFF is 8-bit data to be sent serially to
                BSR     SEND_BYTE               ;  Daytona DAR.  This is the guess value.

Read_DOUT_Level:                                ; Now determine if guess is too high or too low
                                                ;   by reading Daytona DOUT level.
                LDA     PORTA                   ; This is done by reading PORTA and isolating
                AND     #%00001000              ; DOUT_BAR (PTA3).  Compare this to 0: if equal,
                BEQ     TOO_HIGH                ;  then guess is too high (DOUT_BAR toggled low).;

                LDA     SAR                     ; If DOUT did not toggle low, then guess is too low
                ORA     T2                      ; so we add this value to SAR by OR'ing it with T2
                STA     SAR                     ; This is the same as setting the current bit weight
                                                ;  to '1'.
Too_High:       ROR     T2                      ; If DOUT toggled low, then guess is too low.
                                                ; In this case, try the next bit weight until
                BCC     CONV_WAIT               ;  the carry bit is set.
Conv_Ready:     PULA                            ; SAR contains the converted value.
                RTS                             ; Restore accumulator and Return.

*** Place Daytona in Read Temperature Mode
READTEMP:
                bset S1Vpp,PORTA
                bclr S0,PORTA
                rts

*** Place Daytona in Read Pressure Mode
READPRESS:
                bclr S1Vpp,PORTA
                bset S0,PORTA
                rts

*** Place Daytona in IDLE Mode
IDLE:
                bclr S1Vpp,PORTA
                bclr S0,PORTA
                rts

*** Place Daytona in SAMPLE Mode
READOUT:
                bset S1Vpp,PORTA
                bset S0,PORTA
                rts

⌨️ 快捷键说明

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