Freescale Semiconductor DRM079 Welding System User Manual


 
Implementation
Variable Speed DC Fan Control using the MC9RS08KA2, Rev. 0
28 Freescale Semiconductor
sta KBIES ;HALL rising Edge Trigger
sta KBIPE ;KBI Enable
;-------------------------------------------------------
;Config MTIM
;
;Timer prescalar=256 -> Timer clk = 16kHz
;Bus = 4MHz
;Max OF period = 16.384ms
;Timer resolution = 64us
;-------------------------------------------------------
mov #(MTIM_BUS_CLK|MTIM_DIV_256), MTIMCLK
mov #255, MTIMMOD
;-------------------------------------------------------
;Motor Start Sequence
;-------------------------------------------------------
ResetPosition:
mov #mPWM1, PTAD ; Lock FAN in reset position
lda #30 ;
Dly1 bsr Delay ; for Delay 0.5s
dbnza Dly1 ;
clr PTAD ; de-energize coils
bsr Delay
; Drive L2
ldx #mPWM2 ; Select L2 Coils
bsr SetPWM ; Drive coil
bsr Delay ; De-energize coils
inc MotorRunning ; otherwise Update Software flag
;-------------------------------------------------------
;Fan Control Loop
;-------------------------------------------------------
FanControlLoop:
;1) Drive L1 coil
clr KBIES ; HALL falling edge trigger
ldx #mPWM1 ; Select L1 Coil
bsr SetPWM ; Drive coil
;2) Read Temp Sensor
jsr ReadSensor ; Read Sensor value
;3) Dead time control
StartTimer ; Wait dead time period
wait
mov #(mMTIMSC_TSTP|mMTIMSC_TRST), MTIMSC; mask interrupt and clear flag
;4) Drive L2 coil
bset HALL, KBIES ; HALL rising edge trigger
ldx #mPWM2 ; Select L2 Coil
bsr SetPWM ; Drive coil