User's Manual

Temperature Sensor Measurement
Variable Speed DC Fan Control using the MC9RS08KA2, Rev. 0
Freescale Semiconductor 19
Table 3-2 shows the entire dynamic range of the temperature sensor voltage can be covered by about 44
timer counts. For convenience, the timer overflow period is set to 63, which is identical to the size of the
paging window ($00C0 to $00FF) in the MC9RS08KA2. The timer value captured can be used directly as
an index to the paging window for the target PWM period value lookup.
The code below shows how the timer value is captured using RS08 instructions.
ReadSensor:
mov #(MTIM_BUS_CLK|MTIM_DIV_8), MTIMCLK; Change Timer resolution
mov #63, MTIMMOD ; OF period
mov #(mMTIMSC_TRST|mMTIMSC_TOIE), MTIMSC; Reset and Start Timer
mov #(mACMPSC_ACME|mACMPSC_ACIE|ACMP_OUTPUT_RAISING), ACMPSC
; Enable ACMP, start RC rise
bset ACMPSC_ACF, ACMPSC ; Clear ACMP Flag
wait
brclr ACMPSC_ACF, ACMPSC, NoReading
mov MTIMCNT, SensorReading ; Capture timer count
bset ACMPSC_ACF, ACMPSC ; Clear ACMP Flag
clr ACMPSC ; disable ACMP
wait ; delay to OF and make the
; read process deterministic
mov #(mMTIMSC_TSTP|mMTIMSC_TRST), MTIMSC; mask interrupt and clear
; flag
mov #(MTIM_BUS_CLK|MTIM_DIV_256), MTIMCLK; Reset Timer resolution
rts
NoReading:
mov #$00, SensorReading ; Smallest Number
clr ACMPSC ; disable ACMP
mov #(mMTIMSC_TSTP|mMTIMSC_TRST), MTIMSC ; mask interrupt and clear
; flag
mov #(MTIM_BUS_CLK|MTIM_DIV_256), MTIMCLK; Reset Timer resolution
rts
Table 3-2. RC Charging Profile Against Timer Count
Time (ยตs)
Voltage across the
Temperature Sensor (V)
ADC Readout
(Timer Count)
00 0
20.10 1
40.19 2
60.28 3
and so on...
86 2.82 43
88 2.87 44
90 2.91 45
and so on...
126 3.52 63