3–294
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
ORG
LDX
BSR
BSR
ADCONV
BSR
BSR
$C000
#REGBASE
SPI_CNFG
SET_UP
* DESIGNATES START OF MEMORY MAP FOR USER CODE
* Location of base register for indirect adr
* Set–up SPI Module for data X–mit to LCD
* Power–Up A/D, initialize constants
* Calls subroutine to make an A/D conversion
* Delay routine to prevent LCD flickering
* Converts hex format to in of Hg
CONVERT
BSR
DELAY
IN_HG
*
*
*
*
The value of FLAG passed from IN_HG is used to determine
If a range error has occurred. The following logical
statements are used to either allow further conversion or jump
to a routine to display a range error message.
LDAB
CMPB
BEQ
BSR
BRA
FLAG
#$80
INRANGE
ERROR
OUTPUT
* Determines if an range Error has ocurred
* If No Error detected (FLAG=$80) then
* system will continue conversion process
* If error occurs (FLAG<>80), branch to ERROR
* Branches to output ERROR code to display
*
No Error Detected, Conversion Process Continues
INRANGE
JSR
BCDCONV
JSR
* Converts Hex Result to BCD
* Uses Look–Up Table for BCD–Decimal
LOOKUP
OUTPUT
JSR
SPI2LCD
BRA
* Output transmission to LCD
* Continually converts using Branch Always
CONVERT
*
*
*
Subroutine SPI_CNFG
Purpose is to initialize SPI for transmission
and clear the display before conversion.
SPI_CNFG BSET
PORTD,X #$20
LDAA
STAA
* Set SPI SS Line High to prevent glitch
* Initializing Data Direction for Port D
* Selecting SS, MOSI, SCK as outputs only
#$38
DDRD,X
LDAA
STAA
#$5D
SPCR,X
* Initialize SPI–Control Register
* selecting SPE,MSTR,CPOL,CPHA,CPRO
LDAA
STAA
LDAA
#$5
COUNTER
SPSR,X
* sets counter to X–mit 5 blank bytes
* Must read SPSR to clear SPIF Flag
CLRA
* Transmission of Blank Bytes to LCD
ERASELCD JSR
TRANSFER
DEC
BNE
* Calls subroutine to transmit
COUNTER
ERASELCD
RTS
*
*
*
SET_UP
Subroutine SET_UP
Purpose is to initialize constants and to power–up A/D
and to initialize POFFSET used in conversion purposes.
#$90
* selects ADPU bit in OPTION register
STAA
ADOPT,X
* Power–Up of A/D complete
LDD
#$0131+$001A
* Initialize POFFSET
STD
POFFSET
* POFFSET = 305 – 25 in hex
LDAA
#$00
RTS
LDAA
* or Pmax + offset voltage (5 V)
*
*
*
Subroutine DELAY
Purpose is to delay the conversion process
to minimize LCD flickering.
DELAY
OUTLOOP
INLOOP
LDA
#$FF
#$FF
* Loop for delay of display
* Delay = clk/255*255
LDB
DECB
BNE
DECA
BNE
RTS
INLOOP
OUTLOOP
*
*
*
Subroutine ADCONV
Purpose is to read the A/D input, store the conversion into
SENSOUT. For conversion purposes later.
ADCONV
LDX
#REGBASE
LDAA
STAA
* loads base register for indirect addressing
#$25
ADCTL,X
* initializes A/D cont. register SCAN=1,MULT=0
F
Freescale Semiconductor, Inc.
n
.