Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

Es Arduino 2

es_arduino_2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Es Arduino 2

es_arduino_2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Lecture 2

Introduction to Microcontrollers

1
Microcontrollers

 Microcontroller

 CPU + ++++++++++
 Microprocessor

 CPU (on single chip)

2
What is a Microcontroller
 Integrated chip that typically contains integrated CPU, memory (RAM
ROM), I/O ports on a single Chip.

 System on a single Chip/ small computer on a single chip

 Designed to execute a specific task to control a single system

 Smaller & Specified (design cost)

 Differs from Microprocessor


general-purpose chip
Used to design multi purpose computers or devices
Require Multiple chips to handle various tasks

 Typically Microcontroller embedded inside some device

 Microcontrollers are important part of Embedded systems 3


What is a Development Board

• A printed circuit board


designed to facilitate
work with a particular
microcontroller.

• Typical components include:


• power circuit
• programming interface
• basic input; usually buttons and LEDs
• I/O pins
4
The Arduino Development Board
Arduino (The name is an Italian , meaning “strong friend”) is an open-
source platform used for building electronics projects. Arduino consists of both a
physical programmable circuit board (often referred to as a microcontroller) and a
piece of software, or IDE (Integrated Development Environment) that runs on your
computer, used to write and upload computer code to the physical board.

5
Arduino Microcontroller Boards
6

Microcontroller ATmega328
Operating Voltage 5V
Input Voltage
7-12 V
(recommended)
Input Voltage (limits) 6-20 V
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
32 KB (ATmega328) of which 2 KB used by
Flash Memory
bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz
ATmega328 Internal Architecture

7
ATmega328 Microcontroller
Pin number
Pin name

Special
function

8
Microcontroller Ports and Pins

 The communication channels


through which information C
flows into or out of the
microcontroller
 Ex. PORTB
 Pins PB0 – PB7
 May not be contiguous
 Often bi-directional

9
ATmega328
Block Diagram

Input

Output

10
Setting the Pin Data Direction
 Arduino
 pinMode(pin_no., dir)
 Ex. Make Arduino pin 3 (PD3) an output
 pinMode(3, OUTPUT);

 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…

11
Atmega328 Overview
Internal
memories
 32KB Flash
 1KB EEPROM
 2KB SRAM

8-bit CPU
Timer/Counter

Serial Peripheral
Universal Synchronous Interface
and Asynchronous
serial Receiver and
Transmitter (Serial)

GPIO 2-wire Serial


Interface

12
AVR Microcontroller

AVR stand for?

 Advanced Virtual RISC,


the founders are Alf Egil Bogen Vegard Wollan RISC

 AVR architecture was conceived by two students at


Norwegian Institute of Technology (NTH) and further refined
and developed at Atmel Norway (Atmel AVR).

13
AVR Microcontroller

 AVR Micro controllers is Family of RISC


Microcontrollers from Atmel.

 There are multiple architectures

RISC (Reduced Instruction Set Computer)


CISC (Complex Instruction Set Computer)

14
RISC Microcontroller

Reduced Instruction Set Computers Advantages

 Fast Execution of Instructions due to simple instructions for


CPU.
 RISC chips require fewer transistors, which makes them
cheaper to design and produce.
 Emphasis on software
 Single-clock , reduced instruction only
 Register to register: “LOAD" and "STORE“ are independent
instructions
 Spends more transistors on memory registers

15
On Chip
Debugger

Two Wire
Interface

16
AVR Microcontroller
The AVR is a Harvard architecture CPU.
 Harvard Architecture

 Computer architectures that used physically separate storage


and signal pathways for their instructions and data.

 CPU can read both an instruction and data from memory


at the same time that makes it faster.

 von Neumann architecture

 CPU can Read an instruction or data from/to the memory.

 Read, Write can`t occur at the same time due to same


memory and signal pathway for data and instructions.

17
AVR Microcontroller

Harvard Architecture

Harvard Architecture diagram


18
AVR Microcontroller

 AVR is a family of 8-bit microntrollers with a large range of variants


differing in:

- size of program-memory (flash)


- size of EEPROM memory
- number of I/O pins
- number of on-chip features such as UART and ADC

 Smallest microcontroller is the ATTiny11 with 1k flash ROM, no RAM


and 6 I/O pins.

 Large such as the ATMEGA128 with 128k flash, 4KB RAM, 53 I/O pins
and lots of on-chip features.

19
AVR Microcontroller

20
AVR Architecture
• Registers
• Instruction Set
• I/O ports
• Memory (flash & RAM & ROM)
• CPU

21
AVR Architecture
 Registers: Two types of registers
GERNEL purpose & SPECIAL purpose registers

 GERNEL purpose
32 general purpose registers having storage capacity of
8-Bits
Named as R0,R1,R2 to R31.
Register 0 to 15 & 16 to 31 are different.
Can store both Data & Addresses.

 SPECIAL purpose: Three registers


Program counter
Stack Pointer
Status Register 22
AVR Memory Space
• Program Flash
– Vectors, Code, and
(Unchangeable) Constant Data
• Working Registers
– Includes X, Y, and Z registers.
• I/O Register Space
– Includes “named” registers
• SRAM – Data Space
– Runtime Variables and Data
– Stack space
• EEPROM space
– For non-volatile but alterable data

23
AVR Architecture
Pointer Register

Three 16-bit address registers pairs of registers 26 to 31


have extra meaning in AVR assembly.
X (r27:r26), y (r29:r28), z (r31:r30).

pointer Sequence
Read/Write from address X,
X
don't change the pointer

24
AVR Architecture

status register
(SREG) It is 8-bit long each bit has a different meaning.

I T H S V N Z C

I: Global Interrupt Enable/Disable Flag, SREG7


T: Transfer bit used by BLD and BST instructions, SREG6
H: Half Carry Flag, SREG5
S: For signed tests Instruction Set, SREG4
V: Two's complement overflow indicator, SREG3
N: Negative Flag, SREG2
Z: Zero Flag, SREG1
C: Carry Flag, SREG0

25
AVR Architecture

Stack Pointer (SP)

16-bit stack pointer (SP) holds address in data space of area


to save function call information.

26
AVR
Register Architecture

27
AVR Architecture

Memory:

There are two separate


memories

Program Memory
Data Memory

28
AVR Studio

 Integrated Development Environment (IDE) for


writing and debugging AVR applications for
windows environments.

 AVR Studio provides a project management tool,


source file editor, chip simulator and In-circuit
emulator interface for the powerful AVR 8-bit
RISC family of microcontrollers.

29

You might also like