AN2475 Freescale Semiconductor / Motorola, AN2475 Datasheet - Page 10

no-image

AN2475

Manufacturer Part Number
AN2475
Description
Generating a PWM Signal Modulated by an Analog Input Using the MC68HC908QY4 Microcontroller
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2475/D
;*******************************************************************************************
;* Code Starts Here
;*******************************************************************************************
Init:
IntOsc:
;* Configure oscillator trim value
;* Enable ADCH3 continuous convertion
;* Optionally, select ADC ch 1 and 2 by using the instruction below
;*
;*
;* Program Timer Interface Module (TIM)
;* Initializing PWM
DecPeriod:
10
org
mov
lda
sta
lda
sta
mov
mov
mov
bclr
bclr
bset
bset
mov
mov
mov
mov
mov
mov
mov
mov
lda
cmp
bmi
lda
deca
clrh
sta
ldx
div
tax
stx
stx
FlashStart
#initCfg1,CONFIG1
#initCfg2
CONFIG2
TRIMLOC
OSCTRIM
#initAD,ADSCR
#$21,adscr
#$22,adscr
PTB0,PTB
PTB1,PTB
DDRB0,DDRB
DDRB1,DDRB
#initTim,TSC
#periodH,TMODH
#periodL,TMODL
#InitpwmH,TCH0H
#InitpwmL,TCH0L
#tsc0Val,TSC0
#TimVal,TSC
#ADclkval,ADICLK
#Permin
TMODL
Error
TMODL
TMODL
#$02
PWMLow
TCH0L
Generating a PWM Signal Modulated by an Analog Input
Freescale Semiconductor, Inc.
For More Information On This Product,
Using the MC68HC908QY4 Microcontroller
Go to: www.freescale.com
;Set config1 register
;(LVI and COP disabled)
;set MCU to internal oscillator
;Load the factory oscillator trim value
;into the OSCTRIM register
;Start Convertion, CH3 selected
;Start Convertion, CH1 selected
;Start Convertion, CH2 selected
;Initial value for PTB0
;Initial value for PTB1
;PTB0 outputs regulation ok!
;PTB1 outputs regulation error!
;Reset & Stop Counter
;Set PWM period
;T = periodL*16 int. bus*(1/bus_clk)
;initial value for output compare (50%)
;enable buffered PWM in channel 0
;Disable interruption
;clk = internal bus / 16
;ADC clock, bus clock/ 16
;Verify if Period is lower than Minimum Period
;Go to Error status if so
;Decrement period
;Set PWM Duty Cycle to ~50%
MOTOROLA

Related parts for AN2475