CH 8 AVR Peripherals - WaveGenPWM ICP
CH 8 AVR Peripherals - WaveGenPWM ICP
TIMER APPLICATIONS
INPUT CAPTURE WAVE GENERATION AND PWM
DR T WALINGO
New modes
Init: sbi DDRB, 3 ;pins set as output Toggle pin after 512/2 = 256 steps
TCNT0
OCR1x
Time
OC1x
X
1
Time
; ****************************************
.org 0x00
rjmp Init
;*****************************************
;CONFIGURATION SECTION
.org 0x100
Init:
sbi DDRD, 5
;*****************************************
Start : rjmp Start Students to attempt
Remember accessing
;***************************************** the question in class
16 bit registers
7.797KHz
ICP1
; *************************************************************************************************
; *************************************************************************************************
OC1A
• Frequency of
Determine thegenerated
frequencywave is 1/256
of the the
generated
frequency
waveofinthe timerto
relation clock.
timer clock
Non inverted
• Non inverted mode duty cycle Inverted PWM PWM
DDetermine
= ((OCRO+1)/256) x 100
the duty cycle TCNT0
OXFF
D = Determine
((255-OCRO)/256) x 100
the duty cycle
0
Time
OC0
OCR0+1 OCR0+1 OCR0+1 OCR0+1
• Note: In non PWM modes, a desired value 1
is loaded to the OCR0 instantly. In PWM
the value is loaded when the timer 0 Time
reaches the TOP or BOTTOM
0 1 1 0 1 0 0 1
• Frequency
Determineofthe
generated
frequencywave is 1/510
of the the
generated
frequency
waveof in
the timer clock.
relation to timer clock
Non inverted
255 255 PWM
TCNT0
• Non inverted mode duty cycle. OXFF
D =Determine
((2x OCR0)/510) x 100
the duty cycle OCR0
0 510 clocks
510 clocks Time
0 1 1 0 0 0 0 1
Duty cycle cannot be 0-non inverted mode or Can be from 0 to 100% for all the modes
100% in inverted mode