User's Manual Part 1

A/D conversion of XYZ levels
Wireless Sensing Triple Axis Reference design, Rev. 0.9
Freescale Semiconductor 17
Figure 3-3ZSTAR Sensor board software overview
For the Sensor board operation, several of the MC9S08QG8’s hardware modules are used: Analog to
Digital Converter (ADC), Synchronous Peripheral Interface (SPI), External Interrupt Request module
(IRQ) and General Purpose Input/Output (GPIO).
3.2 A/D conversion of XYZ levels
The 3-axis accelerometer sensor MMA7260Q provides three separate analog levels for the X, Y and Z
axis. These outputs are ratiometric which means that the output offset voltage and sensitivity will scale
linearly with applied supply voltage. This is a key feature when interfacing to a microcontroller with A/D
converter reference levels tied to a power supply, because it provides system level cancellation of supply
induced errors in the analog to digital conversion process.
During the analog-to-digital conversion in the microcontroller, 8-bit resolution is used. MC9S08QG8 A/D
channels 0, 1 and 2 are connected to X (channel 1), Y (channel 2) and Z (channel 0) outputs of the
MMA7260Q. The microcontroller’s APCTL1 register enables these ADC channels for pin I/O control by
the ADC module.
The ADCCFG register controls the selected mode of operation, clock source, clock divide, and
configuration for low power or long sample time.
3.2.1 ADC module init:
APCTL1 = 0b00000111; /* 0,1,2 channels are ADC */
ADCCFG = 0b01100000; /* set prescale to 8, ADICLK=BUS, 8-bit, high speed */
Actual ADC measurements are done in the main software loop. There is a macro (called POWSUM) that
allows configuration of measurement to take several measurements of each channel during one loop. E.g.
changing POWSUM to 3, 2^3 = 8, each channel will be measured 8 times, with POWSUM 7, each channel
Sensor data
Analog-to-Digital converter
(ADC) module
MC9S08QG8
SMAC
ZSTAR RF protocol handler
sleep
software
calibration data
g-select
Serial Peripheral Interface
(SPI) module
IRQ
MC39
MMA7260Q
GPIO