
2–72
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
LDA #$40 ; Enable the output compare interrupt
STA TCONTROL
CLI ; Interrupt begins here
LDA #$CC ; Port C = 1100 1100 Letter ”C”
STA PORTC
LDA #$BE ; Port B = 1011 1110 Letter ”A”
STA PORTB
LDA #$C4 ; Port A = 1100 0100 Letter ”L”
STA PORTA
LDA #16
IDLE JSR DLY20 ; Idling for a while (16*0.125 = 2 sec)
DECA ; for the zero offset to stabilize
BNE IDLE ; before perform auto–zero
LDA #$00 ; Sample the data 32,768 times and take
STA DIV_LO ; the average 8000 H = 32,768
LDA #$80 ; Right shift of 15 equivalent to divide
STA DIV_HI ; by 32,768
LDA #!15 ; Overall sampling time = 1.033 s)
STA NO_SHIFT
JSR READAD ; Zero acceleration calibration
LDX #5 ; Calculate the zero offset
LDA PTEMPLO ; DC offset = PTEMPLO * 5
STA ZERO_ACC
MUL
STA DCOFFSETLO ; Save the zero offset in the RAM
TXA
STA DCOFFSETHI
CLR HOLD_CNT
LDA #$10 ; Sample the data 16 times and take
STA DIV_LO ; the average 0100 H = 16
LDA #$00 ; Right shift of 4 equivalent to divide
STA DIV_HI ; by 16
LDA #$4 ; Overall sampling time = 650 us
STA NO_SHIFT
LDA ZERO_ACC ; Display 0.0g at the start
STA MAXACC
JSR ADTOLCD
CLR START_TIME
CLR AVE_CNT1
CLR AVE_CNT2
CLR SHIFT_CNT
CLR AVERAGE_L
CLR AVERAGE_M
CLR AVERAGE_H
REPEAT JSR READAD ; Read acceleration from ADC
LDA ZERO_ACC
ADD #$04
CMP PTEMPLO
BLO CRASH ; If the acceleration < 2.0g
LDA PTEMPLO ; Accumulate the averaged results
ADD AVERAGE_L ; for 128 times and take the averaging
STA AVERAGE_L ; again to achieve more stable
CLRA ; reading at low g
ADC AVERAGE_M
STA AVERAGE_M
CLRA
ADC AVERAGE_H
STA AVERAGE_H
LDA #$01
ADD AVE_CNT1
STA AVE_CNT1
CLRA
ADC AVE_CNT2
STA AVE_CNT2
CMP #$04
BNE REPEAT
LDA AVE_CNT1
CMP #$00
BNE REPEAT
SHIFTING INC SHIFT_CNT ; Take the average of the 128 samples
LSR AVERAGE_H
ROR AVERAGE_M
ROR AVERAGE_L
LDA SHIFT_CNT
CMP #$0A
BLO SHIFTING
LDA AVERAGE_L
F
Freescale Semiconductor, Inc.
n
.