CN310 Microprocessor Systems Design

Similar documents
Introduction to Arduino. Wilson Wingston Sharon

ARDUINO MEGA INTRODUCTION

Introduction to Embedded Systems

INTERRUPTS in microprocessor systems

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Lab Course Microcontroller Programming

Arduino Uno R3 INTRODUCTION

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

ATmega128. Introduction

Microcontroller basics

Robosoft Systems in association with JNCE presents. Swarm Robotics

AVR XMEGA TM. A New Reference for 8/16-bit Microcontrollers. Ingar Fredriksen AVR Product Marketing Director

VLSI Design Lab., Konkuk Univ. Yong Beom Cho LSI Design Lab

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

keyestudio Keyestudio MEGA 2560 R3 Board

MICROPROCESSOR BASED SYSTEM DESIGN

Interconnects, Memory, GPIO

The Atmel ATmega328P Microcontroller

EE 308: Microcontrollers

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

LBAT90USB162 Atmel. LBAT90USB162 Development Board User s Manual

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

AVR- M16 development board Users Manual

SBAT90USB162 Atmel. SBAT90USB162 Development Board User s Manual

Diploma in Embedded Systems

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

PIC Microcontroller Introduction

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

AVR Microcontrollers Architecture

User s Manual of Board Micro Controller ET-EASY168 STAMP ET-EASY168 STAMP. Picture displays structure of Board ET-EASY168 STAMP.

Workshop on Microcontroller Based Project Development

AVR Training Board-I. VLSI Design Lab., Konkuk Univ. LSI Design Lab

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Lab 1 Introduction to Microcontroller

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

8-bit Microcontroller with 1K Byte of In-System Programmable Flash AT90S1200

The Atmel ATmega168A Microcontroller

Embedded programming, AVR intro

Arduino Prof. Dr. Magdy M. Abdelhameed

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

ARDUINO LEONARDO ETH Code: A000022

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

An Arduino Controlled 1 Hz to 60 MHz Signal Generator

Automation Engineers AB Pvt Ltd, NOIDA Job-Oriented Course on Embedded Microcontrollers & Related Software Stack

Cerebot Nano Reference Manual. Overview. Revised April 15, 2016 This manual applies to the Cerebot Nano rev. A

Mega128-DEVelopment Board Progressive Resources LLC 4105 Vincennes Road Indianapolis, IN (317) (317) FAX

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

INTERFACING HARDWARE WITH MICROCONTROLLER

ARDUINO MICRO WITHOUT HEADERS Code: A000093

Clock and Fuses. Prof. Prabhat Ranjan Dhirubhai Ambani Institute of Information and Communication Technology, Gandhinagar

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

Basic Components of Digital Computer

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

Memory Expansion. Lecture Embedded Systems

ARDUINO LEONARDO WITH HEADERS Code: A000057

8051 Microcontroller

HC12 Built-In Hardware

Doc: page 1 of 6

CN310 Microprocessor Systems Design

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

Introduction to Arduino

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

ESPino - Specifications

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

Farklı Arduino Boardlar

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313

Department of Electronics and Instrumentation Engineering Question Bank

8. Power Management and Sleep Modes

Bolt 18F2550 System Hardware Manual

Microcontrollers. Principles and Applications. Ajit Pal +5 V 2K 8. 8 bit dip switch. P2 8 Reset switch Microcontroller AT89S52 100E +5 V. 2.

Unlocking the Potential of Your Microcontroller

EE4390 Microprocessors. Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System

LAMPIRAN I (LISTING PROGRAM)

Breeze Board. Type A. User Manual.

[MG2420] MCU Module Datasheet. (No. ADS0705) V1.0

8-bit Microcontroller with 1K Bytes Flash. ATtiny10 ATtiny11 ATtiny12. Preliminary. Features. Pin Configuration

CN310 Microprocessor Systems Design

OPERATIONAL UP TO. 300 c. Microcontrollers Memories Logic

Overview of Microcontroller and Embedded Systems

Doc: page 1 of 8

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features.

8-bit Microcontroller with 2K Bytes of Flash. ATtiny28L ATtiny28V

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

EE 308 Spring A software delay

CONTENTS BIGAVR2 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

8-bit Microcontroller with 4K Bytes of In-System Programmable Flash AT90S4433 AT90LS4433. Features. Not Recommend for New Designs. Use ATmega8.

Introduction to ARM LPC2148 Microcontroller

Various power connectors. 3.3V regulator. 64K Flash (Internal) 2K EEPROM (Internal) 4K SRAM (Internal) JA Mem Adr/ Data. Doc: page 1 of 9

Embedded Systems. Read pages

Programming in the MAXQ environment

Microcontrollers. Microcontroller

8-bit Microcontroller with 1K Byte Flash. ATtiny11. ATtiny12

ootbrobotics.com Electronics and Robotics LLC

Z8 Encore! XP F1680 Series 8-Bit Flash Solution with Extended Peripherals

Doc: page 1 of 6

Transcription:

CN310 Microprocessor Systems Design Microcontroller Nawin Somyat Department of Electrical and Computer Engineering Thammasat University

Outline Course Contents 1 Introduction 2 Simple Computer 3 Microprocessor Architecture 4 Memory 5 Peripherals 6 Applications Outline 1 Microcontroller Keywords Common Features Circuits Memory 2 Input/output I/O Registers 3 Bus 4 Selection 5 Peripherals Timing Interface Comm. Interface Analog Interface CN310 Microprocessor Systems Design 2 / 52

Some Related Keywords Register: Program counter: address of current instruction Status register: conditions after ALU instruction Flag: bit components Processor bus: Address bus: address of instruction or data Data bus: data access (in or out) Control bus: control signals, e.g. read and write Memory map: Flash memory: store program code or constant SRAM: store volatile data during execution I/O address: memory address for accesing I/O I/O map: memory map for I/O CN310 Microprocessor Systems Design 3 / 52

Some Related Keywords Interrupt: Interrupt request (IRQ): notification of some event Interrupt masking: enable or disable IRQ Interrupt priority: importance of IRQ Interrupt handler: code to be executed in response to an IRQ Interrupt vector: address of interrupt handler Nested interrupt: high-priority IRQ can preempt lower priority Instruction set: ALU instructions: aritmetic/logic operation Two s complement: representation of signed number Data instructions: data manipulation (transfer/movement) Subroutine calls: change program counter CN310 Microprocessor Systems Design 4 / 52

Microcontroller A small computer on a single IC containing a processor core, memory, programmable I/O and peripherals. fewer components, lower power consumption, reduced system cost small memory size, limited processing capability CN310 Microprocessor Systems Design 5 / 52

Microcontroller - Common Features processor core volatile memory (i.e. RAM) for data storage non-volatile memory (e.g. ROM, EEPROM, Flash) for program storage programmable general purpose I/O (GPIO) serial communications interfaces e.g. UART, I 2 C, SPI, CAN peripherals such as timer/counter pulse width modulator (PWM) clock generation analogue-to-digital converter ADC digital-to-analogue converter DAC watchdog CN310 Microprocessor Systems Design 6 / 52

AVR Architecture AVR core Memory: Flash RAM EEPROM Clock generator Peripherals: USART Timers SPI/TWI ADC Multiplexed I/O ports Support components: watchdog JTAG power monitoring CN310 Microprocessor Systems Design 7 / 52

Microcontroller Circuits Minimal microcontroller circuit includes: Supply voltage + ground Oscillator (if using external clock source) Reset circuit (a) Supply (b) Oscillator (c) Reset Circuit CN310 Microprocessor Systems Design 8 / 52

Microcontroller Circuits - Maximum Ratings Microcontroller interfacing circuit must consider MCU limitations on electrical properties. Voltage limit e.g. max 6.0V of operating voltage. Current limit e.g. max 40.0 ma of DC Current per I/O Pin. CN310 Microprocessor Systems Design 9 / 52

Microcontroller Circuits - Signal Conditioning Many applications require the interfacing between MCU and external circuits and/or ICs. Use appropriate interface circuits to perform signal conditioning before digital or analog I/O. CN310 Microprocessor Systems Design 10 / 52

Microcontroller Circuits - Extend Capability MCU usually does not have enough capability for direct control over several devices. Smart ICs are used to enhance I/O features using commands/data through communication interface. CN310 Microprocessor Systems Design 11 / 52

Microcontroller Circuits - Some Physical Problem Some physical phenomena may cause unstable results in software execution. Bouncing effect happens when pressing mechanical switch. Software understands as multiple, very fast pressings. Switch debouncing is hardware or software solution to suppress bouncing effect. CN310 Microprocessor Systems Design 12 / 52

Arduino Circuits - Schematic Arduino circuit relies on all-in-one features of AVR chip to minimize electronic parts. AVR MCU = reset circuit + 16MHz oscillator + ISP header FT232R = USB-to-UART interface chip + 5V supply Easy168 STAMP schematic CN310 Microprocessor Systems Design 13 / 52

Arduino-ATMega168 Pin Mapping CN310 Microprocessor Systems Design 14 / 52

Review of AVR Architecture AVR is a modified Harvard architecture 8-bit RISC microcontroller with 16-bit addressing (64K address space). Program memory: pc[0:15] inst[0:15] I/O registers: adr[0:5] iore iowe Data memory: ramadr[0:15] ramre ramwe dbusin[0:7] dbusout[0:7] CN310 Microprocessor Systems Design 15 / 52

Memory Map To refer to entities as variables, software side tends to abstract everything as memory (data, address, read/write). Code = instructions accessed by fetch-decode-execute cycle Harvard arch. may have instructions to retrieve constants from program memory, e.g. LPM Data = value within memory accessed by instruction execution, e.g. LDD, STD Hardware = value accessed by separate I/O bus, e.g. IN,OUT Memory map shows the location and range of each memory portion. Software can not access value within cache memory since it is handled by hardware. CN310 Microprocessor Systems Design 16 / 52

AVR Memory Map - Program Memory Each memory location is 16-bit wide. Application Flash section Boot Flash Section BOOTSTART depends on boot size 1 set in fuse bits (BOOTSZ1:0) and MCU model FLASHEND 2 depends on MCU model CN310 Microprocessor Systems Design 17 / 52

AVR Memory Map - Data Memory Each memory location is 8-bit wide. 32 general purpose registers: 0x00:0x1F I/O address space: 0x20:0x5F = 64 I/O registers 0x60:0xFF = extended 160 I/O registers Internal SRAM: 0x0100:RAMEND 3, depending on MCU model CN310 Microprocessor Systems Design 18 / 52

AVR Memory Map - EEPROM Each memory location is 8-bit wide. E2END 4 depends on MCU model CN310 Microprocessor Systems Design 19 / 52

I/O Registers Hardware operation and configuration are performed via a group of hardware registers, or I/O registers, or special-function registers. I/O registers are not included with processor core. I/O registers are contained in a specific range in memory, accessible by instructions. Some processors offer specific instructions to access I/O registers. MCU manufacturers tend to name each I/O register, and define them as constants in compiler library. Therefore, no need to remember. CN310 Microprocessor Systems Design 20 / 52

I/O Registers Value contained in I/O registers may be bits, word, or more than words, depending on hardware characteristics. Basic operations (word or bit access) of I/O registers are Read = get status/data Write = set mode/activation Toggle = change mode/operation I/O registers related to an I/O operation Data registers = data to/from hardware. Control registers = operations/modes which can be configured. Status registers = status of hardware operations. No need to remember I/O registers, since it is different for each MCU or even each model (hardware dependent). CN310 Microprocessor Systems Design 21 / 52

Accessing I/O Registers Depending on compiler tools, registers are usually accessed through defined names (available from header files in C) which normally are the same as register names specified in their datasheets. Example: 4.1 #include <avr/io.h> #include <util/delay.h> void main (void) { } DDRB = 0xFF; while (1) { } PORTB = 0xAA; _delay_ms(1000); PORTB = 0x55; _delay_ms(1000); // set PORT B for output // set PORT B bit 2 (PB2) // clear PORT B bit 2 (PB2) CN310 Microprocessor Systems Design 22 / 52

Digital I/O Digital I/O is the basic I/O feature, available for every MCU. A port is a grouping of 8/16/32 related I/O pins. Access in byte or word via I/O register. Each pin can be set (1) or cleared (0) according to related bit in I/O register. Ports may be input only, output only, or input-output (bidirectional). In input mode, pin status is high impedance. In output mode, pin drives voltage according to 0/1 status. CN310 Microprocessor Systems Design 23 / 52

I/O Ports Pin functions are controlled by I/O port registers. Digital I/O ports: Input mode: high-impedance Output mode: high/low AVR port pin configurations CN310 Microprocessor Systems Design 24 / 52

Pushbutton and LED - Arduino Example: 4.2 int ledpin = 13; int inputpin = 2; int val = 0; void setup() { pinmode(ledpin, OUTPUT); pinmode(inputpin, INPUT); } void loop() { val = digitalread(inputpin); if (val == HIGH) { digitalwrite(ledpin, LOW); } else { digitalwrite(ledpin, HIGH); } } CN310 Microprocessor Systems Design 25 / 52

Pushbutton and LED - Port Registers Example: 4.3 int val = 0; void setup() { DDRB = (1<<PB5); DDRD &= ~(1<<PD2); //PORTD = (1<<PD2); } void loop() { val = PIND & (1<<PD2); if (val == (1<<PD2)) { PORTB &= ~(1<<PB5); } else { PORTB = (1<<PB5); } } CN310 Microprocessor Systems Design 26 / 52

I/O Ports: Alternate functions Alternate peripheral connections: ADC voltage inputs Timer timing signals Input capture (counter) pulse signals Serial interface pulse train signals CN310 Microprocessor Systems Design 27 / 52

Microcontroller Bus Processor core connects to other components within MCU through bus. System bus = access to memory, faster means more execution performace. Peripheral bus = access to I/O devices via I/O bus, frequency is limited. External bus = extend processor bus (data/address/control) to external pins. In addition to data/address/control, MCU bus also provides clock signal to drive other digital components. CN310 Microprocessor Systems Design 28 / 52

Microcontroller Clock Most microcontrollers provide flexibility of clock options to match with various applications. Choices of clock sources, internal or external. The ratio for frequency prescaler of each bus. AVR s CKSEL3:0 fuse bits to select clock sources I/O clock (clk I/O ) is used by almost MCU peripherals. CN310 Microprocessor Systems Design 29 / 52

Microcontroller Clock CN310 Microprocessor Systems Design 30 / 52

AVR Fuses Fuses are used to configure important system parameters, such as clock setting. Fuse value (bits/bytes) is changed during each chip programming Incorrect fuse programming may render chip unusable CN310 Microprocessor Systems Design 31 / 52

Microcontroller Datasheet What contents are contained in the MCU datasheet: Features Packaging = pin layouts Structure as block diagram Memory map = ROM/RAM + register mapping Explanation of I/O registers. Instruction summary. Electrical and physical characteristics. CN310 Microprocessor Systems Design 32 / 52

Microcontroller Datasheet What contents are contained in the MCU datasheet: Packaging = pin layouts CN310 Microprocessor Systems Design 33 / 52

Microcontroller Selection There are several criteria in the selection of microcontroller to be used in products. Required MCU resource: On-chip peripherals. Number and type of I/O ports Memory = flash + RAM + EEPROM Production criteria: MCU packaging Operating temperature Development concerns: Familiarity with MCU/tools Company support CN310 Microprocessor Systems Design 34 / 52

Microcontroller Selection There are several criteria in the selection of microcontroller to be used in products. CN310 Microprocessor Systems Design 35 / 52

Microcontroller Selection There are several criteria in the selection of microcontroller to be used in products. CN310 Microprocessor Systems Design 36 / 52

Microcontroller Selection There are several criteria in the selection of microcontroller to be used in products. CN310 Microprocessor Systems Design 37 / 52

Microcontroller Peripherals MCU peripherals are on-chip components that provides I/O features: Timing generation. Analog I/O. Communication interface. Normally, on-chip peripherals are connected to processor core via peripheral bus. Asynchronously. At lower clock frequency. CN310 Microprocessor Systems Design 38 / 52

Peripherals Microcontroller peripherals mostly are digital components. Peripherals usually operate at the chip s voltage level. I/O pins should operate up to Vcc. To connect 3.3V device with 5V device, those I/O pins must be 5V-tolerance I/O. Each peripheral operates independently from processor core. Program execution can not predict what happen outside processor core. Peripherals use interrupt to notify important events. Peripherals usually operate at lower clock frequency compared to memory clock. Peripheral bus provide common I/O clock that is prescaled from system clock. Some peripherals may have internal prescaler to further divide clock frequency. CN310 Microprocessor Systems Design 39 / 52

Timer/Counter Timer/counter is an on-chip component providing features related to time and frequency. Counter register = core component. Clock source: Internal timer External event counter Control logic: count / clear / direction. Counting criteria: Match values. Reload value. CN310 Microprocessor Systems Design 40 / 52

Timer Operations Timer mode feeds scaled clock signal from internal bus, as timebase, into the counter. Main applications of timer mode are high-resolution clock/alarm or to generate various timing signals. Free-running counter. Periodic alarm. Pulse-width modulation. CN310 Microprocessor Systems Design 41 / 52

Counter Operations Counter mode counts number of pulses, converted from external signal using edge detection circuit. Main applications of counter mode are measuring of timing or frequency properties of signal. Period measurement. Frequency counter. CN310 Microprocessor Systems Design 42 / 52

Timer Applications One application of timer/counter units is to generate timing signals, e.g. pulse-width modulation. CN310 Microprocessor Systems Design 43 / 52

Serial Interface Serial interface, i.e. the transmission/reception of bit sequence, is used for communicating between computing devices, i.e. computers, MCUs, smart ICs. Shift buffer Clock signal separate sync Comm. criteria: Finished events. Error events. CN310 Microprocessor Systems Design 44 / 52

Serial Interface Asynchronous: no clock to reference. Universal Asynchronous Receiver Transceiver (UART) Controller Area Network (CAN): car engine network. Synchronous: reference to clock signal. Serial Peripheral Interface (SPI) Inter-Integrated Circuit (I2C) CN310 Microprocessor Systems Design 45 / 52

UART Operations Basic usage of UART is to transmit the bit sequence of data to another end point. Baud rate is configured by prescaling clock signal. UART hardware takes care of transmission/reception of data bits within buffers. Transmit buffer: data bits to be transmitted. Receive buffer: data bits from last completed frame. There are 3 pins: Tx, Rx, Gnd. CN310 Microprocessor Systems Design 46 / 52

UART Applications Main applications of MCU s UART is to communicate with computer (via terminal software), or smart ICs. Report status from device to computer. Get data from device to computer. Example: 4.4 void setup() { Serial.begin(9600); } void loop() { Serial.println("Hello, world\n"); delay(1000); } CN310 Microprocessor Systems Design 47 / 52

Analog-to-Digital Converter ADC converts analog signal into n-bit digital values by sampling voltage, then quantizing into number. Input range (voltage): 0 - ref voltage (A ref ). Output range (number): 0-2 n, n is resolution. number = v in A ref 2 n Multiple input channels via multiplexer. CN310 Microprocessor Systems Design 48 / 52

Analog-to-Digital Converter CN310 Microprocessor Systems Design 49 / 52

ADC Operations 1 Configure clock source by prescaling clock signal. 2 Select input channel. 3 Start conversion. Conversion time of ADC depends on clock frequency. 4 Read data from buffer when conversion finished. Observing the status of conversion flag. CN310 Microprocessor Systems Design 50 / 52

ADC Applications ADC is commonly used in sensor measurement, which requires periodic sampling of voltage. Main loop: 1 Configure clock source and input channel. 2 Do measurement loops: 1 Start ADC conversion. 2 Wait until conversion finish. 3 Read value. 4 Delay for fixed period. Main loop: 1 Configure clock source and input channel. 2 Setup periodic timer handler. Timer handler: 1 Start ADC conversion. 2 Wait until conversion finish. 3 Copy data to buffer. CN310 Microprocessor Systems Design 51 / 52

ADC Applications Example: 4.5 int lightpin = 0, ledpin = 9; void setup() { pinmode(ledpin, OUTPUT); } void loop() { int level; level = analogread(lightpin); analogwrite(ledpin, level); delay(1000); } CN310 Microprocessor Systems Design 52 / 52