Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction
Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction
Overview, AVR
Hardware/Software Introduction
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
VCRs, DVD players
Video game consoles
Video phones
Washers and dryers
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
10
History of AVR
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
16
On Chip
Debugger
18
19
20
21
22
24
27
28
I/O Direct
29
Data Direct
STS
30
Data Indirect
31
32
33
34
36
AVR Timer/Counter 0
8 Bit
Wrap-Around
Up Counter
Interrupt on
overflow
38
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
39
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
40
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 UpDown Counter.
41
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.
42
43
44
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
45
46
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
Im done
Somethings happened that you want to know
about
I have something for you
47
48
49
Reading Assignment:
Chapter 1 of Embedded C Programming and the Atmel AVR
50