EE 319K Introduction to Embedded Systems

Slides:



Advertisements
Similar presentations
ARM versions ARM architecture has been extended over several versions.
Advertisements

Embedded Systems Programming
Appendix D The ARM Processor
Overheads for Computers as Components 2nd ed.
1 ARM Movement Instructions u MOV Rd, ; updates N, Z, C Rd = u MVN Rd, ; Rd = 0xF..F EOR.
4-1 EE 319K Introduction to Embedded Systems Lecture 4: Arithmetic overflow, Branches, Control Structures, Abstraction & Refinement Bard, Erez, Gerstlauer,
© 2000 Morgan Kaufman Overheads for Computers as Components ARM instruction set zARM versions. zARM assembly language. zARM programming model. zARM memory.
Chapter 2 Instruction Sets 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)
1-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Microcontrollers Lecture 1: Introduction, Embedded Systems, Product Life-Cycle, ARM Programming.
Topics covered: ARM Instruction Set Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
Railway Foundation Electronic, Electrical and Processor Engineering.
EE 319K Introduction to Embedded Systems
ARM Core Architecture. Common ARM Cortex Core In the case of ARM-based microcontrollers a company named ARM Holdings designs the core and licenses it.
2-1 EE 319K Introduction to Embedded Systems Lecture 2: I/O, Logic/Shift Operations, Addressing modes, Memory Operations, Subroutines, Introduction to.
ARM Instructions I Prof. Taeweon Suh Computer Science Education Korea University.
Embedded System Design Center Sai Kumar Devulapalli ARM7TDMI Microprocessor Thumb Instruction Set.
Atmega32 Architectural Overview
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
Lecture 2: Basic Instructions CS 2011 Fall 2014, Dr. Rozier.
ECS642U Embedded Systems ARM CPU and Assembly Code William Marsh.
Ch.2 Intro. To Assembly Language Programming
EE 319K Introduction to Embedded Systems
Unit-2 Instruction Sets, CPUs
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
ARM Shifts, Multiplies & Divide??. MVN Pseudo Instructions Pseudo Intruction: Supported by assembler, not be hardware.
Intel Xscale® Assembly Language and C. The Intel Xscale® Programmer’s Model (1) (We will not be using the Thumb instruction set.) Memory Formats –We will.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Intel Xscale® Assembly Language and C. The Intel Xscale® Programmer’s Model (1) (We will not be using the Thumb instruction set.) Memory Formats –We will.
Revision questions CENG2400 v.14b 1 CENG2400 Revision, Question 1 A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module.
Introduction to Microcontrollers
ECE 3430 – Intro to Microcomputer Systems
Format of Assembly language
Atmega32 Architectural Overview
Chapter 4 Copying Data.
Control Unit Lecture 6.
Chapter 5 Integer Arithmetic.
Microprocessor Systems Design I
UNIT – Microcontroller.
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
ECE 3430 – Intro to Microcomputer Systems
Assembly Language Assembly Language
The Cortex-M3/m4 Embedded Systems: Cortex-M3/M4 Instruction Sets
8086 Microprocessor.
Introduction of microprocessor
Chapter 4 Addressing modes
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Prof. Sirer CS 316 Cornell University
William Stallings Computer Organization and Architecture 8th Edition
The University of Adelaide, School of Computer Science
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
The LC-3 Instruction Set Architecture Data Movement instructions
Introduction to Microprocessors and Microcontrollers
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
Chapter 8 Central Processing Unit
Unit – Microcontroller Tutorial Class - 2 ANITS College
Multiplication by small constants (pp. 139 – 140)
Important 8051 Features On chip oscillator 4K bytes ROM 128 bytes RAM
Introduction to Microprocessor Programming
EECE.3170 Microprocessor Systems Design I
ARM Introduction.
Overheads for Computers as Components 2nd ed.
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
CS501 Advanced Computer Architecture
Introduction to Assembly Chapter 2
Computer Operation 6/22/2019.
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

EE 319K Introduction to Embedded Systems Lecture 2: ARM Assembly, More I/O, Switch and LED interfacing Bard, Gerstlauer, Valvano, Yerraballi

Agenda Outline Assembly – ARM ISA Reset Specifics Digital Logic GPIO TM4C123/LM4F120 Specifics Switch and LED interfacing Bard, Gerstlauer, Valvano, Yerraballi

ARM Assembly Language Assembly format Comments Label Opcode Operands Comment init MOV R0, #100 ; set table size BX LR Comments Comments should explain why or how Comments should not explain the opcode and its operands Comments are a major component of self-documenting code What does BX LR do? Bard, Gerstlauer, Valvano, Yerraballi

Simple Addressing Modes Second operand - <op2> ADD Rd, Rn, <op2> Constant ADD Rd, Rn, #constant ; Rd = Rn+constant Shift ADD R0, R1, LSL #4 ; R0 = R0+(R1*16) ADD R0, R1, R2, ASR #4 ; R0 = R1+(R2/16) Memory accessed only with LDR STR Constant in ROM: =Constant / [PC,#offs] Variable on the stack: [SP,#offs] Global variable in RAM: [Rx] I/O port: [Rx] Bard, Gerstlauer, Valvano, Yerraballi

Addressing Modes Immediate addressing Data is contained in the instruction MOV R0,#100 ; R0=100, immediate addressing List two ways to bring a constant into a register? Bard, Gerstlauer, Valvano, Yerraballi

Addressing Modes Indexed Addressing Address of the data in memory is in a register LDR R0,[R1] ; R0= value pointed to by R1 Is the number 0x20000004 in general? In this example Bard, Gerstlauer, Valvano, Yerraballi

Addressing Modes PC Relative Addressing Address of data in EEPROM is indexed based upon the Program Counter The Cortex-M3 has a 32-bit address space Instructions are at most 32 bits long => there is not enough space in an instruction for an address EEPROM accesses can be indexed using the program counter The PC always points to EEPROM and it can be used to calculate an address relative to the value in the PC RAM accesses involve storing the address in EEPROM and then accessing it using indexed addressing relative to the PC Two instructions will typically be required to access RAM or I/O Bard, Gerstlauer, Valvano, Yerraballi

Memory Access Instructions Loading a register with a constant, address, or data LDR Rd, =number LDR Rd, =label LDR and STR used to load/store RAM using register-indexed addressing Register [R0] Base address plus offset [R0,#16] ADR Rd,val is a pseudo-op that gets assembled into ADD Rd,PC,#offs Can only load values that are addresses (relative to PC) Offset is 8 bit, i.e. address must be within 255 bytes of PC LDR Rd,=val is a pseudo-op that gets assembled into either a MOV Rd,#val or a constant in ROM with LDR Rd,[pc,#offs] Can be any constant (number/value) or address Bard, Gerstlauer, Valvano, Yerraballi

Load/Store Instructions General load/store instruction format LDR{type} Rd,[Rn] ;load memory at [Rn] to Rd STR{type} Rt,[Rn] ;store Rt to memory at [Rn] LDR{type} Rd,[Rn, #n] ;load memory at [Rn+n] to Rd STR{type} Rt,[Rn, #n] ;store Rt to memory [Rn+n] LDR{type} Rd,[Rn,Rm,LSL #n] ;load [Rn+Rm<<n] to Rd STR{type} Rt,[Rn,Rm,LSL #n] ;store Rt to [Rn+Rm<<n] Aligned/Unaligned Memory Access Aligned word-aligned address is used for a word, dual word, or multiple word access, or where a halfword-aligned address is used for a halfword access Unaligned accessing a 32-bit object (4 bytes) but the address is not evenly divisible by 4 accessing a 16-bit object (2 bytes) but the address is not evenly divisible by 2 Unaligned access supported for the following instructions: LDR Load 32-bit word LDRH Load 16-bit unsigned halfword LDRSH Load 16-bit signed halfword (sign-extend bit 15 to bits 31-16) STR Store 32-bit word STRH Store 16-bit halfword Bard, Gerstlauer, Valvano, Yerraballi

ARM ISA : ADD, SUB and CMP ARITHMETIC INSTRUCTIONS ADD{S} {Rd,} Rn, <op2> ;Rd = Rn + op2 ADD{S} {Rd,} Rn, #im12 ;Rd = Rn + im12 SUB{S} {Rd,} Rn, <op2> ;Rd = Rn - op2 SUB{S} {Rd,} Rn, #im12 ;Rd = Rn - im12 RSB{S} {Rd,} Rn, <op2> ;Rd = op2 - Rn RSB{S} {Rd,} Rn, #im12 ;Rd = im12 - Rn CMP Rn, <op2> ;Rn - op2 CMN Rn, <op2> ;Rn - (-op2) ‘S’ variants: set condition codes (default: not set) Addition C bit set if unsigned overflow V bit set if signed overflow Subtraction C bit clear if unsigned overflow V bit set if signed overflow Bard, Gerstlauer, Valvano, Yerraballi

ARM ISA : Multiply and Divide 32-BIT MULTIPLY/DIVIDE INSTRUCTIONS MUL{S} {Rd,} Rn, Rm ;Rd = Rn * Rm MLA Rd, Rn, Rm, Ra ;Rd = Ra + Rn*Rm MLS Rd, Rn, Rm, Ra ;Rd = Ra - Rn*Rm UDIV {Rd,} Rn, Rm ;Rd = Rn/Rm unsigned SDIV {Rd,} Rn, Rm ;Rd = Rn/Rm signed Multiplication does not set C,V bits MULS sets N and Z, but not C and V. Bard, Gerstlauer, Valvano, Yerraballi

Input/Output: TM4C123 6 General-Purpose I/O (GPIO) ports: Four 8-bit ports (A, B, C, D) One 6-bit port (E) One 5-bit port (F) Bard, Gerstlauer, Valvano, Yerraballi 12

TM4C123 I/O Pins I/O Pin Characteristics Set AFSEL to 0 Can be employed as an n-bit parallel interface Pins also provide alternative functions: UART Universal asynchronous receiver/transmitter SSI Synchronous serial interface I2C Inter-integrated circuit Timer Periodic interrupts, input capture, and output compare PWM Pulse width modulation ADC Analog to digital converter, measure analog signals Analog Compare two analog signals Comparator QEI Quadrature encoder interface USB Universal serial bus Ethernet High speed network CAN Controller area network Set AFSEL to 0 Set AFSEL to 1 Bard, Gerstlauer, Valvano, Yerraballi

TM4C123 LaunchPad I/O Pins

TM4C123 I/O registers Four 8-bit ports (A, B, C, D) One 6-bit port (E) One 5-bit port (F) PA1-0 to COM port PC3-0 to debugger PD5-4 to USB device Bard, Gerstlauer, Valvano, Yerraballi 15

Reset, Subroutines and Stack A Reset occurs immediately after power is applied and when the reset signal is asserted (Reset button pressed) The Stack Pointer, SP (R13) is initialized at Reset to the 32-bit value at location 0 (Default: 0x20000408) The Program Counter, PC (R15) is initialized at Reset to the 32-bit value at location 4 (Reset Vector) The Link Register (R14) is initialized at Reset to 0xFFFFFFFF Thumb bit is set at Reset Processor automatically saves return address in LR when a subroutine call is invoked. User can push and pull multiple registers on or from the Stack at subroutine entry and before subroutine return. Bard, Gerstlauer, Valvano, Yerraballi

Switch Configuration positive – pressed = ‘1’ negative – pressed = ‘0’ Bard, Gerstlauer, Valvano, Yerraballi

Switch Configuration Positive Logic t Negative Logic s – pressed, 0V, false – not pressed, 3.3V, true Positive Logic t – pressed, 3.3V, true – not pressed, 0V, false Bard, Gerstlauer, Valvano, Yerraballi

LED Interfacing LED current v. voltage Brightness = power = V*I anode (+) cathode (1) “big voltage connects to big pin” Bard, Gerstlauer, Valvano, Yerraballi

LED Configuration Bard, Gerstlauer, Valvano, Yerraballi

LED Interfacing R = (3V – 1.5)/0.001 = 1.5 kOhm R = (5.0-2-0.5)/0.01 LED current < 8 ma LED current > 8 ma LED may contain several diodes in series Bard, Gerstlauer, Valvano, Yerraballi

LaunchPad Switches and LEDs The switches on the LaunchPad Negative logic Require internal pull-up (set bits in PUR) The PF3-1 LEDs are positive logic Bard, Gerstlauer, Valvano, Yerraballi

I/O Port Bit-Specific I/O Port bit-specific addressing is used to access port data register Define address offset as 4*2b, where b is the selected bit position 256 possible bit combinations (0-8) Add offsets for each bit selected to base address for the port Example: PF4 and PF0 Port F = 0x4005.D000 0x4005.D000+0x0004+0x0040 = 0x4005.D044 Provides friendly and atomic access to port pins Bard, Gerstlauer, Valvano, Yerraballi