Temperature Sensor Measurement
Table 3-2. RC Charging Profile Against Timer Count
Time (∝s) | Voltage across the | ADC Readout | |
Temperature Sensor (V) | (Timer Count) | ||
| |||
|
|
| |
0 | 0 | 0 | |
|
|
| |
2 | 0.10 | 1 | |
|
|
| |
4 | 0.19 | 2 | |
|
|
| |
6 | 0.28 | 3 | |
|
|
| |
| and so on... |
| |
|
|
| |
86 | 2.82 | 43 | |
|
|
| |
88 | 2.87 | 44 | |
|
|
| |
90 | 2.91 | 45 | |
|
|
| |
| and so on... |
| |
|
|
| |
126 | 3.52 | 63 | |
|
|
|
Table
The code below shows how the timer value is captured using RS08 instructions.
ReadSensor: | #(MTIM_BUS_CLKMTIM_DIV_8), MTIMCLK; Change Timer resolution | |
mov | ||
mov | #63, MTIMMOD | ; OF period |
mov | #(mMTIMSC_TRSTmMTIMSC_TOIE), MTIMSC; Reset and Start Timer | |
mov | #(mACMPSC_ACMEmACMPSC_ACIEACMP_OUTPUT_RAISING), ACMPSC | |
bset | ACMPSC_ACF, ACMPSC | ; Enable ACMP, start RC rise |
; Clear ACMP Flag | ||
wait | ACMPSC_ACF, ACMPSC, NoReading |
|
brclr | ; Capture timer count | |
mov | MTIMCNT, SensorReading | |
bset | ACMPSC_ACF, ACMPSC | ; Clear ACMP Flag |
clr | ACMPSC | ; disable ACMP |
wait |
| ; delay to OF and make the |
mov |
| ; read process deterministic |
#(mMTIMSC_TSTPmMTIMSC_TRST), MTIMSC; mask interrupt and clear | ||
mov |
| ; flag |
#(MTIM_BUS_CLKMTIM_DIV_256), MTIMCLK; Reset Timer resolution | ||
rts |
|
|
NoReading: | #$00, SensorReading | ; Smallest Number |
mov | ||
clr | ACMPSC | ; disable ACMP |
mov | #(mMTIMSC_TSTPmMTIMSC_TRST), MTIMSC ; mask interrupt and clear | |
mov |
| ; flag |
#(MTIM_BUS_CLKMTIM_DIV_256), MTIMCLK; Reset Timer resolution | ||
rts |
|
|
| Variable Speed DC Fan Control using the MC9RS08KA2, Rev. 0 | |
|
| |
Freescale Semiconductor | 19 |