Freescale Semiconductor DRM079 manual KBISCKBACK, Kbisc, MTIMSCTOF, Mtimsc

Page 30
Variable Speed DC Fan Control using the MC9RS08KA2, Rev. 0

Implementation

;X indicate the coil to be driven ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetPWM:

mov

#255, MTIMMOD

 

; OF period

mov

#(mMTIMSC_TRSTmMTIMSC_TOIE), MTIMSC; Reset and Start Timer

lda

#20

 

; Enable Interrupt & Edge only

mov

#(mKBISC_KBIE), KBISC

bset

KBISC_KBACK, KBISC

; Clear Flag

stx

PTAD

 

; Drive coil

TimingLoop:

MTIMSC_TOF, MTIMSC

; Clear TOF

bclr

wait

KBISC_KBF, KBISC, HallFound

; HALL sensor edge found

brset

dbnza

TimingLoop

; If no HALL output, Stop the driving

jmp

MotorHang

HallFound:

MTIMCNT, DriveTime

 

mov

 

cbeqa

#20, StableDrive

 

mov

#MaxDeadTime, DriveTime

 

StableDrive:

DeadTime

 

 

lda

 

 

add

DriveTime

 

 

sta

ActualPeriod

 

; Disconnect coil

clr

PTAD

 

mov

#(mKBISC_KBACK), KBISC

; Clear Flag and mask interrupt

mov

#(mMTIMSC_TSTPmMTIMSC_TRST), MTIMSC; mask interrupt and clear flag

rts

 

 

 

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

;Read Temperature Sensor Value

;Timer prescalar=8 -> Timer clk~250kHz

;Bus = 2MHz

;Max OF period = 1.02ms

;Timer resolution = 4us ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ReadSensor:

mov

#(MTIM_BUS_CLKMTIM_DIV_8), MTIMCLK; Change Timer resolution

mov

#63, MTIMMOD

; OF period

mov

#(mMTIMSC_TRSTmMTIMSC_TOIE), MTIMSC; Reset and Start Timer

mov

#(mACMPSC_ACMEmACMPSC_ACIEACMP_OUTPUT_RAISING), ACMPSC

bset

; Enable ACMP, start RC rise

ACMPSC_ACF, ACMPSC

; Clear ACMP Flag

wait

; delay to OF and make the read process deterministic

brclr

ACMPSC_ACF, ACMPSC, NoReading

 

mov

MTIMCNT, SensorReading

; Clear ACMP Flag

bset

ACMPSC_ACF, ACMPSC

clr

ACMPSC

; disable ACMP

wait

#(mMTIMSC_TSTPmMTIMSC_TRST), MTIMSC; mask interrupt and clear flag

mov

mov

#(MTIM_BUS_CLKMTIM_DIV_256), MTIMCLK; Reset Timer resolution

rts

 

 

30

Freescale Semiconductor

Image 30
Contents Variable Speed DC Fan Control using the MC9RS08KA2 Page Variable Speed DC Fan Control using the MC9RS08KA2 Revision HistoryFreescale Semiconductor Table of Contents Freescale Semiconductor Chapter Introduction IntroductionFreescale’s New Generation Ultra Low Cost MCU DC Fan Reference Design TargetsBi-Phase Bldc Motor Bi-Phase Bldc Motor DiagramFreescale Semiconductor Chapter Motor Control CommutationRotor Position Control Commutation Waveforms Speed ControlFault Detection Motor StartupFreescale Semiconductor Block Diagram Chapter ImplementationHardware Resources Control Loop Firmware Control Loop Temperature Sensor Measurement = V DD⎜ RC⎟#63, Mtimmod ACMPSCACF, AcmpscAcmpsc Temperature Conversion Temperature Conversion Table Freescale Semiconductor VR1 Freescale Semiconductor Appendix B Program Listing Mtimtclkrising RtidisableMtimtclkfalling AcmpoutputbothMAPADDR6NVICSTRM, Icstrm $3FFA #HIGH613NVICSTRM, PageselMAPADDR6NVFTRIM, Icssc #ICSDIV2, ICSC2#MTIMBUSCLKMTIMDIV256, Mtimclk KbiesKbipe #255, MtimmodMAPADDR6SRS Rts Drive coilKBISCKBACK, Kbisc MTIMSCTOF, Mtimsc#6, Mtimmod KbiscBUZZER, Ptad #24, Mtimmod#30, Mtimmod Page How to Reach Us