Hardware Reference
In-Depth Information
5 V
9 k
10 k
HCS12
R f
TC1047A
+12 V
10 k
V OUT
-
+12 V
3 k
-
74 1
V M
74 1
AN7
+
R 1
+
150 k
R 2
-12 V
-12 V
-5 V
Figure 12.18 Circuit connection between the TC1047A and the HCS12
translation and scaling for V OUT . The circuit connection is shown in Figure 12.18. This circuit
uses V DD and V SS as the reference voltages required in the process of A/D conversion. The range
of the voltage connected to the AN7 pin is between 0 and 5 V for the given temperature range.
To convert the A/D conversion result to the corresponding temperature, we need to do the
following:
1. Divide the conversion result by 6.2
2. Subtract 40 from the quotient
Since the HCS12 MCU cannot handle fl oating-point numbers directly, the operation of dividing
by 6.2 would be implemented by multiplying the conversion result by 10 and then dividing the
product by 62.
The procedure for starting an A/D conversion, reading the conversion result, calculating
the corresponding temperature, and converting the temperature value into an ASCII string
every 200 ms is as follows:
Step 1
Configure the A/D converter properly.
Step 2
Start an A/D conversion.
Step 3
Wait until the A/D conversion is complete.
Step 4
Multiply the conversion result by 10.
Step 5
Divide the product resulting from step 4 by 62 to obtain the temperature reading. Use the
variables quo and rem to hold the quotient and remainder.
Step 6
Subtract 40 from quo to obtain the actual temperature.
Step 7
If quo $ 0, go to step 9; otherwise, replace quo with its two's complement.
Step 8
If rem Z 0, then
1. Decrement quo by 1
2. rem
62 2 rem
Search WWH ::




Custom Search