
3–296
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
*
*
*
*
*
Purpose is to implement a Look–Up conversion
The BCD is used to index off of TABLE
where the appropriate hex code to display
that decimal digit is contained.
DIGIT4,3,2 are converted only.
LOOKUP
TABLOOP
LDX
DEX
#DIGIT1+4
* Counter starts at 5
* Start with Digit4
* Loads table base into Y–pointer
* Loads current digit into B
* Adds to base to index off TABLE
* Stores HEX segment result in A
LDY
LDAB
ABY
LDAA
STAA
CPX
BNE
#TABLE
0,X
0,Y
0,X
#DIGIT2
TABLOOP
* Loop condition complete, DIGIT2 Converted
RTS
*
*
*
*
*
*
Subroutine SPI2LCD
Purpose is to output digits to LCD via SPI
The format for this is to send a start byte,
four digits, and a stop byte. This system
will have 3 significant digits: blank digit
and three decimal digits.
*
Sending LCD Start Byte
SPI2LCD
LDX
#REGBASE
LDAA
LDAA
BSR
SPSR,X
#$02
TRANSFER
* Reads to clear SPIF flag
* Byte, no colon, start bit
* Transmit byte
*
Initializing decimal point & blank digit
* Sets MSB for decimal pt.
* after digit 3
LDAA
ORA
STAA
DIGIT3
#$80
DIGIT3
LDAA
STAA
#$00
DIGIT1
* Set 1st digit as blank
*
Sending four decimal digits
LDY
LDAA
BSR
INY
CPY
BNE
#DIGIT1
0,Y
TRANSFER
* Pointer set to send 4 bytes
* Loads digit to be x–mitted
* Transmit byte
* Branch until both bytes sent
DLOOP
#DIGIT4+1
DLOOP
*
Sending LCD Stop Byte
LDAA
BSR
#$00
TRANSFER
* end byte requires all 0’s
* Transmit byte
RTS
*
*
*
Subroutine TRANSFER
Purpose is to send data bits to SPI
and wait for conversion complete flag bit to be set.
TRANSFER LDX
#REGBASE
BCLR
STAA
BRCLR
BSET
LDAB
PORTD,X #$20
SPDR,X
SPSR,X #$80 XMIT* Wait for flag
PORTD,X #$20
SPSR,X
* Assert SS Line to start X–misssion
* Load Data into Data Reg.,X–mit
XMIT
* DISASSERT SS Line
* Read to Clear SPI Flag
RTS
*
*
Location for FCB memory for look–up table
There are 11 possible digits: blank, 0–9
TABLE
FCB
END
$7E,$30,$6D,$79,$33,$5B,$5F,$70,$7F,$73,$00
F
Freescale Semiconductor, Inc.
n
.