User's Manual

Temperature Sensor Measurement
Variable Speed DC Fan Control using the MC9RS08KA2, Rev. 0
Freescale Semiconductor 29
;5) Read Temp Sensor Again
bsr ReadSensor ; Read Sensor value
;6) Dead time control
StartTimer
;7) During the dead time, update dead time period every 128ms
brclr SRTISC_RTIF, MAP_ADDR_6(SRTISC), UpdateLater; Update PWM duty cycle
jsr TableLookup
UpdateLater:
lda ActualPeriod
sub TargetPeriod ; Actual-Target
blo IncPeriod
beq WaitAgain ; if same, Fan speed reach target then exit
DecPeriod: ; if bigger, decrement DeadTime
lda DeadTime
cmp #MinDeadTime
blo WaitAgain
dec DeadTime
bra WaitAgain
IncPeriod: ; if smaller, increment DeadTime
lda DeadTime
cmp #MaxDeadTime
bhs WaitAgain
inc DeadTime
bra WaitAgain
WaitAgain:
;8) Bump COP
sta MAP_ADDR_6(SRS) ; Bump COP
wait
mov #(mMTIMSC_TSTP|mMTIMSC_TRST), MTIMSC; mask interrupt and clear flag
;9) Repeat the control cycle
bra FanControlLoop
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Delay 16ms
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Delay:
mov #255, MTIMMOD ; OF period
mov #(mMTIMSC_TRST|mMTIMSC_TOIE), MTIMSC; Reset and Start Timer
wait
mov #(mMTIMSC_TSTP|mMTIMSC_TRST), MTIMSC; mask interrupt and clear flag
sta MAP_ADDR_6(SRS) ; Bump COP
rts
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Drive coil
;