AN2839 Freescale Semiconductor / Motorola, AN2839 Datasheet - Page 19

no-image

AN2839

Manufacturer Part Number
AN2839
Description
Implementing a Lamp Dimmer with an HC908Q Family MCU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
;*******************************************************************************************
;* SUBROUTINES
;* This part includes subroutines
;*******************************************************************************************
InitTimer:
;Subroutine for Thyristor gate control
Gate:
loop:
;Subroutine for Timer Overflow
TOverflow:
Skip:
;*******************************************************************************************
;* Main Init
;* This is the point where code starts executing after a RESET.
;*******************************************************************************************
main:
Freescale Semiconductor
org
mov
mov
mov
bra
lda
bset
nop
bclr
dbnza loop
jmp
nop
nop
brclr TOF,TSC,TOverflow ;Wait for Timer Overflow
lda
and
sta
mov
bra
rts
mov
mov
mov
bset
clr
clr
clrh
clrx
FlashStart
#initTim,TSC ;Timer - Cleared + Stopped.
#InitTMODH,TMODH ;Set max. brightness
#InitTMODL,TMODL ;after we start the timer.
Skip
#GateVal
PTA1,PTA
PTA1,PTA
Skip
TSC
#TSCClr
TSC
#initTim,TSC ;STOP and RESET Counter
Skip
#initCfg1,CONFIG1 ;Set config1 register
#initCfg2,CONFIG2 ;set MCU to internal oscillator, IRQ enabled
#InitDDRA,DDRA ;PTA0 -> Zero Crossing detection
DDRA1,DDRA
Counter1
Counter2
Implementing a Lamp Dimmer with an HC908Q Family MCU, Rev. 0
;Gate pulse duration
;Clear TOF bit
;(LVI and COP disabled)
;PTA1 -> Pulses on Thyristor gate
;PTA3 as RSTb -> Turns on 1-minute timer
Software Description
19

Related parts for AN2839