1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction.

Slides:



Advertisements
Similar presentations
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
Advertisements

Embedded Systems Design: A Unified Hardware/Software Introduction 1 Introduction to embedded Systems.
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.
Introduction to Microprocessors Number Systems and Conversions No /6/00 Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
ASPPRATECH.
WELCOME M.TECH- BIOMEDICAL SIGNAL PROCESSING & INSTRUMENTATION Murigendrayya M Hiremath Lecturer –ML DSCE.
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
Embedded Systems Overview
SENIOR DESIGN 10/3.
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
Atmega32 Architectural Overview
1 © Unitec New Zealand Overview Of Embedded Hardware ETEC 6416 Date: - 03 Aug, 2011.
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.
Microcontroller Systems: Motivation
Embedded Systems Design 1. 2 Embedded Systems Overview Computing systems are everywhere Most of us think of “desktop” computers –PC’s –Laptops –Mainframes.
Embedded Systems. 2 A “short list” of embedded systems And the list goes on and on Anti-lock brakes Auto-focus cameras Automatic teller machines Automatic.
AVR Microcontrollers.
Computing Systems Computer abstractions and technology.
Input/Output mechanisms
A Few Words From Dilbert
1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
بسمه تعالي 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.
Technology discontinuities drive new computing paradigms and applications 1960 Mainframe ComputerIBM 1970 Mini-Computer DEC 1980 WorkstationSun, HP 1990PCIntel,
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.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
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.
The 8085 Microprocessor Architecture. What 8085 meant for? 80 - year of invention bit processor 5 - uses +5V for power.
Chapter Microcontroller
Embedded Systems Introduction. Microprocessor building blocks 1. ALU (Arithmetic Logic Unit): The ALU is a sequential logic circuitry that is intended.
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.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Chapter 1: Embedded Computing Embedded System Design.
KAASHIV INFOTECH – A SOFTWARE CUM RESEARCH COMPANY IN ELECTRONICS, ELECTRICAL, CIVIL AND MECHANICAL AREAS
Vadodara Institute of Engineering Subject: Microcontroller interfacing Prepared by: Bipin Malani ( ) Vishwa Pandit ( ) Branch : Electronics.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
USING TV REMOTE AS A CORDLESS MOUSE FOR THE COMPUTER
CORDLESS MOUSE FEATURES BY TV REMOTE USING PIC MICROCONTROLLER
Introduction to Microcontroller Technology
C. K. Pithawalla College of Engineering and Technology, Surat
MCI PPT AVR MICROCONTROLLER Mayuri Patel EC-1 5th sem
UNIT – Microcontroller.
BITS EDU. CAMPUS , VARNAMA
Overview of AVR Hardware/Software Introduction
AVR Addressing Modes Subject: Microcontoller & Interfacing
EmbedDed Systems – MECT190
The Arduino Microcontroller: Atmel AVR Atmega 328
Timer/Counter Modified from Dr. Lam Phung’s Slides.
ATmega103 Timer0 and Interrupts
Introduction to Microprocessors and Microcontrollers
EmbedDed Systems – MECT190
Memories.
Journey: Introduction to Embedded Systems
Architectural Overview
Introduction to Embedded Systems
AVR – ATmega103(ATMEL) Architecture & Summary
Wireless Embedded Systems
SNS COLLEGE OF TECHNOLOGY
Introduction to Embedded Systems
Embedded Systems By : Simran Amaandeep Singh
Presentation transcript:

1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction

2 Embedded Systems Overview Computing systems are everywhere Most of us think of “desktop” computers –PC’s –Laptops –Mainframes –Servers But there’s another type of computing system –Far more common...

3 Embedded Systems Overview Embedded computing systems –Computing systems embedded within electronic devices –Hard to define. Nearly any computing system other than a desktop computer –Billions of units produced yearly, versus millions of desktop units –Perhaps 50 per household and per automobile Computers are in here... and here... and even here... Lots more of these, though they cost a lot less each.

4 A “short list” of embedded systems And the list goes on and on Anti-lock brakes Auto-focus cameras Automatic teller machines Automatic toll systems Automatic transmission Avionic systems Battery chargers Camcorders Cell phones Cell-phone base stations Cordless phones Cruise control Curbside check-in systems Digital cameras Disk drives Electronic card readers Electronic instruments Electronic toys/games Factory control Fax machines Fingerprint identifiers Home security systems Life-support systems Medical testing systems Modems MPEG decoders Network cards Network switches/routers On-board navigation Pagers Photocopiers Point-of-sale systems Portable video games Printers Satellite phones Scanners Smart ovens/dishwashers Speech recognizers Stereo systems Teleconferencing systems Televisions Temperature controllers Theft tracking systems TV set-top boxes VCR’s, DVD players Video game consoles Video phones Washers and dryers

5 What is an embedded system? What makes a microcontroller: – Self Contained CPU Memory I/O – Application or Task Specific Not a general-purpose computer Appropriately scaled for the job

6 What is an embedded system? Embedded PCs? “Soft” Processors on PLDs? Systems On A Chip?

7 Designing Embedded Systems Microcontrollers – Don’t have keyboard and monitor jacks – Must use ports to perform I/O Inputs – to sense things Outputs – to control things Related Component Topics – Common Interfaces – Part Packages

8 What you will do: Labs –Lab 1: Introduction to AVR STK500 Hardware/Software, a couple of simple c programs –Lab 2: A/D converter –Lab 3: Optical Sensors –Lab 4: 2 bits D/A converter –Lab 5: Controls and Feedback –Lab 6: Motor Control - open loop –Lab 7: Motor Control - simple feedback control –Lab 8: Motor Control - proportional feedback control

9 What you will do: Presentation – your proposed project Final Project –Hardware –Software –Presentation –Report

10 Introduction to AVR CodeVision AVR C Compiler Professional version –Installed in 20 PCs in room EN229 –Compile programs with more than a thousand instructions. –Provides many useful assembly programs used by your C programs. You write your programs in C completely. AVR C compiler will integrate all required programs together –More about AVR C compiler when presenting Lab 1

11 Introduction to AVR

12 Used in Lab

13 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

14 AVR Architecture

15 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.

16 On Chip Debug Serial Peripheral Interface Two Wire Interface

17

18 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

19

20

21 AREF is analog ref. pin for A/D converter AVCC is connected to Vcc or through a low pass filter to Vcc

22

23 AVCC and AREF properly connected

24 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

25 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

26 Register Direct: 1 Register

27 Register Direct: 2 Registers

28 I/O Direct

29 Data Direct STSstore direct to data space

30 Data Indirect

31 Data Indirect w/ Displacement Operand address is the result of the Y- or Z-register contents added to the address contained in 6 bits of the instruction word. Rd/Rr specify the destination or source register.

32 Data Indirect: Pre-Decrement The X,- Y-, or the Z-register is decremented before the operation.

33 Data Indirect: Post-Increment The X-, Y-, or the Z-register is incremented after the operation.

34 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 and BST instructions I: Global Interrupt Enable/Disable Flag

35 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 This instruction resets the Watchdog Timer. This instruction must be executed within a limited time given by the WD prescaler. When WDT (Watch Dog Timer) times out and resets the processor

36 include static unsigned int waiter; /*variable to time blinks*/ void main (void) { DDRC = 0x1; /*set PORTC.0 for output*/ /*wait for button to be pressed*/ while (PINA.0 == 1) { ; /*wait for PB to be pressed*/ } WDTCR = 0x0b; /*enable WDT with 130 ms timeout*/ /*stay in this loop while button is held*/ while(PINA.0 == 0) { #asm("wdr"); /*reset WT continuously*/ ++waiter; /*increment waiter variable*/ if (waiter == 50000) { PORTC.0 = PORTC.0 ^ 1; /*complement port bit*/ waiter = 0; /*reset waiter for next delay time*/ } while(1); /*lock up to allow WDT to time out*/ } /* Demonstration the use of of the watchdog timer */

37

38 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 – 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

39 AVR Timer/Counter 0 8 Bit Wrap-Around Up Counter Interrupt on Overflow

40 AVR Timer/Counter 0 8 Bit Up Counter – counts from 0 to 255 (0xFF), then loops to 0 – Internal or External Clock source Prescaler Interrupt on Overflow – Transition from 255 to 0 can trigger interrupt if desired

41 Example: 6MHz, Prescaler = 8, 6/8=0.75MHz, 1 clock cycle = 1.33 us for the Timer

42 static unsigned int time_count; /*.5 second counter*/ // Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isr(void) { TCNT0 = 31; /*set initial value for counter 0 to 31, count up to 256, for 300 us timeout*/ /* 256 – 31 = 225 counts at 1.33 us/clock cycle; 225x1.33 = 300 us */ ++time_count; /*increment.5 second counter*/ if (time_count == 1666) /* 300us x 1666 =.5 sec */ { PORTC.0 = (PORTC.0 ^ 1); /*complement port bit to blink LED*/ time_count = 0; /*reset time counter for next.5 second*/ } void main (void) { DDRC = 0x01; /*set PORTC.0 for output*/ /*set timer 0 prescaler to clk/8*/ TCCR0=0x02; TCNT0=0x00; OCR0=0x00; /* unmask Timer 0 overflow interrupt*/ TIMSK=0x01; /* enable interrupts */ #asm("sei") while(1) { ; /*do nothing in here */ } /*TCCR: timer counter control register*/ /* TCNT0: timer counter 0*/

43

44 AVR Timer/Counter 1 – 16 Bit – Dual Comparators A,B (output captures) – 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.

45 Timer 1 and Output Compare The AVR has two output compares (OCR1A/B) – OCR1A/B are 16-bit registers – When the value of OCR1x matches that of Timer1: A user-defined action can take place on the OC1x pin (set/clear/inv) 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

46 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

47 Timer Control: I/O space Timer 0: – Control Register (TCCR0) – Timer/Counter0 (TCNT0) 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

48 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).

49 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”

50

51 Reading Assignment: Chapter 1 of Embedded C Programming and the Atmel AVR Next class time we may have a quiz about Chapter 1 Exercises.