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

Similar documents
The ARM Cortex-M0 Processor Architecture Part-1

Embedded System Design

ARM Cortex core microcontrollers

AND SOLUTION FIRST INTERNAL TEST

ARM Architecture and Assembly Programming Intro

ARM Cortex-M4 Programming Model

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

Interrupts and Low Power Features

Design and Implementation Interrupt Mechanism

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

Computer Organization Laboratory. Class Notes. Instructor: Ken Q. Yang Dept. of ECE, URI

Arm Cortex -M33 Devices

ARM architecture road map. NuMicro Overview of Cortex M. Cortex M Processor Family (2/3) All binary upwards compatible

Multitasking on Cortex-M(0) class MCU A deepdive into the Chromium-EC scheduler

ARM ARCHITECTURE. Contents at a glance:

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

ARM Cortex core microcontrollers 3. Cortex-M0, M4, M7

ELC4438: Embedded System Design ARM Cortex-M Architecture II

ARM Cortex -M for Beginners

EE4144: ARM Cortex-M Processor

ARM Interrupts. EE383: Introduction to Embedded Systems University of Kentucky. James E. Lumpp

ARM Processor Architecture

MICROPROCESSOR BASED SYSTEM DESIGN

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

ARM Cortex-M4 Architecture and Instruction Set 1: Architecture Overview

Troubleshooting Guide

Cortex-M4 Processor Overview. with ARM Processors and Architectures

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

Universität Dortmund. ARM Architecture

ECE 471 Embedded Systems Lecture 2

ARM Ltd. ! Founded in November 1990! Spun out of Acorn Computers

ARM Embedded Systems: ARM Design philosophy, Embedded System Hardware, Embedded System Software

Chapter 5. Introduction ARM Cortex series

RM3 - Cortex-M4 / Cortex-M4F implementation

Job Posting (Aug. 19) ECE 425. ARM7 Block Diagram. ARM Programming. Assembly Language Programming. ARM Architecture 9/7/2017. Microprocessor Systems

Processor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ARM Processors for Embedded Applications

The ARM Cortex-M0 Processor Architecture Part-2

introduction to interrupts

IoT and Security: ARM v8-m Architecture. Robert Boys Product Marketing DSG, ARM. Spring 2017: V 3.1

Processor Architecture

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan

Cortex-M3 Reference Manual

Microcontroller basics

Hercules ARM Cortex -R4 System Architecture. Processor Overview

Implementing Secure Software Systems on ARMv8-M Microcontrollers

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang

EE 308: Microcontrollers

Introduction to C. Write a main() function that swaps the contents of two integer variables x and y.

ARM. Cortex -M7 Devices. Generic User Guide. Copyright 2015 ARM. All rights reserved. ARM DUI 0646A (ID042815)

The Definitive Guide to the ARM Cortex-M3

Exception and fault checking on S32K1xx

ARM Cortex-M and RTOSs Are Meant for Each Other

Cortex-M Software Development

AVR Microcontrollers Architecture

What is Pipelining? Time per instruction on unpipelined machine Number of pipe stages

Chapter 15 ARM Architecture, Programming and Development Tools

Microcontrollers. Microcontroller


CISC RISC. Compiler. Compiler. Processor. Processor

This course provides an overview of the SH-2 32-bit RISC CPU core used in the popular SH-2 series microcontrollers

Application Note. Migrating from 8051 to Cortex Microcontrollers. Document number: ARM DAI 0237 Issued: July 2010 Copyright ARM Limited 2010

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 12 Processor Structure and Function

UNIT 2 (ECS-10CS72) VTU Question paper solutions

ARM Processors ARM ISA. ARM 1 in 1985 By 2001, more than 1 billion ARM processors shipped Widely used in many successful 32-bit embedded systems

Pipelining concepts The DLX architecture A simple DLX pipeline Pipeline Hazards and Solution to overcome

ECE332, Week 2, Lecture 3. September 5, 2007

ECE332, Week 2, Lecture 3

Computer Systems Architecture I. CSE 560M Lecture 5 Prof. Patrick Crowley

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

Overview of Computer Organization. Chapter 1 S. Dandamudi

VE7104/INTRODUCTION TO EMBEDDED CONTROLLERS UNIT III ARM BASED MICROCONTROLLERS

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Microcomputer Architecture and Programming

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Overview of Computer Organization. Outline

ARM CORTEX-R52. Target Audience: Engineers and technicians who develop SoCs and systems based on the ARM Cortex-R52 architecture.

References & Terminology

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan

Wed. Aug 23 Announcements

ECE251: Thursday September 27

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Interrupt/Timer/DMA 1

L2 - C language for Embedded MCUs

DC57 COMPUTER ORGANIZATION JUNE 2013

V8-uRISC 8-bit RISC Microprocessor AllianceCORE Facts Core Specifics VAutomation, Inc. Supported Devices/Resources Remaining I/O CLBs

RM4 - Cortex-M7 implementation

18-349: Embedded Real-Time Systems Lecture 2: ARM Architecture

Lab 4 Interrupt-driven operations

What is Pipelining. work is done at each stage. The work is not finished until it has passed through all stages.

ARM Cortex -M33 Processor User Guide

Microcontroller systems Lec 2 PIC18LF8722 Microcontroller s s core

ARM Cortex-M0 DesignStart Processor and v6-m Architecture. Joe Bungo ARM University Program Manager Americas/Europe R&D Division

Latches. IT 3123 Hardware and Software Concepts. Registers. The Little Man has Registers. Data Registers. Program Counter

COEN-4720 Embedded Systems Design Lecture 3 Intro to ARM Cortex-M3 (CM3) and LPC17xx MCU

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

MIPS Pipelining. Computer Organization Architectures for Embedded Computing. Wednesday 8 October 14

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

Transcription:

ARCHITECTURE AND PROGRAMMING George E Hadley, Timothy Rogers, and David G Meyer 2018, Images Property of their Respective Owners

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

THE ARM BUSINESS MODEL License Controls whole HW design stack Fab their own chips, so can beat the competition by getting to smaller transistors fastest Do not fab anything Only designs and sells IP Licenses their IP to other companies allow them to modify designs for $$$

STM32F0 OVERVIEW STM32F0 Top Level Block Diagram (from Figure 1 of STM32F051R8T6 Datasheet)

STM32F0 OVERVIEW Microcontroller Core

STM32F0 OVERVIEW Memory (SRAM and Flash)

STM32F0 OVERVIEW Reset and Clock Control

STM32F0 OVERVIEW Internal System Bus

STM32F0 OVERVIEW General-Purpose I/O (GPIO)

STM32F0 OVERVIEW Timer and Real Time Clock (RTC)

STM32F0 OVERVIEW ADC, DAC, and Comparators

STM32F0 OVERVIEW Universal Synchronous/Asynchronous Receiver/Transmitter (USART)

STM32F0 OVERVIEW Serial Peripheral Interface (SPI)

STM32F0 OVERVIEW Inter-Integrated Circuit (I 2 C)

STM32F0 CORE

STM32F0 CORE CPU: Central processor, executes instructions, performs embedded math, etc. JTAG: Programming/debug interface to processor Serial Wire: Programming/debug interface to processor Nested Vector Interrupt Controller (NVIC): Handles context switching, interrupt priorities, etc. Wake Up Interrupt Controller (WIC): Allows processor to wake up from low power operation from external stimuli Data Watchpoint: Used to keep track of register values Breakpoint Unit: Used to pause processor execution at specific locations in memory (used for debugging)

STM32F0 CORE The CPU is treated as a proprietary black box from ARM Design and implementation of processor cores is taught in ECE 437 Illustrative single-cycle (left) and pipelined (right) processor cores

MOTIVATION FOR RISC CISC (e.g., x86, 9S12) Large variety of op codes + addressing modes Variable length instructions More complicated HW Less complicated compilers Many multi-cycle instructions Better code density Difficult to pipeline RISC (e.g., ARM, PIC) Fewer operations + addressing modes Fixed size instructions Less complicated HW More complicated compilers Most instructions are singlecycle Worse code density Easier to pipeline

MOTIVATION FOR RISC Why Bother with RISC? 1. Simpler to decode 2. Simpler instructions = simpler hardware 3. Easier to pipeline WHY BOTHER WITH RISC?

MOTIVATION FOR PIPELINING Steps Required to Process a Machine Instruction 1. Get the instruction from memory (Fetch) 2. Figure out what the instruction does (Decode) 3. Do it! (Execute) What determines the maximum clock frequency of a digital circuit?

MOTIVATION FOR PIPELINING Single-Cycle Processor Core One Long Cycle

MOTIVATION FOR PIPELINING Pipelined Processor Core One Shorter Cycle

MOTIVATION FOR PIPELINING Pipelining Analogy 1st task Early in Time Later in Time Last task Simultaneous activity From 7:30 to 8:00 pm

MOTIVATION FOR PIPELINING Pipelining Instructions Clock Cycle Number 1 2 3 4 5 6 7 8 9 Instruction i IF ID EX MEM WB Instruction i+1 IF ID EX MEM WB Instruction i+2 IF ID EX MEM WB Instruction i+3 IF ID EX MEM WB Instruction i+4 IF ID EX MEM WB Improves instruction throughput. Once full, instructions finish at a rate of one/cycle.

MOTIVATION FOR PIPELINING Why Pipelining is Important Increases clock speed Allows for overlapped execution of instructions, therefore increasing hardware utilization All high performance processors are pipelined

MOTIVATION FOR PIPELINING Why Not Pipeline Indefinitely? Pipeline registers at each stage add additional latency setup/hold time of registers More hardware required for each stage Deeper pipelines are more sensitive to branch misprediction

MOTIVATION FOR PIPELINING An Ideal Pipeline Uniform Sub-computations Goal: Each stage has same delay Achieve by balancing pipeline stages Identical Computations Goal: Each computation uses same number of stages Achieve by unifying instruction types Independent Computations Goal: Avoid hazards Look for ways to minimize pipeline stalls

MOTIVATION FOR PIPELINING Dependencies I1: Add R3,R1,R2 I2: Add R4,R3,R5 I2 needs the results (stored in R3) from I1 Want both instructions to execute at the same time Might have to wait executing I2 until I1 has completed

MOTIVATION FOR PIPELINING How RISC Facilitates Pipelining Uniform Sub-computations Memory addressing modes <=> disparity of speed between processor and memory Identical Computations RISC: reducing complexity makes each instruction use roughly the same number of stages Independent Computations Reg-Reg ( Load-Store ): makes it easier to identify dependencies (versus Reg-Mem)

CORTEX-M0 PROGRAMMING MODEL High-Level Concepts ARMv6-M architecture supports multiple states, modes, and levels: Thumb State: general operating state Thread Mode: used when running normal code Privileged Level: full processor access Unprivileged Level: some memory regions and operations inaccessible (optional on Cortex-M0+, unavailable on Cortex-M0) Handler Mode: used when running exceptions Debug State: debugging stated, active when processor is halted by debugger

CORTEX-M0 PROGRAMMING MODEL High-Level Concepts

CORTEX-M0 PROGRAMMING MODEL Core Registers Cortex-M0 utilizes a load-store architecture (data is loaded to register from memory, processed, and then stored back to memory) Cortex-M0/M0+ feature sixteen 32-bit registers, as well as special registers: R0-R7 (low registers): general purpose, accessible by all instructions R8-R12 (high registers): general purpose, accessible by some instructions (such as MOV)

CORTEX-M0 PROGRAMMING MODEL Core Registers (Continued) R13 (SP): Stack pointer, used in push/pop instructions. References two physically distinct pointers: Main Stack Pointer (MSP): default stack pointer Process Stack Pointer (PSP): can be used in Thread mode R14 (LR): link register, contains return address from interrupt, subroutine, or function R15 (PC): program counter, tracks current memory location

CORTEX-M0 PROGRAMMING MODEL Core Registers (Continued) Combined Program Status Registers (xpsr): Provides information about program execution and arithmetic logic unit (ALU) flags. Consists of three separate registers: Application PSR (APSR): contains ALU flags (N,Z,C,V) Negative Flag (N): indicates result of last operation was negative Zero Flag (Z): indicates result of last operation was zero Carry Flag (C): indicates carry out of sign position from previous operation Overflow Flag (V): indicates two s complement overflow condition has occurred

CORTEX-M0 PROGRAMMING MODEL Core Registers (Continued) Combined Program Status Registers (cont.): Interrupt PSR (IPSR): Contains currently executing interrupt ISR number Exception PSR (EPSR): Contains T state bit, indicating Thumb operation (hardcoded to 1 on Cortex-M0/M0+)

CORTEX-M0 PROGRAMMING MODEL Core Registers (Continued) Interrupt Mask Special Register (PRIMASK): Contains a single bit for masking interrupts (masks all interrupts except NMI and HardFault when set). Only accessible using special access instructions (MSR, MRS, CPS) CONTROL Register: 2-bit special purpose register: SPSEL (bit 1): Specifies Handler Mode (0) / Thread Mode (1) npriv (bit 0): Specifies privileged access (0) or unprivileged access (1) (unprivileged access unavailable on Cortex-M0; hardcoded as 0)

CORTEX-M0 PROGRAMMING MODEL Memory System and the Stack ARM Cortex-M processors feature 4GB memory address space, divided into architecturally-defined regions

SOFTWARE TOOLCHAIN The software toolchain for ECE 362 is used to translate source code into µc instructions, and program the hex file generated into the target device Many toolchains are available, but Eclipse + OpenSTM32 have been selected for development in the lab experiments (toolchain setup is the subject of Experiment 0) Eclipse/OpenSTM32 toolchain based on GNU Compiler Collection (gcc)

SOFTWARE TOOLCHAIN Software tools in the Eclipse/OpenSTM32 Toolchain: Toolchain: Combines source files together into executable/linkable format (.elf) file, calls compiler Compiler: Converts C/C++ code to assembly, calls assembler and linker Assembler: Converts assembly code to machine code Linker: Combines assembly code segments together into unified hex file Flash Programming: Writes hex machine code file to onboard memory on target device

SOFTWARE TOOLCHAIN

Questions?