lecture 1: embedded systems overview, avr hardware/software introduction
DESCRIPTION
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. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/1.jpg)
1
Lecture 1: Embedded Systems Overview, AVR
Hardware/Software Introduction
![Page 2: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/2.jpg)
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...
![Page 3: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/3.jpg)
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.
![Page 4: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/4.jpg)
4
A “short list” of embedded systems
And the list goes on and on
Anti-lock brakesAuto-focus camerasAutomatic teller machinesAutomatic toll systemsAutomatic transmissionAvionic systemsBattery chargersCamcordersCell phonesCell-phone base stationsCordless phonesCruise controlCurbside check-in systemsDigital camerasDisk drivesElectronic card readersElectronic instrumentsElectronic toys/gamesFactory controlFax machinesFingerprint identifiersHome security systemsLife-support systemsMedical testing systems
ModemsMPEG decodersNetwork cardsNetwork switches/routersOn-board navigationPagersPhotocopiersPoint-of-sale systemsPortable video gamesPrintersSatellite phonesScannersSmart ovens/dishwashersSpeech recognizersStereo systemsTeleconferencing systemsTelevisionsTemperature controllersTheft tracking systemsTV set-top boxesVCR’s, DVD playersVideo game consolesVideo phonesWashers and dryers
![Page 5: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/5.jpg)
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
![Page 6: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/6.jpg)
6
What is an embedded system?
• Embedded PCs?
• “Soft” Processors on PLDs?
• Systems On A Chip?
![Page 7: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/7.jpg)
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
![Page 8: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/8.jpg)
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: 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
![Page 9: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/9.jpg)
9
What you will do:
• Final Project – your proposed project
• Final Project– Hardware– Software– Presentation– Report
![Page 10: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/10.jpg)
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
![Page 11: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/11.jpg)
11
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.
History of AVR
![Page 12: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/12.jpg)
12
Introduction to AVR
![Page 13: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/13.jpg)
13
![Page 14: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/14.jpg)
14
![Page 15: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/15.jpg)
15
![Page 16: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/16.jpg)
16
Used in Lab
![Page 17: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/17.jpg)
17
![Page 18: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/18.jpg)
18
![Page 19: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/19.jpg)
19
![Page 20: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/20.jpg)
20
![Page 21: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/21.jpg)
21
![Page 22: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/22.jpg)
22
![Page 23: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/23.jpg)
23
![Page 24: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/24.jpg)
24
![Page 25: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/25.jpg)
25
![Page 26: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/26.jpg)
26
![Page 27: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/27.jpg)
27
![Page 28: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/28.jpg)
28
![Page 29: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/29.jpg)
29
![Page 30: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/30.jpg)
30
![Page 31: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/31.jpg)
31
![Page 32: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/32.jpg)
32
![Page 33: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/33.jpg)
33
![Page 34: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/34.jpg)
34
![Page 35: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/35.jpg)
35
![Page 36: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/36.jpg)
36
![Page 37: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/37.jpg)
37
![Page 38: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/38.jpg)
38
![Page 39: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/39.jpg)
39
![Page 40: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/40.jpg)
40
![Page 41: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/41.jpg)
41
![Page 42: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/42.jpg)
42
![Page 43: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/43.jpg)
43
![Page 44: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/44.jpg)
44
PB2 PB3 also used as Analog Input 0 (AIN0) and Analog Input 1 (AIN1)
![Page 45: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/45.jpg)
45
The Analog Comparator comparesthe input values on the positive pin AIN0 and negative pinAIN1.
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 comparatoroutput rise, fall or toggle
![Page 46: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/46.jpg)
46
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
![Page 47: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/47.jpg)
47
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
![Page 48: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/48.jpg)
48
AVR Timer/Counter 0
• 8 Bit
• Wrap-Around
Up Counter
• Interrupt on
overflow
![Page 49: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/49.jpg)
49
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
![Page 50: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/50.jpg)
50
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 0
![Page 51: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/51.jpg)
51
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.
![Page 52: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/52.jpg)
52
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 multipleevents, 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.
AVR Timer/Counter 1
![Page 53: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/53.jpg)
53
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.,(OC1A )PD5 / (OC1B) 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
![Page 54: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/54.jpg)
54
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
![Page 55: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/55.jpg)
55
Timer Control: I/O space
• 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
![Page 56: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/56.jpg)
56
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).
![Page 57: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/57.jpg)
57
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”
![Page 58: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/58.jpg)
58
![Page 59: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/59.jpg)
59
Watchdog Timer: reset the MCUThe Watchdog Timer is clocked from a separate On-chip Oscillator which runs at 1 MHz
![Page 60: Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction](https://reader035.vdocument.in/reader035/viewer/2022062222/56814f36550346895dbcd19a/html5/thumbnails/60.jpg)
60
Reading Assignment: Chapter 1 of Embedded C Programming and the Atmel AVR