BITS EDU. CAMPUS , VARNAMA

Slides:



Advertisements
Similar presentations
More fun with Timer/Counters
Advertisements

Introduction of Holtek HT-46 series MCU
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.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Embedded Systems Overview
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
SENIOR DESIGN 10/3.
Embedded System Design Laboratory September 27, 2002Stanford University - EE281 Lecture #1 Lecture #1 Outline Welcome Back AVR Hardware –Pins and Ports.
AVR  Modern RISC architecture: Compact and FAST.  Tuned for high level languages.  Consistent architecture across entire line.  Small AVR are subsets.
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.
AVR Microcontrollers.
ARM Timers.
System Clocks.
16F877A. Timer 0 The Timer0 module timer/counter has the following features: –8-bit timer/counter –Readable and writable –8-bit software programmable.
A Few Words From Dilbert
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction.
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
Clock Options and Sleep Modes. Clock Sources Flash Fuse bits can be programmed to choose one of the following Clock sources: 1. External RC Osc. f = 1/(3RC).
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
بسمه تعالي AVR Microcontrollers. The ATmega8 Basic Features -1.
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
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.
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.
Interrupt On a very basic level, an interrupt is a signal that interrupts the current processor activity. It may be triggered by an external event (change.
TIMERS AND INTERRUPTS AVI SINGH KEVIN JOSE PIYUSH AWASTHI.
1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction.
AVR Architecture Prepared By: Avdhesh Soni ( ) Sarthak Patel ( ) Akshay Parekh ( ) Fenil Sachla ( ) Guided.
Embedded Systems Overview Prepared by Nisha Sinsinbar Subject: Microcontoller & Interfacing Sub code: EC Department.
NAM S.B MDLAB. Electronic Engineering, Kangwon National University 1.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
ALPHA COLLEGE OF ENGINEERING & TECHNOLOGY Introduction to AVR ATMega32 Architecture PREPARED BY SHWETA ( ) BHOOMI ( ) YOGEN ( )
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.
Why are Timer Functions Important?
Embedded Systems Programming
V.V.P. ENGINEERING COLLEGE,RAJKOT
ECE 3430 – Intro to Microcomputer Systems
Atmega32 Architectural Overview
C. K. Pithawalla College of Engineering and Technology, Surat
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
Timer and Interrupts.
Microcontroller Applications
MCI PPT AVR MICROCONTROLLER Mayuri Patel EC-1 5th sem
UNIT – Microcontroller.
Overview of AVR Hardware/Software Introduction
AVR Addressing Modes Subject: Microcontoller & Interfacing
AVR Microcontrollers Prepared By: Disha Ruparelia ( )
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.
The Arduino Microcontroller: Atmel AVR Atmega 328
Timer/Counter Modified from Dr. Lam Phung’s Slides.
8-bit Timer/Counter0 with PWM
ECE 3430 – Intro to Microcomputer Systems
ATmega103 Timer0 and Interrupts
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Introduction to Microprocessors and Microcontrollers
8-bit Timer/Counter2 with PWM and Asynchronous Operation
Architectural Overview
Introducing the PIC Mid-Range Family and the 16F84A
AVR – ATmega103(ATMEL) Architecture & Summary
8051 Micro Controller.
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.
ECE 3430 – Intro to Microcomputer Systems
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
Presentation transcript:

BITS EDU. CAMPUS , VARNAMA ELECTRONICS & COMMUNICATION DEPARTMENT MICROCONTROLLERS AND INTERFACING Submitted by: Prabmeet Saini (130050111062) Submitted to: Rita Aggrawal

Overview: AVR Hardware/Software Introduction

History of AVR The Atmel AVRTM is a family of 8-bit RISC microcontrollers produced by Atmel. The AVR architecture was conceived by two students at the Norwegian Institute of Technology (NTH) and further refined and developed at Atmel Norway, the Atmel daughter company founded by the two chip architects.

Introduction to AVR

Used in Lab

AVR Architecture • What are the features of RISC? – 1 instruction per clock cycle (pipelined) – Lots of registers: 32 GP registers – Register-to-register operation • Variations in the parts: – TINY to MEGA – ATtiny10 • Processor has only 8 pins – ATmega128 (128K bytes flash) • Processor has 64 pins

AVR Architecture

AVR RISC Architecture Single Cycle Instructions: 8mhz = 8mips. Large register file (32). Every register an accumulator. 3 index register pairs Register & IO are mapped in SRAM space.

On Chip Debugger Two Wire Interface

Typical Hardware Support Internal or External Oscillator/Clock Brown Out Detector One or more timers Two or more PWM One or more USART 10 bit ADC Analog Comparator External interrupts

PB2 PB3 also used as Analog Input 0 (AIN0) and Analog Input 1 (AIN1)

The Analog Comparator compares the input values on the positive pin AIN0 and negative pin AIN1. When the voltage on the positive pin AIN0 is higher than the voltage on the negative pin AIN1, the Analog Comparator Output, ACO, is set. ACO is kept in bit 5 of Analog Comparator Control and Status Register The comparator’s output can be set to trigger the Timer/Counter1 Input Capture function. In addition, the comparator can trigger a separate interrupt, exclusive to the Analog Comparator. The user can select Interrupt triggering on comparator output rise, fall or toggle

AVR Memory Space • Program Flash – Vectors, Code, and (Unchangeable) Constant Data • Working Registers – Includes X, Y, and Z registers. • I/O Register Space – Includes “named” registers • SRAM – Data Space – Runtime Variables and Data – Stack space • EEPROM space – For non-volatile but alterable data

AVR Addressing Modes • Register Direct, with 1 and 2 registers • I/O Direct • Data Direct • Data Indirect – with pre-decrement – with post-increment • Code Memory Addressing

Register Direct: 1 Register

Register Direct: 2 Registers

I/O Direct

Data Direct STS store direct to data space

Data Indirect

Data Indirect w/ Displacement

Data Indirect: Pre-Decrement

Data Indirect: Post-Increment

Status Register: SREG Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two’s complement overflow indicator S: N  V, For signed tests H: Half Carry Flag T: Transfer bit used by BLD (Bit load) and BST (Bit store) instructions I: Global Interrupt Enable/Disable Flag

Interesting Instruction Examples: • NOP – Do nothing for 1 cycle • SLEEP – Sleep until reset or interrupted • WDR – Watch Dog Reset AVR Instruction set manual available in the course website

Timers: Why we need them • Provide accurately timed delays or actions independent of code execution time • How are Timers used? – Accurate delay • Read the timer, store value as K. Loop until timer reaches K+100. – Schedule important events • Setup an Output Compare to trigger an interrupt at a precise time Port B pin3, PB3, when used as output port, OC0 (Timer/Counter0 Output Compare Match Output) (p.57 of Atmeg16 manual) – Measure time between events • When event#1 happens, store timer value as K • When event#2 happens, read timer value and subtract K • The difference is the time elapsed between the two events

AVR Timer/Counter 0 • 8 Bit • Wrap-Around Up Counter • Interrupt on overflow

AVR Timer/Counter 0 • 8 Bit Up Counter – counts from 0 to 255 (0xFF), then loops to 0 – Internal or External Clock source Prescaler Output capture through OC0, i.e. PB3, pin 4 • Interrupt on Overflow – Transition from 255 to 0 can trigger interrupt if desired

AVR Timer/Counter 0 OC0, Output Compare Match output: Whenever TCNT0 equals OCR0 (Output Compare Register 0), the comparator signals a match The PB3 pin can serve as an external output for the Timer/Counter0 Compare Match. The PB3 pin has to be configured as an output

AVR Timer/Counter 1 – 16 Bit – Dual Comparators A,B (output compares) – Up Counter – Interrupt on: • Overflow • Compare A/B • Input Capture of external event on ICP pin. – Can also act as an 8, 9 or 10 bit PWM Up- Down Counter.

AVR Timer/Counter 1 The Input Capture unit of Timer/Counter captures external events and gives them a time-stamp indicating time of occurrence. The external signal indicating an event, or multiple events, can be applied via the ICP1 pin or alternatively, via the Analog Comparator unit. The time-stamps can then be used to calculate frequency, duty-cycle, and other features of the signal applied. Alternatively the time-stamps can be used for creating a log of the events.

Timer 1 and Output Compare • The AVR has two output compares (OCR1A/B) – OCR1A/B are 16-bit registers – When the value of OCR1A/OCR1B matches that of Timer1: • A user-defined action can take place on the OC1A/OC1B pin (set/clear/inv) i.e.,PD5 /PD4 need to set as output • An interrupt can be triggered • Timer1 can be cleared to zero – Once set up, output compares operate continuously without software intervention – Great for: • Precise recurring timing • Frequency/Tone generation (maybe sound effects) • All kinds of digital signal generation – Infrared communications – Software-driven serial ports

Timer 1 and PWM • Pulse-Width Modulation – Useful for using digital circuits to achieve analog- like control of motors, LEDs, etc – Timer 1 has two channels of PWM output on OCR1A and OCR1B

Timer Control • Timer 0: – Control Register (TCCR0) for clock selection, external clock or internal clock, prescaler etc. – Timer/Counter0 (TCNT0) holding counter value • Timer 1: – Control Register A & B (TCCR1A/B) – Input Capture Register (ICR1) – Timer/Counter1 Output Compare Register A and B (OCR1A/B) – Timer/Counter1 (TCNT1) • Timer Interrupt Registers (Mask and Flag Registers) are Common to Both Timers

AVR Timer/Counter Sources • Shut Off • CPU frequency divided by 1,8,64,256,1024 • At 8MHz that’s: 1/8us, 1us, 8us, 32us, 128us • External Input (rising or falling).

Interrupts • Interrupts halt normal code execution in order to go do something more important or time sensitive • Interrupt “Handlers” – Using the Interrupt Vectors • Interrupts are used for: – RESET – Timers and Time-Critical Code – Hardware signaling • “I’m done” • “Something’s happened that you want to know about” • “I have something for you”

Watchdog Timer: reset the MCU The Watchdog Timer is clocked from a separate On-chip Oscillator which runs at 1 MHz