Freescale Semiconductor, Inc.
BEQ
LDA
BRA
LDA
STA
CLR
LDA
STA
LDA
STA
RTS
NEWMAX1
MAXACC
NEWMAX2
#$C8
HOLD_CNT
HOLD_DONE
#$FF
START_TIME
PTEMPLO
MAXACC
; Branch if the Holdtime is due
; otherwise use the current value
NEWMAX1
NEWMAX2
; Hold time = 200 * 15 ms = 3 sec
; Reload the hold time for the next
; maximum value
; Start to count down the hold time
; Take the current value as maximum
******************************************
*
*
*
*
*
*
*
*
*
*
*
*
This subroutine is to convert
the AD data to the LCD
Save the data to be diaplayed
in MAXACC
******************************************
ADTOLCD
SEI
LDA
STA
LDA
STA
LDA
LDX
MUL
ADD
STA
STA
LDA
STA
CLRA
TXA
ADC
STA
STA
LDA
SUB
STA
LDA
SBC
STA
BCS
BRA
LDA
SUB
STA
LDA
SBC
STA
LDA
STA
CLRX
LDA
SUB
STA
LDA
SBC
STA
INCX
BCC
DECX
LDA
ADD
STA
LDA
ADC
STA
TXA
AND
BEQ
LDA
STA
BRA
LDA
STA
; Disable the Timer Interrupt !!
; Load 0000 into the memory
#$00
DECHI
#$00
DECLO
MAXACC
#5
; Acceleration = AD x 5
; Acceleration is stored as DECHI
; and DECLO
; Temporary storage
; Assume positive deceleration
; ”00” positive ; ”01” negative
DECLO
DECLO
ACCLO
#$00
SIGN
DECHI
DECHI
ACCHI
DECLO
DCOFFSETLO
DECLO
DECHI
DCOFFSETHI
DECHI
NEGATIVE
SEARCH
DCOFFSETLO
ACCLO
; Temporary storage
; Deceleration = Dec – DC offset
; Branch if the result is negative
; Acceleration = DC offset – Dec
NEGATIVE
DECLO
DCOFFSETHI
ACCHI
DECHI
#$01
; Assign a negative sign
SIGN
SEARCH
LOOP100
; Start the search for hundred digit
; Acceleration = Acceleration – 100
DECLO
HUNDREDLO
DECLO
DECHI
HUNDREDHI
DECHI
; X = X + 1
LOOP100
; if acceleration >= 100, continue the
; loop100, otherwise X = X – 1
; Acceleration = Acceleration + 100
DECLO
HUNDREDLO
DECLO
DECHI
HUNDREDHI
DECHI
; Check if the MSD is zero
#$FF
NOZERO
$0300,X
PORTC
STARTTEN
#$00
; If MSD is zero, branch to NOZERO
; Output the first second digit
NOZERO
; Display blank if MSD is zero
PORTC
Motorola Sensor Device Data
www.motorola.com/semiconductors
Go to: www.freescale.com
2–75
For More Information On This Product,