
3–295
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
WTCONV
BRCLR
ADCTL,X #$80 WTCONV
LDAB
ADR2,X
CLRA
STD
SENSOUT
RTS
* Wait for completion of conversion flag
* Loads conversion result into Accumulator
* Stores conversion as SENSOUT
*
*
*
*
IN_HG
Subroutine IN_HG
Purpose is to convert the measured pressure SENSOUT, into
units of in–Hg, represented by a hex value of 305–150
This represents the range 30.5 – 15.0 in–Hg
LDD
POFFSET
* Loads maximum offset for subtraction
SUBD
SENSOUT
* RESULT = POFFSET–SENSOUT in hex format
STD
RESULT
* Stores hex result for P, in Hg
CMPD
#305
BHI
TOHIGH
CMPD
BLO
#150
TOLOW
LDAB
STAB
BRA
#$80
FLAG
END_CONV
TOHIGH
LDAB
#$FF
STAB
BRA
FLAG
END_CONV
TOLOW
LDAB
STAB
#$00
FLAG
END_CONV RTS
*
*
*
*
Subroutine ERROR
This subroutine sets the display digits to output
an error message having detected an out of range
measurement in the main program from FLAG
ERROR
LDAB
STAB
STAB
#$00
DIGIT1
DIGIT4
* Initialize digits 1,4 to blanks
LDAB
CMPB
BNE
FLAG
#$00
SET_HI
* FLAG is used to determine
* if above or below range.
* If above range GOTO SET_HI
LDAB
STAB
LDAB
STAB
BRA
#$0E
DIGIT2
#$7E
DIGIT3
END_ERR
* ELSE display LO on display
* Set DIGIT2=L,DIGIT3=O
* GOTO exit of subroutine
SET_HI
LDAB
#$37
STAB
LDAB
STAB
* Set DIGIT2=H,DIGIT3=1
DIGIT2
#$30
DIGIT3
END_ERR
RTS
*
*
*
*
*
Subroutine BCDCONV
Purpose is to convert ALTITUDE from hex to BCD
uses standard HEX–BCD conversion scheme
Divide HEX/10 store Remainder, swap Q & R, repeat
process until remainder = 0.
BCDCONV
LDAA
#$00
STAA
STAA
STAA
LDY
LDD
#$A
IDIV
STAB
DEY
CPX
XGDX
BNE
LDX
RTS
* Default Digits 2,3,4 to 0
DIGIT2
DIGIT3
DIGIT4
#DIGIT4
RESULT
* Conversion starts with lowest digit
* Load voltage to be converted
* Divide hex digit by 10
* Quotient in X, Remainder in D
* stores 8 LSB’s of remainder as BCD digit
CONVLP
LDX
0,Y
#$0
* Determines if last digit stored
* Exchanges remainder & quotient
CONVLP
#REGBASE
* Reloads BASE into main program
*
Subroutine LOOKUP
F
Freescale Semiconductor, Inc.
n
.