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

📄 daytona_routines_l90j.asm

📁 基于MOTOLOLAR单片机的TPMS发送控制器代码设计
💻 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_8ms             ; 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
                bls     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_8ms              ; 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
                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
                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.
                pulx                            ; If all bits are sent, restore XR
                rts                             ;  and 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:                                         ; 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
                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,
                cmp     #$00                    ;  then guess is too high (DOUT_BAR toggled low).
                beq     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

*** 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 + -