Introduction To Microcontrollers: Sistemas Embebidos Oscar Acevedo, PHD

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Introduction to Microcontrollers

Sistemas Embebidos
Oscar Acevedo, PhD
What is a Microcontroller?

• A microcontroller (µC) is a microprocessor-based system enclosed on a single package


(chip)

• A microcontroller contains:
• A “simple” microprocessor
• Memory (RAM and ROM)
• Ports
• Support hardware (clock, interrupts, etc)
• Application-oriented Hardware (AD converter)

• A µC is frequently used in embedded systems implementation


Microcontroller Block Diagram
Microcontroller Tiers

• µC vendors classify their devices based on hardware capabilities:


• Low-tier: 8 bit µP, as small as 8-pin µC
• Medium-tier: 8-16bit µP, up to 40-pin µC
• Advanced-tier: 16-32 bit µP, >40-pin µC. Similar to embedded processors
Popular Microcontroller Vendors

TEXAS
ATMEL MICROCHIP
INSTRUMENT

MOTOROLA
FREESCALE INTEL
About Microcontrollers

• Advantage: • Disadvantage:
• Easy to use • Limited resources
• Small • Low clock speed
• Low power
• Good for portable devices
Integrated Development Environment

• Each vendor offers it own IDE to develop prototypes


• PIC: Mplab, pickit
• Atmel: atmel studio, stk600

• IDE has two parts:


• Software
• Hardware (Programmer)
Microchip Studio (Atmel Studio)

• It is the official IDE for Atmel microcontrollers

• It allows creating, compiling, debugging, simulating and downloading a project into a


microcontroller

• Arduino is also an IDE, but it is not an official ATMEL software


IDE - Hardware

• We will be using the Arduino UNO as programmer (around 50% course)


• No need of additional programmer
• Already configured for use
• You can use Atmel studio and Arduino IDE
Microcontroller Programming

• In order to perform any task, a program must be developed and deployed to the µC

• Programs can be developed in:


• Assembly
• Adapted high-level language (C/C++)
Microcontroller Programming

C language
Microcontroller Programming

• Programming is focused on:


• Hardware configuration
• Hardware handling
• Data processing

• You should keep in mind that you are working directly with hardware

• Think in BINARY!!!
Program Structure

• The µC executes a single program infinitely

Reset / Power On

Configuration

Main
Code
Microcontroller Internal Structure

• You will find these blocks in any µC:


• Microprocessor
• Memory: RAM, ROM
• Ports
• Support hardware: clock, interrupts, reset, etc.
• Additional hardware: timer, A/D, serial ports, etc.

• The main difference between µC tiers is hardware capability

• Each vendor usually design its own µC hardware


Microcontroller Internal Structure – ATMega328
The Microprocessor

• The microprocessor is a multipurpose, clock driven, register based, programmable


electronic device which accepts digital or binary data as input, processes it according to
instructions stored in its memory, and provides results as output. Microprocessors
contain both combinational logic and sequential digital logic
The Microprocessor - Memory Organization

• Von Neumann • Harvard


• Program and data share the same • Program and data have different physical
physical memory, so only one bus memory, so two bus systems are required
The Microprocessor – Instruction Type

• CISC • RISC
• Complex instruction set computer • Reduced instruction set computer
• Large number of instructions • Low number of instructions
• Specialized instructions • Basic instructions
• Many addressing modes • Few addressing modes
• Variable length instruction format • Fixed length instruction
The Microprocessor – ATMega328p (AVR)

• It is a harvard, RISC • Single-cycle


architecture (like almost all Arithmetic Logic Unit
μC) (ALU) operation
• Simple pipeline: fetch and • Multiply Support
execute
• Most AVR
• One instruction is executed instructions have a
in every clock cycle single 16-bit word
• Register File contains 32 x format
8-bit general purpose
working registers
The Microprocessor – ATMega328p (AVR)

Instruction execution time


Memory

• There are two main memory spaces:

• Data Memory

• Program Memory: 32KB (16K x 16)


• Boot loader
• Application program
Memory – Data Memory

• Organized as follows:
• 32 registers
• 64 I/O registers
• 160 I/O registers (ext)
• 2048 Bytes SRAM
• The 64 basic I/O registers can
be accessed from both IN-
OUT instructions and memory
instructions
Memory – Access Time

It requires 2 clkCPU cycles


Fin de la presentación

You might also like