Architecture of Arduino Microcontroller
Architecture of Arduino Microcontroller
Architecture of Arduino
microcontroller
Learning Objectives
Explain the general architecture of a microcontroller
List the key features of the ATmega328
microcontroller
Explain the features and elements of the Arduino and
Spartronics Experimenter Shield (SES)
Explain the concepts of microcontroller pins as inputs
and outputs
Convert between binary and hexadecimal digits
What is a Microcontroller?
ANALOG
INPUTS
http://www.adafruit.com/index.php?main_page=popup_image&pID=50
ATmega328 Features
http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-
ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf
Arduino Duemilanove
http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove
See the handout: Arduino_ATmega328_pin_mapping_and_schematic
Pin 13 LED
Digital pins header
USB
connector Reset button
ATmega328 MCU
Power-ground header
http://arduino.cc/en/uploads/Main/ArduinoDuemilanove.jpg
Arduino Uno R3
ATmega16u2 replaces FT232RL for USB-serial communication
http://www.adafruit.com/index.php?main_page=popup_image&pID=50
See: http://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-uno-faq
Arduino Due Note: 3.3 V !!
http://www.adafruit.com/index.php?main_page=popup_image&pID=1076
See: http://arduino.cc/en/Main/ArduinoBoardDue
Arduino Duemilanove/Uno Features
Microcontroller ATmega168/328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB
Flash Memory
used by bootloader
SRAM 1 KB (ATmega168) or 2 KB (ATmega328)
EEPROM 512 bytes (ATmega168) or 1 KB (ATmega328)
Clock Speed 16 MHz
http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove
http://arduino.cc/en/uploads/Main/arduino-duemilanove-schematic.pdf
ATmega328 Microcontroller
Pin number
Pin name
Special
function
Note the
limitations!
p. 316 Source:http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega328P
Absolute Maximums
• Input
• When you want to take information from the external
world (sensors) into the MCU
• Output
• When you want to change the state of something outside
the MCU (turn a motor on or off, etc.)
• Pins default to input direction on power-up or reset
• Your program can set or change the directionality of
a pin at any time
ATmega328
Block Diagram
Input
Output
M68HC11 microcontroller
Setting the Pin Data Direction
• Arduino
• pinMode(pin_no., dir)
• Ex. Make Arduino pin 3 (PD3) an output
• pinMode(3, OUTPUT);
• pinMode(PIN_D3, OUTPUT); // with
me106.h
• Note: one pin at a time
• Suppose you wanted Arduino pins 3, 5, and 7 (PD3, PD5,
and PD7) to be outputs?
• Is there a way to make them all outputs at the same time?
• Yes! Answer coming later…
Pin Voltages
momentary
Pins as Inputs and Pull-up Resistors - 2
• Switch as a sensor, cont.
• Make the voltage on the pin ATmega328
determinate by turning on the pull-up VTG= +5V
resistor for PD3
• Assuming PD3 is an input:
• digitalWrite(PIN_SWITCH,HIGH); 1
PD3
turns on the “pull-up” resistor
0
• pinMode(PIN_SWITCH,INPUT_PULLUP);
• What will the voltage on PD3 be when the
switch is open?
• VTG
• What will the voltage on PD3 be when the
switch is closed?
Pins as Inputs and Pull-up Resistors - 3
• Switch as a sensor, cont.
• To turn off the pull-up resistor ATmega328
• Assuming PD3 is an input: VTG= +5V
digitalWrite(PIN_SWITCH,
LOW); turns the “pull-up” resistor 1
off PD3
0
Pins as Inputs and Pull-up Resistors - 4
• Possibility of ‘weak drive’ when pull-up
resistor is turned on ATmega328
• Pin set as an input with a pull-up VTG= +5V
resistor turned on can source a small
current iweak
1
• Remember this! PD3
0
ATmega328 Registers of Interest
Jump to bits
Example 1
Make Arduino pins 3, 5, and 7 (PD3, PD5, and
PD7) to be outputs
• Arduino approach • Alternate approach