Avr microcontrollers training (sahil gupta - 9068557926)
1. AVR Microcontrollers
What is a microcontroller?
− microprocessor
− Read-write memory
− Flash memory
− EEPROM
− Input/Output Control
− Peripheral Devices (AD/DA)
Billions sold per year, most processors
Emphasis is on cost. (pennies)
Alternative/paired to ASIC/DSP
Emphasis on power consumption
2. ATMega32 Specifications
Low-Power 8-bit AVR Microcontroller
Modified Harvard Architecture
Around $4 individual, $2.50 in Volume
32 8-bit general-purpose registers
131 Instructions, Multi-cycle Implementation
− Most are single-cycle
− 2-cycle multiply, 2-cycle memory access
− Thus up to 1MIPS/MHz
20MHz, up to 20MIPS
16KB self-programmable Flash
512 Bytes EEPROM
1KB SRAM
4. Manufacturers
Intel, Freescale, Microchip (PIC), TI, Zilog
Atmel AVR
− Many Types, tinyAT, megaAT, automotive
− Lighting, LCD
− Share unified platform
− Different #s of I/O control
− Built-in Pull-up resistors
− Ethernet, Serial Data, Auxiliary Power, USB
− Analog I/O, Packaging, Interrupts, Math, JTAG
− Get the right amount of memory for the job
5. Development Platforms
Everything Needed, All-In-One
Arduino / Diecimila
− ATMega8 / ATMega168 based
− Open source, multiplatform IDE
− Cheap ($33 assembled!)
− Great Online Community
− USB, power, protoshield available, breadboard,
LEDs
Parallax (PIC)
PICAXE (PIC)
ArmExpress
Many Others
6. Cheaper
A Transistor Saved is a Transistor Earned
No Lack Floating Point
Non-Pipeline
No cache
Limited Math / Branching
Very Slow (1 to 32MHz)
Very Little Memory (64bytes to 256KB)
From under a dollar to $20 for advanced
− Cheaper in volume
− Important for large product runs
7. AVR History
Conceived by two students at Norwegian
Institute of Technology (NTH)
− Alf-Egil Bogen and Vegard Wollan
Originally Known as μRISC (Micro RISC)
Sold to Atmel, continued working under
Atmel Norway subsidiary
AVR supposedly not acronym
− May mean Advanced Virtual RISC
Beauty in simplicity
− Can wrap mind around entire CPU
8. ATMega32 IO
6 PWM Shared Input/Outputs (Analog)
8 digital input/outputs
SPI-serial, 2-wire serial, ISP, others
− Monitoring, debugging, programming, power
USART serial interface
− (interfaces with USB on Arduino)
9.
10.
11. Instruction Set
Mostly unified across all AVR
− With exceptions for feature differences
32 or 16 bit instructions
8-bit fields, vary depending on instructions
I/O manipulation treated in similar fashion to
registers
− Allows for clean and simple usage
Parallel Instruction Fetch
Uses Skip instead of Branches
Use software libraries for more complex
functionality (divide)
12. Registers
32 general purpose registers
Addressable as first 32 memory addresses
4 Different Simultaneous Access Schemes
X, Y, Z registers for indirect memory
− Dual-purpose, 16 bit
− 26/27, 28/29, 30/31
200+ I/O, settings, timers, interrupts registers
Overflow at 256 / 65K!
14. Memories
3 different memories
− SRAM
− Flash
− EEPROM
Direct/Indirect Addressing (5 modes total)
Flash is divided into two 8KB sections
− Independently addressable
Flash has reserved Bootloader section for
software security
15. Additional Functionality
Registers for serial access
Interrupts
External Interrupts
Power Management
Timers
Analog Comparators
Other Goodies
All handled via special registers
− Some settings via bit-flags
16. Compilers
Meant for Assembly Programming
− Many environments available
BASIC and FORTRAN compilers available
Open Source Tools and Compilers
avr-GCC for C/C++ support
AVR Studio Assembler / Simulator
− Supported, official, Windows-only IDE
17. Operating System?
No common operating systems available
None would work!
EEPROM Bootloader / Initializer
Real-Time Operating Systems
Commercial Systems:
− Salvo
− AVRX
− NutOS
− Proc
18. FreeRTOS
Free and Open Source Operating System
− Portable across many platforms
− Royalty Free
1-2KB storage
50-100Bytes Memory
Can spawn off “tasks”
− Guaranteed timings, simple
“Coroutines”
− Less memory, more complex, coexist, portable
Commercial Sister Projects
19. Loading
EEPROM burner / custom Programmer
ISP-interface
− Serial / Parallel Programming (AVRdude)
USB tty support
Most IDE's available will make this job easy
20. Future
Smaller, Better, Faster, Cheaper
Many new products become possible
− Children's toys
− Ubiquitous Computing
− Physical Computing
Becoming very popular among Hobbyists
Great introduction for CS people into EE-land
21. A/D CONVERTER
An Analog-to-digital
converter (abbreviated ADC, A/D or A to D) is a device
that converts a continuous physical quantity (usually
voltage) to a digital number that represents the quantity's
amplitude. The conversion involves quantization of the
input, so it necessarily introduces a small amount of
error. Instead of doing a single conversion, an ADC often
performs the conversions (“samples" the input)
periodically. The result is a sequence of digital values
that have converted a continuous-time and continuous-
amplitude analog signal to a discrete time and discrete-
amplitude digital signal.