Temperature Sensor Measurement

NoReading:

#$00, SensorReading

; Smallest Number

mov

clr

ACMPSC

; disable ACMP

mov

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

mov

#(MTIM_BUS_CLKMTIM_DIV_256), MTIMCLK; Reset Timer resolution

rts

 

 

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

;6-bit Table Lookup ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TableLookup:

bset SRTISC_RTIACK, MAP_ADDR_6(SRTISC);5

mov

#HIGH_6_13(TableStart), PAGESEL;5 Calculate the PAGE

lda

SensorReading

;3

add

#$c0

;2 Reference to paging window

tax

,x

;2

lda

;3

sta

TargetPeriod

;2

mov

#HIGH_6_13(SOPT), PAGESEL

;5

rts

 

;3

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

;Error Handling

;Stop the motor

;Sound the buzzer (about 520Hz) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MotorHang:

clr

PTAD

; clear

PWMp and PWMn

lda

MotorRunning

; Check

software flag

bne

SoundBuzzer

; =1, Motor is running

jmp

ResetPosition

 

 

SoundBuzzer:

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

mov

clr

KBISC

; mask KBI

lda

#255

; Bump COP

sta

MAP_ADDR_6(SRS)

Beep:

BUZZER, PTAD

; a 20%

duty cycle loop

bset

; Drive

buzzer

mov

#6, MTIMMOD

 

Reset and Start Timer

mov

#(mMTIMSC_TRSTmMTIMSC_TOIE), MTIMSC;

wait

#(mMTIMSC_TSTPmMTIMSC_TRST), MTIMSC;

mask interrupt and clear flag

mov

sta

MAP_ADDR_6(SRS)

; Bump COP

bclr

BUZZER, PTAD

; Clear

buzzer

mov

#24, MTIMMOD

 

Reset and Start Timer

mov

#(mMTIMSC_TRSTmMTIMSC_TOIE), MTIMSC;

wait

#(mMTIMSC_TSTPmMTIMSC_TRST), MTIMSC;

mask interrupt and clear flag

mov

sta

MAP_ADDR_6(SRS)

 

; Bump COP

dbnza

Beep

 

 

 

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

 

 

 

Freescale Semiconductor

 

31

Page 31
Image 31
Freescale Semiconductor DRM079 manual Kbisc, BUZZER, Ptad, #6, Mtimmod, #24, Mtimmod