
2–74
Motorola Sensor Device Data
For More Information On This Product,
  Go to: www.freescale.com
DIVIDE       INC     RSHIFT           ; Increase the right counter
             LSR     PRESHI2
             ROR     PRESHI           ; Right shift the high byte
             ROR     PRESLO           ; Right shift the low byte
             LDA     RSHIFT
             CMP     NO_SHIFT         ; If the right shift counter >= NO_SHIFT
             BHS     ENDDIVIDE        ; End the shifting
             JMP     DIVIDE           ; otherwise continue the shifting
ENDDIVIDE    LDA     PRESLO
             STA     PTEMPLO
             RTS
******************************************
*                                        *
*       Timer service interrupt          *
*     Alternates the Port data and       *
*          backplane of LCD              *
*                                        *
******************************************
TIMERCMP     STA     TEMP2            ; Push Accumulator
             COM     PORTC            ; Port C = – (Port C)
             COM     PORTB            ; Port B = – (Port B)
             COM     PORTA            ; Port A = – (Port A)
             LDA     START_TIME       ; Start to count down the hold time
             CMP     #$FF             ; if START_TIME = FF
             BNE     SKIP_TIME
             JSR     CHECK_HOLD
SKIP_TIME    BSR     COMPRGT          ; Branch to subroutine compare register
             LDA     TEMP2            ; Pop Accumulator
             RTI
******************************************
*                                        *
*      Check whether the hold time       *
*        of crash impact is due          *
*                                        *
******************************************
CHECK_HOLD   DEC     HOLD_CNT
             LDA     HOLD_CNT
             CMP     #$00             ; Is the hold time up
             BNE     NOT_YET
             LDA     #$00             ; If yes,
             STA     PLMA             ; stop buzzer
             LDA     #$FF             ; Set HOLD_DONE to FF indicate that the
             STA     HOLD_DONE        ; hold time is up
             CLR     START_TIME       ; Stop the counting down of hold time
NOT_YET      RTS
******************************************
*                                        *
*           Subroutine reset             *
*      the timer compare register        *
*                                        *
******************************************
COMPRGT      LDA     TCNTHI           ; Read Timer count register
             STA     TEMPTCNTHI       ; and store it in the RAM
             LDA     TCNTLO
             STA     TEMPTCNTLO
             ADD     #$4C             ; Add 1D4C H = 7500 periods
             STA     TEMPTCNTLO       ; with the current timer count
             LDA     TEMPTCNTHI       ; 1 period = 2 us
             ADC     #$1D
             STA     TEMPTCNTHI       ; Save the next count to the register
             STA     OCMPHI1
             LDA     TSTATUS          ; Clear the output compare flag
             LDA     TEMPTCNTLO       ; by access the timer status register
             STA     OCMPLO1          ; and then access the output compare
             RTS                      ; register
******************************************
*                                        *
*      Determine which is the next       *
*    acceleration value to be display    *
*                                        *
******************************************
MAXVALUE     LDA     PTEMPLO
             CMP     MAXACC           ; Compare the current acceleration with
             BLS     OLDMAX           ; the memory, branch if it is <= maxacc
             BRA     NEWMAX1
OLDMAX       LDA     HOLD_DONE        ; Decrease the Holdtime when
             CMP     #$FF             ; the maximum value remain unchanged
F
Freescale Semiconductor, Inc.
n
.