600 likes | 708 Views
Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction. 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.
E N D
Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction
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...
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.
A “short list” of embedded systems 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 And the list goes on and on
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
What is an embedded system? • Embedded PCs? • “Soft” Processors on PLDs? • Systems On A Chip?
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
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: 4 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
What you will do: • Final Project – your proposed project • Final Project • Hardware • Software • Presentation • Report
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
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.
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
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 When the value in the Output Compare Register matches the value in timer/counter register -- triggers an interrupt -- 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 compare match output through OC0 for timer/counter 0 compare match, 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