AN1921 Motorola / Freescale Semiconductor, AN1921 Datasheet - Page 12

no-image

AN1921

Manufacturer Part Number
AN1921
Description
AN1921 General DSP568xx Interface Examples using the Embedded SDK
Manufacturer
Motorola / Freescale Semiconductor
Datasheet
Interfacing to Serial Devices Using the SPI Port
12
Using the IDE’s debug capability, the last 64 readings are stored in the array DataStore[] for user
review. The current sample is also accumulated in the variable sum to perform a batch averaging when
64 recent samples have been read.
Outside the 64 sample loop, the mean is determined and placed in the variable Vcount. Next, the
current atmospheric or barometric pressure (BaroPress) is computed.
The coded equation is an adaptation of an equation taken from the MPX4115A Integrated Pressure
Sensor Tech Note. The equation relates the voltage out (Vout) with the pressure (P) in kiloPascals and
(Voltage supplied) Vs.
Rewriting the equation for P yields,
In this set-up for the TLC2543, Vcc = REF+ = Vs. This implies that maximum voltage is V ~ ADC
number of bits = 2^12 = 4096. The ADC delivers a count (Vcount) between 0 and 4096. This allows
the above expression to be written as:
Since the sensor measures absolute pressure, the units can be converted to the more recognizable units
of millibars. The conversion factor is 1 millibar = 100 kPa. When applied to the last equation, it yields:
which is the source of the expression implemented in the code. The coded expression employs 4 shifts
and 4 adds to yield the pressure in millibars.
There are several ways to visualize what is happening. The first is to halt (not kill) the process from the
Metrowerks’ IDE debug window. Once the process is halted, the contents of the DataStore[] array can
be viewed by selecting the View menu and selecting the Global Variables Window.
After the Global Variables Window appears, select Inttlc2543 from the list on the left. In the right half
of the window, select the plus sign to the left of the listed variable name, DataStore, and the current
contents of the array will appear. The range of values to be found there will fall between 3000 and
4000, depending on the user’s altitude above sea level and weather conditions. If the DataStore[] does
not contain a number in this range, check the connection between the EVM’s SPI0 header and the
ADC with the schematic in
pressure (BaroPressure) is also found in the right side of the Global Variables Window. The expected
range should be between 800 and 1100.
Another means of checking the proper operation of this test requires access to an oscilloscope and
leaving the test procedure executing on the EVM board. Placing a probe on the I/O clock line and
triggering on the rising edge of the I/O CLOCK line pulse, should yield a signal similar to that shown
on the lower line in
the first probe on the I/O clock line (triggering on the clock pulses) and placing a second probe on the
SPI0 MOSI line, will yield the signals seen in
line and ADcmd =0x8C00.
Vout = Vs * (0.009*P - 0.095)
P = (Vout/Vs + 0.095)/0.009
P = 0.0271*Vcount + 10.555 (kPa)
P = 0.271*Vcount + 105.55
where P is pressure in kPa
Figure
Interface Examples Using the Embedded SDK
Figure 6
7, which represents the SPI-generated clock pulses sent to ADC. Leaving
and connection references in
Figure
8, where the command byte is seen on the upper
Table
3. The computed atmospheric

Related parts for AN1921