8-bit Timer/Counter2 with PWM and Asynchronous Operation

Slides:



Advertisements
Similar presentations
More fun with Timer/Counters
Advertisements

Kuliah Mikrokontroler AVR Comparator AVR Eru©September 2009 PENS.
COMP3221: Microprocessors and Embedded Systems Lecture 16: Interrupts II Lecturer: Hui Wu Session 2, 2005.
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
ATtiny2313 Timers/Counters CS-423 Dick Steflik. What Do You Use Timers For? Timing of events (internal or external)‏ Scheduling Events Measuring the width.
5-1 Timer/Counters In many microprocessor systems we need to:  count logic pulses  measure the frequency of signals  measure the period of pulses 
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Pulse Width Modulation modes
16-Bit Timer/Counter 1 and 3 Counter/Timer 1,3 (TCNT1, TCNT3) are identical in function. Three separate comparison registers exist. Thus, three separate.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
ECE 371- Unit 11 Timers and Counters (“Stop Watches and Alarm Clocks”)
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
Slides created by: Professor Ian G. Harris Interrupts  Embedded systems often perform some tasks which are infrequent and possibly unpredictable Hang.
Timer/counter Chapter 12
ARM Timers.
System Clocks.
A Few Words From Dilbert
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
MSP430 Mixed Signal Microcontroller – Parte 2 Afonso Ferreira Miguel Source: slau056d – Texas instruments.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
ELE22MIC Lecture 18 The AVR Sleep Modes The ATMEGA128’s Timer System
Counter/Timer/PWM. incoming Lab. Counter counter is a device which stores the number of times a particular event or process has occurred synchronous/asynchronous.
AVR Programming: Timers October 8, What is a timer? A register that keeps track of a current value This value is updated at a certain frequency.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
CS-280 Dr. Mark L. Hornick 1 Atmel Timer/Counter System Most microcontrollers include some type of timer system Facilitates real-time monitoring and control.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
Timers and Interrupts Mark Neil - Microprocessor Course.
Timers and Scheduled Interrupts
The AVR microcontroller and embedded systems using assembly and c AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi.
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
C Examples 6. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
TIMERS.
16-Bit Timer/Counter 1 and 3
Timer modules in PIC 16F877.  The PIC 16F877 basically has three independent timer modules,  denoted by the symbols, TIMER-0, TIMER1,andTIMER2. . These.
Timers and Scheduled Interrupts
EET 2261 Unit 13 Enhanced Capture Timer
16F877A.
Why are Timer Functions Important?
V.V.P. ENGINEERING COLLEGE,RAJKOT
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Timer and Interrupts.
BITS EDU. CAMPUS , VARNAMA
Programmable Interval Timer
Programmable Interval Timer 8254 LECTURE 3
AVR Addressing Modes Subject: Microcontoller & Interfacing
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
COMP2121: Microprocessors and Interfacing
Timer/Counter Modified from Dr. Lam Phung’s Slides.
16-bit Timer/Counter1 Features
8-bit Timer/Counter0 with PWM
ATmega103 Timer0 and Interrupts
8051 Timers Prof. Rajiv R Bhandari.
Pugazhendhi.M 11/12/2018 TIMERS 11/12/2018 CCET CCET.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
DC motor and PWM.
전자의료시스템 및 실습 System Configuration/Interrupt
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
Wave Generation and Input Capturing
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

8-bit Timer/Counter2 with PWM and Asynchronous Operation Features Single Compare unit Counter Clear Timer on Compare Match (Auto Reload) Glitch-free, Phase Correct Pulse Width Modulator (PWM) Frequency Generator 10-bit Clock Prescaler Overflow and Compare Match Interrupt Sources (TOV2 and OCF2) Allows clocking from External 32 kHz Watch Crystal Independent of the I/O Clock

Registers TCCR2 – Timer/Counter Control Register TCNT2 – Timer/Counter Register OCR2 – Output Compare Register ASSR – Asynchronous Status Register TIMSK – Timer/Counter Interrupt Mask Register TIFR – Timer/Counter Interrupt Flag Register SFIOR – Special Function IO Register

TCCR2 – Timer/Counter Control Register Bit 7 – FOC2: Force Output Compare Bit 3, 6 – WGM2[1:0]: Waveform Generation Mode Bit 5:4 – COM21:0: Compare Match Output Mode Bit 2:0 – CS22:0: Clock Select

ASSR – Asynchronous Status Register Bit 3 – AS2: Asynchronous Timer/Counter2 Bit 2 – TCN2UB: Timer/Counter2 Update Busy Bit 1 – OCR2UB: Output Compare Register2 Update Busy Bit 0 – TCR2UB: Timer/Counter Control Register2 Update Busy

Bit 3 – AS2: Asynchronous Timer/Counter2 When AS2 is written to zero, Timer/Counter 2 is clocked from the I/O clock, clkI/O. When AS2 is written to one, Timer/Counter2 is clocked from a Crystal Oscillator connected to the Timer Oscillator 1 (TOSC1) pin. When the value of AS2 is changed, the contents of TCNT2, OCR2, and TCCR2 might be corrupted.

• Bit 2 – TCN2UB: Timer/Counter2 Update Busy When Timer/Counter2 operates asynchronously and TCNT2 is written, this bit becomes set. When TCNT2 has been updated from the temporary storage register, this bit is cleared by hardware. A logical zero in this bit indicates that TCNT2 is ready to be updated with a new value.

• Bit 1 – OCR2UB: Output Compare Register2 Update Busy When Timer/Counter2 operates asynchronously and OCR2 is written, this bit becomes set. When OCR2 has been updated from the temporary storage register, this bit is cleared by hardware. A logical zero in this bit indicates that OCR2 is ready to be updated with a new value.

• Bit 0 – TCR2UB: Timer/Counter Control Register2 Update Busy When Timer/Counter2 operates asynchronously and TCCR2 is written, this bit becomes set. When TCCR2 has been updated from the temporary storage register, this bit is cleared by hardware. A logical zero in this bit indicates that TCCR2 is ready to be updated with a new value. If a write is performed to any of the three Timer/Counter2 Registers while its update busy flag is set, the updated value might get corrupted and cause an unintentional interrupt to occur. The mechanisms for reading TCNT2, OCR2, and TCCR2 are different. When reading TCNT2, the actual timer value is read. When reading OCR2 or TCCR2, the value in the temporary storage register is read.

TIMSK – Timer/Counter Interrupt Mask Register Bit 7 – OCIE2: Timer/Counter2 Output Compare Match Interrupt Enable Bit 6 – TOIE2: Timer/Counter2 Overflow Interrupt Enable

TIFR – Timer/Counter Interrupt Flag Register Bit 7 – OCF2: Output Compare Flag 2 Bit 6 – TOV2: Timer/Counter2 Overflow Flag

Bit 7 – OCF2: Output Compare Flag 2 The OCF2 bit is set (one) when a compare match occurs between the Timer/Counter2 and the data in OCR2 – Output Compare Register2. OCF2 is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, OCF2 is cleared by writing a logic one to the flag. When the I-bit in SREG, OCIE2 (Timer/Counter2 Compare match Interrupt Enable), and OCF2 are set (one), the Timer/Counter2 Compare match Interrupt is executed

Bit 6 – TOV2: Timer/Counter2 Overflow Flag The TOV2 bit is set (one) when an overflow occurs in Timer/Counter2. TOV2 is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, TOV2 is cleared by writing a logic one to the flag. When the SREG I-bit, TOIE2 (Timer/Counter2 Overflow Interrupt Enable), and TOV2 are set (one), the Timer/Counter2 Overflow interrupt is executed. In PWM mode, this bit is set when Timer/Counter2 changes counting direction at $00.

SFIOR – Special Function IO Register Bit 1 – PSR2: Prescaler Reset Timer/Counter2 When this bit is written to one, the Timer/Counter2 prescaler will be reset. The bit will be cleared by hardware after the operation is performed. Writing a zero to this bit will have no effect. This bit will always be read as zero if Timer/Counter2 is clocked by the internal CPU clock. If this bit is written when Timer/Counter2 is operating in asynchronous mode, the bit will remain one until the prescaler has been reset.