EE 308: Microcontrollers

Similar documents
EE 308: Microcontrollers

EE 308: Microcontrollers

EE 308: Microcontrollers

Microcontroller VU

EE 308: Microcontrollers

AVR Microcontrollers Architecture

Microprocessors And Microcontrollers (Practical)

PIC Microcontroller and

EE 308: Microcontrollers

Module 2: Introduction to AVR ATmega 32 Architecture

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

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

EE 308: Microcontrollers

Microprocessors And Microcontroller

2011 Pearson Higher Education, Mazidi, Naimi, and Naimi Pearson Higher Education, 2011 Pearson Higher Education,

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

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

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

Programming Microcontroller Assembly and C

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

ECE 471 Embedded Systems Lecture 2

Choosing a Micro for an Embedded System Application

ET-BASE AVR ATmega64/128

ELC4438: Embedded System Design Embedded Processor

ATmega128. Introduction

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

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

Basic Components of Digital Computer

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

MICROPROCESSOR BASED SYSTEM DESIGN

Introduction to Microcontrollers

Installation and Maintenance

Somes French translations :

Distributed Real- Time Control Systems

Microcontroller systems Lec 2 PIC18LF8722 Microcontroller s s core

AVR MICROCONTROLLER ARCHITECTURTE

ARDUINO MEGA INTRODUCTION

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

WIZTECH AUTOMATION SOLUTIONS (P) LTD., An ISO 9001:2000 and IAO certified company

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

Fig 1. Block diagram of a microcomputer

MICROCONTROLLERS 8051

Lecture 1. Course Overview and The 8051 Architecture

Chapter 1. Microcontroller Overview

This week we will learn about embedded programming. The agenda:

ELCT 912: Advanced Embedded Systems

Embedded Systems Design (630414) Lecture 1 Introduction to Embedded Systems Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Microcontrollers. Microcontroller

EE 308: Microcontrollers

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

ME 515 Mechatronics. A microprocessor

Lecture (01) Introducing Embedded Systems and the Microcontrollers By: Dr. Ahmed ElShafee

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

Microprocessors/Microcontrollers

ELCT708 MicroLab Session #1 Introduction to Embedded Systems and Microcontrollers. Eng. Salma Hesham

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

Embedded System Project (521423S) - Specifications

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

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Embedded programming, AVR intro

HCS12 Microcontroller and Embedded Systems: Using Assembly and C with CodeWarrior 1 st Edition

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

CN310 Microprocessor Systems Design

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

CHAPTER 2: AVR ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING

PART 1 : MR-162. PART 2 : CPU Board. PART 3 : Software Tools. PART 4 : Compile and Download. 1. Introduction 2. Features

MECE336 Microprocessors I

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

An Arduino Controlled 1 Hz to 60 MHz Signal Generator

Microcontroller: CPU and Memory

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

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

Arduino Uno R3 INTRODUCTION

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

Lecture 2. Introduction to Microcontrollers

AVR ISA & AVR Programming (I)

Introduction to Microcontrollers

Low-Cost Microcontrollers

Digital Homebrewing. Bob Okas W3CD. Copyright 2004 Robert P. Okas

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Microcontroller basics

Development Tools. 8-Bit Development Tools. Development Tools. AVR Development Tools

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

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

LED Matrix Scrolling using ATmega32 microcontroller

Embedded Systems and Software

TKT-3500 Microcontroller systems

8051 MICROCONTROLLERS

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

CN310 Microprocessor Systems Design

3.3V regulator. JA H-bridge. Doc: page 1 of 7

BASIC INTERFACING CONCEPTS

Getting Started with STK200 Dragon

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

Embedded Systems. Computer Organization. Wednesday 25 November 15

Introduction to Arduino. Wilson Wingston Sharon

OUTLINE. STM32F0 Architecture Overview STM32F0 Core Motivation for RISC and Pipelining Cortex-M0 Programming Model Toolchain and Project Structure

(Embedded) Systems Programming Overview

Doc: page 1 of 6

Transcription:

EE 308: Microcontrollers Introduction Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 6, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 1 / 23

What are microcontrollers? A microcontroller is a processor with memory and several other components integrated on a a single chip making it perfect for a variety of applications covering a wide range, e.g., coffee machines, automotive industry, communications, defense systems, satellites, etc. Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 2 / 23

Differences between microcontrollers and microprocessor Microcontroller Microprocessor CPU SRAM EEPROM/ Flash Timer/ Counter CPU SRAM EEPROM/ Flash Timer/ Counter Digital I/O module Serial interface ADC Other peripherals General Purpose Microprocessor Serial interface ADC Digital I/O module Microcontroller Contains a processor Has memory and I/O modules integrated on the same chip Compact Cheap Small power consumption Processor is standalone, memory and I/O modules are seperate Designer can choose components for memory and I/O High processing power General purpose Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 3 / 23

Variety of microcontroller manufacturers 68HC11/12 Freescale Semiconductors s (Formerly Motorola) 8051 Intel AVR Atmel Z8 Zilog PIC Microchip Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 4 / 23

Evaluation boards BigAVR6 Dragon12 Plus ATtiny85 Zilog Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 5 / 23

Embedded systems Control unit performed by a microcontroller is integrated into the system. Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 6 / 23

Mechatronics Integration for mechanical systems with electronics and information processing. Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 7 / 23

Factors to consider Capability of meeting the specification of the task at hand Speed Packaging Power consumption Amount of memory Number of I/O pins Upgradability Cost Development tools Availability Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 8 / 23

CISC vs RISC Complex Instruction Set Computer (CISC) Larger architecture Variable code size Powerful instruction set Requires several clock cycles to execute instructions Reduced Instruction Set Computer (RISC) Simple architecture Small set of instructions One or few clock cycles to execute instructions Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 9 / 23

Von Neumann vs Harvard Von Neumann Harvard Code memory Data memory data bus data bus CPU data bus address bus control bus Code memory control bus CPU control bus Data memory address bus address bus Von Neumann architecture Harvard architecture Code and data are accessed through the same bus Results in a bottle neck since we can t access code and data at the same time More delays Separate buses for accessing code and data Faster Less delays Requires more hardware Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 10 / 23

AVR Core RISC with Harvard architecture Code ROM Data RAM Data EEPROM Timers I/O ports ADC PWM Communication interfaces: USART, SPI, I2C (TWI), CAN, USB Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 11 / 23

Atmega1284 RISC architecture 131 instructions (most executes in single clock cycle) 128K bytes code ROM 4K bytes EEPROM 16K bytes SRAM JTAG Timers/counters, PWM, 8-channel 10bit ADC Watchdog timer USART, SPI, I2C Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 12 / 23

Atmega1284 PDIP Package This will be the chip used through out the semester. Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 13 / 23

Reasons for using assembly More efficient use of computing power and memory Closer to the hardware If mass production is the goal, then there will be money saving by going to smaller cheaper parts Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 14 / 23

Assembly language Assembly language consists of, instructions referred to as mnemonics, directives and labels.. INCLUDE " M1284DEF. INC " LDI R16, hi8 ( RAMEND ) OUT SPH, R16 LDI R16, lo8 ( RAMEND ) 5 OUT SPL, R16 ;initialize stack pointer SBI DDRC, 0 ;set bit 0 of DDRC HERE : SBI PORTC, 0 10 CALL DELAY ;call DELAY subroutine CBI PORTC, 0 CALL DELAY RJMP HERE 15 DELAY : LDI R20, 255 DL1 : DEC R20 BRNE DL1 RET Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 15 / 23

Assembly language Assembly language consists of, instructions referred to as mnemonics, directives and labels.. INCLUDE " M1284DEF. INC " LDI R16, hi8 ( RAMEND ) OUT SPH, R16 LDI R16, lo8 ( RAMEND ) 5 OUT SPL, R16 ;initialize stack pointer SBI DDRC, 0 ;set bit 0 of DDRC HERE : SBI PORTC, 0 10 CALL DELAY ;call DELAY subroutine CBI PORTC, 0 CALL DELAY RJMP HERE 15 DELAY : LDI R20, 255 DL1 : DEC R20 BRNE DL1 RET Directive Label Comment Instruction Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 15 / 23

Software tools GNU AVR toolchain (will be used in lectures) Free Open source Linux and Windows (WinAVR) Arduino IDE is based on it Requires a bit more effort to make it work Atmel Studio (mostly used in the lab) Free Supports all their products Runs only on Windows Has and additional assembler (used by default): avrasm2 Can t handle mixed C and assembly, and relies on GCC to do that Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 16 / 23

What to download on the microcontroller Assembler replaces mnemonics by their opcodes, resolves include directives, translates register names to addresses, removes comments, etc. avr-as -mmcu=atmega1284 -o ex.o ex.s Linker links multiple files avr-ld -mavr51 -o ex.elf ex.o Translate object files avr-objcopy -j.text -j.data -O ihex -o ex.hex ex.elf Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 17 / 23

Intel Hex vs S19 Intel Hex :1000000000E40EBF0FEF0DBF389A409A0E940C001B :1000100040980E940C00F9CF4FEF4A95F1F70895F0 :00000001FF Motorola S19 S01100006578616D706C65345F332E686578C9 S113000000E40EBF0FEF0DBF389A409A0E940C0017 S113001040980E940C00F9CF4FEF4A95F1F70895EC S9030000FC Start code (:) Byte count data only (2 characters) Address (4 characters) Record type (2 characters) 00 data record 01 end of file Data (2k characters) Checksum (2 characters) Record type (2 characters) S0 Block header S1-3 Data records S5 Record count S7-9 End of block Byte count (2 characters) Address + Data + Checksum Address (4 characters) Data (2k characters) Checksum (2 characters) Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 18 / 23

Downloading the hex file avrdude -v -c dragon_jtag -p m1284 -Pusb -U flash:w:ex.hex Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 19 / 23

avr-as vs avrasm2 There are differences between the GCC assembler and the one used by Atmel. For full list you need to consult the documentation but below are some of the frequently used ones. avr-as.equ DDRA, 0x01.asciz hello.section.data.section.text hi8 lo8 avrasm2.equ DDRA = 0x01.db hello,0.dseg.cseg high low Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 20 / 23

Programmer Prototyping area Programming Interfaces SPI High Voltage Serial Parallel JTAG PDI awire Debugging Interfaces JTAG debugwire PDI awire Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 21 / 23

Makefile FILENAME MCU PARTNO ARCH PORT PROGRAMMER AS LD OBJCOPY PROG ASFLAGS LDFLAGS OBJFLAGS PRFLAGS = example = atmega1284 = m1284 = avr51 = usb = dragon_jtag = avr-as = avr-ld = avr-objcopy = avrdude = -mmcu=$(mcu) --gstabs = -m$(arch) = -j.text -j.data -O ihex = -v -c $(PROGRAMMER) -p $(PARTNO) -P$(PORT).PHONY: all install clean all: $(FILENAME).hex $(FILENAME).o $(FILENAME).elf %.o: %.s $(AS) $(ASFLAGS) -o $@ $< %.elf: %.o $(LD) $(LDFLAGS) -o $@ $< %.hex: %.elf $(OBJCOPY) $(OBJFLAGS) $< $@ install: $(FILENAME).hex $(PROG) $(PRFLAGS) -U flash:w:$< clean: rm -f $(FILENAME).hex $(FILENAME).elf $(FILENAME).o Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 22 / 23

Arduino environment Free package Arduino language implemented in C/C++ Lots of libraries A lot of copy/paste Hides a lot of the details and therefore Makes you lazy Optimization requires extensive redesign of code Resulting code may not operate under strict timing, memory, power requirements Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 23 / 23

Arduino environment Free package Arduino language implemented in C/C++ Lots of libraries A lot of copy/paste Hides a lot of the details and therefore Makes you lazy Optimization requires extensive redesign of code Resulting code may not operate under strict timing, memory, power requirements As an engineer, specifically an embedded systems engineer, you must understand enough about what you are designing, standards and specifications, and have the ability to validate and verify your design. The Arduino environment may not give you the ability to do so. Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 23 / 23

Arduino environment Free package Arduino language implemented in C/C++ Lots of libraries A lot of copy/paste Hides a lot of the details and therefore Makes you lazy Optimization requires extensive redesign of code Resulting code may not operate under strict timing, memory, power requirements As an engineer, specifically an embedded systems engineer, you must understand enough about what you are designing, standards and specifications, and have the ability to validate and verify your design. The Arduino environment may not give you the ability to do so. Very useful to non-technical users, hobbyists, students (K-12), but highly questionable for critical engineering designs Aly El-Osery (NMT) EE 308: Microcontrollers January 6, 2018 23 / 23