Download presentation
Presentation is loading. Please wait.
1
V.V.P. ENGINEERING COLLEGE,RAJKOT
AVR Timer/Counter Subject : Micro Controller & Interfacing Name of the Students: 1) JAGATIYA KEVAL( )
2
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
3
8-bit Timer/Counter0 with PWM
Features Single Compare Unit Counter Clear Timer on Compare Match (Auto Reload) Glitch-free, Phase Correct Pulse Width Modulator (PWM) Frequency Generator External Event Counter 10-bit Clock Prescaler (1, 8, 64, 256, 1024) Overflow and Compare Match Interrupt Sources (TOV0 and OCF0)
4
Timer0
5
Registers The Timer/Counter (TCNT0) and Output Compare Register (OCR0) are 8-bit registers. Interrupt request (abbreviated to Int.Req. in the figure) signals are all visible in the Timer Interrupt Flag Register (TIFR). All interrupts are individually masked with the Timer Interrupt Mask Register (TIMSK). TIFR and TIMSK are not shown in the figure since these registers are shared by other timer units.
6
The Timer/Counter can be clocked internally, via the prescaler, or by an external clock source on the T0 pin. The Clock Select logic block controls which clock source and edge the Timer/Counter uses to increment (or decrement) its value. The Timer/Counter is inactive when no clock source is selected. The output from the Clock Select logic is referred to as the timer clock (clkT0).
7
The double buffered Output Compare Register (OCR0) is compared with the Timer/Counter value at all times. The result of the compare can be used by the waveform generator to generate a PWM or variable frequency output on the Output Compare Pin (OC0). The compare match event will also set the Compare Flag (OCF0) which can be used to generate an output compare interrupt request.
8
Registers TCCR0 – Timer/Counter Control Register
TCNT0 – Timer/Counter Register OCR0 – Output Compare Register TIMSK – Timer/Counter Interrupt Mask Register TIFR – Timer/Counter Interrupt Flag Register
9
Bit 5:4 – COM01:0: Compare Match Output Mode
10
Bit 2:0 – CS02:0: Clock Select
11
TIMSK – Timer/Counter Interrupt Mask Register
12
TIFR – Timer/Counter Interrupt Flag Register
13
Thank you
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.