3–293
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
APPENDIX
MC68HC11 Barometer Software Available on:
Motorola Electronic Bulletin Board
MCU Freeware Line
8–bit, no parity, 1 stop bit
1200/300 baud
(512) 891–FREE (3733)
* BAROMETER APPLICATIONS PROJECT – Chris Winkler
* Developed: October 1st, 1992 – Motorola Discrete Applications
* This code will be used to implement an MC68HC11 Micro–Controller
* as a processing unit for a simple barometer system.
* The HC11 will interface with an MPX2100AP to monitor,store
* and display measured Barometric pressure via the 8–bit A/D channel
* The sensor output (32mv max) will be amplified to .5 – 2.5 V dc
* The processor will interface with a 4–digit LCD (FE202) via
* a Motorola LCD driver (MC145453) to display the pressure
* within +/– one tenth of an inch of mercury.
* The systems range is 15.0 – 30.5 in–Hg
*
*
*
*
A/D & CPU Register Assignment
This code will use index addressing to access the
important control registers. All addressing will be
indexed off of REGBASE, the base address for these registers.
REGBASE
ADCTL
ADR2
ADOPT
PORTB
PORTD
DDRD
SPCR
SPSR
SPDR
EQU
$1000
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
* register base of control register
* offset of A/D control register
* offset of A/D results register
* offset for A/D option register location
* Location of PORTB used for conversion
* PORTD Data Register Index
* offset of Data Direction Reg.
* offset of SPI Control Reg.
* offset of SPI Status Reg.
* offset of SPI Data Reg.
$30
$32
$39
$04
$08
$09
$28
$29
$2A
*
*
*
*
User Variables
The following locations are used to store important measurements
and calculations used in determining the altitude. They
are located in the lower 256 bytes of user RAM
DIGIT1
DIGIT2
DIGIT3
DIGIT4
COUNTER
POFFSET
SENSOUT
RESULT
FLAG
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
$0001
$0002
$0003
$0004
$0005
$0010
$0012
$0014
EQU
* BCD blank digit (not used)
* BCD tens digit for pressure
* BCD tenths digit for pressure
* BCD ones digit for pressure
* Variable to send 5 dummy bytes
* Storage Location for max pressure offset
* Storage location for previous conversion
* Storage of Pressure(in Hg) in hex format
* Determines if measurement is within range
$0016
*
*
*
*
*
*
*
*
*
*
*
*
*
MAIN PROGRAM
The conversion process involves the following steps:
1.
2.
3.
4.
5.
Set–Up SPI device–
Set–Up A/D, Constants
Read A/D, store sample
Convert into in–Hg
Determine FLAG condition
Display error
Continue Conversion
Convert hex to BCD format BCDCONV
Convert LCD display digits
Output via SPI to LCD
SPI_CNFG
SET_UP
ADCONV
IN_HG
IN_HG
a.
b.
ERROR
INRANGE
6.
7.
8.
LOOKUP
SPI2LCD
*
*
*
This process is continually repeated as the loop CONVERT
runs unconditionally through BRA (the BRANCH ALWAYS statement)
Repeats to step 3 indefinitely.
F
Freescale Semiconductor, Inc.
n
.