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

📄 daytona_routines_l22b.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 output mode,
                jsr     SERSAR                   ; perform A/D conversion,
                lda     SAR                      ; get converted value and store
                sta     PRESSURE                 ; Pressure data.

                jsr     IDLE

Chk_max:        cmp     Max_Pres
                blo     Chk_min
                sta     Max_Pres

Chk_min:        cmp     Min_Pres
                bhi     Not_Min
                sta     Min_Pres

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

SEND_BYTE:
                psha                            ; Save accumulator
                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
SEND_nextbit:                                   ;  to Daytona.
                sec                             ; Set the carry bit
                rolx                            ; Rotate x left and watch the Carry bit toggle.
                bcs     ONE                     ; Send a '1' if Carry set else
                bcc     ZERO                    ;  send '0' just to be symetric.
ONE:            bset    SDATA,PORTA             ; SDATA = '1'
                bra     TOGGLE_CLOCK

ZERO:           bclr    SDATA,PORTA             ; SDATA = '0'
                bra     TOGGLE_CLOCK            ; again to be symetric

TOGGLE_CLOCK:   bset    DCLK,PORTA              ; Shift SDATA state into DAR by toggling clock
                lda     BITCOUNT
                cmp     #!1                     ; This is a work-around to an L22B
                bne     NOTLAST                 ; rev4 bug: need to hold the last
                ldhx    #!100                   ; clock high for at least 50 us (could also
                jsr     tempo                   ; double-clock, this way is more elegant, I think)

NOTLAST:        bclr    DCLK,PORTA
                dec     BITCOUNT                ; Determine if there are more bits to be sent.
                bne     SEND_nextbit            ; Shift out next bit if we have more bits to send.
                pula                            ; If all bits are sent, restore accumulator
                rts                             ;  and return.

; Daytona Serial SAR routine (SSAR)
;
; Called with:    jsr SERSAR
; Returns: 8 bit converted value in SAR variable
; Calls          SEND_BYTE
SERSAR:                                         ; serial SAR routine
                psha                            ; save accumulator

START_CONV:
INIT_DAC:       clr     SAR                     ; SAR will contain the result of 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
                jsr     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,
                cmp     #$00                    ;  then guess is too high (DOUT_BAR toggled low).
                beq     TOO_HIGH                ;
;                brclr   DOUT_BAR,PORTA,TOO_HIGH
; -------------------------------------------------
                                                ; If DOUT did not toggle low, then guess is too low
                                                ;  so we add this value to SAR by OR'ing it with T2
                lda     SAR                     ; This is the same as setting the current bit weight
                                                ;  to '1'.
                ora     T2                      ;
                sta     SAR                     ;
                                                ;
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:
                                                ; SAR contains the converted value.
                pula                            ; restore accumulator.
                rts

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

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

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

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

⌨️ 快捷键说明

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