You are previewing The Definitive Guide to ARM® Cortex®-M3 and Cortex®-M4 Processors, 3rd Edition.
O'Reilly logo
The Definitive Guide to ARM® Cortex®-M3 and Cortex®-M4 Processors, 3rd Edition

Book Description

This new edition has been fully revised and updated to include extensive information on the ARM Cortex-M4 processor, providing a complete up-to-date guide to both Cortex-M3 and Cortex-M4 processors, and which enables migration from various processor architectures to the exciting world of the Cortex-M3 and M4.

This book presents the background of the ARM architecture and outlines the features of the processors such as the instruction set, interrupt-handling and also demonstrates how to program and utilize the advanced features available such as the Memory Protection Unit (MPU).

Chapters on getting started with IAR, Keil, gcc and CooCox CoIDE tools help beginners develop program codes.  Coverage also includes the important areas of software development such as using the low power features, handling information input/output, mixed language projects with assembly and C, and other advanced topics.



  • Two new chapters on DSP features and CMSIS-DSP software libraries, covering DSP fundamentals and how to write DSP software for the Cortex-M4 processor, including examples of using the CMSIS-DSP library, as well as useful information about the DSP capability of the Cortex-M4 processor
  • A new chapter on the Cortex-M4 floating point unit and how to use it
  • A new chapter on using embedded OS (based on CMSIS-RTOS), as well as details of processor features to support OS operations
  • Various debugging techniques as well as a troubleshooting guide in the appendix
  • topics on software porting from other architectures
  • A full range of easy-to-understand examples, diagrams and quick reference appendices

Table of Contents

  1. Cover image
  2. Title page
  3. Table of Contents
  4. Copyright
  5. Foreword
  6. Preface
  7. Synopsis
  8. About this Book
  9. Contributor Bio-Paul Beckmann
  10. Acknowledgments
  11. Terms and Abbreviations
  12. Conventions
  13. Chapter 1. Introduction to ARM® Cortex®-M Processors
    1. Abstract
    2. 1.1 What are the ARM® Cortex®-M processors?
    3. 1.2 Advantages of the Cortex®-M processors
    4. 1.3 Applications of the ARM® Cortex®-M processors
    5. 1.4 Resources for using ARM® processors and ARM microcontrollers
    6. 1.5 Background and history
  14. Chapter 2. Introduction to Embedded Software Development
    1. Abstract
    2. 2.1 What are inside typical ARM® microcontrollers?
    3. 2.2 What you need to start
    4. 2.3 Software development flow
    5. 2.4 Compiling your applications
    6. 2.5 Software flow
    7. 2.6 Data types in C programming
    8. 2.7 Inputs, outputs, and peripherals accesses
    9. 2.8 Microcontroller interfaces
    10. 2.9 The Cortex® microcontroller software interface standard (CMSIS)
  15. Chapter 3. Technical Overview
    1. Abstract
    2. 3.1 General information about the Cortex®-M3 and Cortex-M4 processors
    3. 3.2 Features of the Cortex®-M3 and Cortex-M4 processors
  16. Chapter 4. Architecture
    1. Abstract
    2. 4.1 Introduction to the architecture
    3. 4.2 Programmer’s model
    4. 4.3 Behavior of the application program status register (APSR)
    5. 4.4 Memory system
    6. 4.5 Exceptions and interrupts
    7. 4.6 System control block (SCB)
    8. 4.7 Debug
    9. 4.8 Reset and reset sequence
  17. Chapter 5. Instruction Set
    1. Abstract
    2. 5.1 Background to the instruction set in ARM® Cortex®-M processors
    3. 5.2 Comparison of the instruction set in ARM® Cortex®-M processors
    4. 5.3 Understanding the assembly language syntax
    5. 5.4 Use of a suffix in instructions
    6. 5.5 Unified assembly language (UAL)
    7. 5.6 Instruction set
    8. 5.7 Cortex®-M4-specific instructions
    9. 5.8 Barrel shifter
    10. 5.9 Accessing special instructions and special registers in programming
  18. Chapter 6. Memory System
    1. Abstract
    2. 6.1 Overview of memory system features
    3. 6.2 Memory map
    4. 6.3 Connecting the processor to memory and peripherals
    5. 6.4 Memory requirements
    6. 6.5 Memory endianness
    7. 6.6 Data alignment and unaligned data access support
    8. 6.7 Bit-band operations
    9. 6.8 Default memory access permissions
    10. 6.9 Memory access attributes
    11. 6.10 Exclusive accesses
    12. 6.11 Memory barriers
    13. 6.12 Memory system in a microcontroller
  19. Chapter 7. Exceptions and Interrupts
    1. Abstract
    2. 7.1 Overview of exceptions and interrupts
    3. 7.2 Exception types
    4. 7.3 Overview of interrupt management
    5. 7.4 Definitions of priority
    6. 7.5 Vector table and vector table relocation
    7. 7.6 Interrupt inputs and pending behaviors
    8. 7.7 Exception sequence overview
    9. 7.8 Details of NVIC registers for interrupt control
    10. 7.9 Details of SCB registers for exception and interrupt control
    11. 7.10 Details of special registers for exception or interrupt masking
    12. 7.11 Example procedures in setting up interrupts
    13. 7.12 Software interrupts
    14. 7.13 Tips and hints
  20. Chapter 8. Exception Handling in Detail
    1. Abstract
    2. 8.1 Introduction
    3. 8.2 Exception sequences
    4. 8.3 Interrupt latency and exception handling optimization
  21. Chapter 9. Low Power and System Control Features
    1. Abstract
    2. 9.1 Low power designs
    3. 9.2 Low power features
    4. 9.3 Using WFI and WFE instructions in programming
    5. 9.4 Developing low power applications
    6. 9.5 The SysTick timer
    7. 9.6 Self-reset
    8. 9.7 CPU ID base register
    9. 9.8 Configuration control register
    10. 9.9 Auxiliary control register
    11. 9.10 Co-processor access control register
  22. Chapter 10. OS Support Features
    1. Abstract
    2. 10.1 Overview of OS support features
    3. 10.2 Shadowed stack pointer
    4. 10.3 SVC exception
    5. 10.4 PendSV exception
    6. 10.5 Context switching in action
    7. 10.6 Exclusive accesses and embedded OS
  23. Chapter 11. Memory Protection Unit (MPU)
    1. Abstract
    2. 11.1 Overview of the MPU
    3. 11.2 MPU registers
    4. 11.3 Setting up the MPU
    5. 11.4 Memory barrier and MPU configuration
    6. 11.5 Using sub-region disable
    7. 11.6 Considerations when using MPU
    8. 11.7 Other usages of the MPU
    9. 11.8 Comparing with the MPU in the Cortex®-M0+ processor
  24. Chapter 12. Fault Exceptions and Fault Handling
    1. Abstract
    2. 12.1 Overview of fault exceptions
    3. 12.2 Causes of faults
    4. 12.3 Enabling fault handlers
    5. 12.4 Fault status registers and fault address registers
    6. 12.5 Analyzing faults
    7. 12.6 Faults related to exception handling
    8. 12.7 Lockup
    9. 12.8 Fault handlers
    10. 12.9 Additional information
  25. Chapter 13. Floating Point Operations
    1. Abstract
    2. 13.1 About floating point data
    3. 13.2 Cortex®-M4 floating point unit (FPU)
    4. 13.3 Lazy stacking in detail
    5. 13.4 Using the floating point unit
    6. 13.5 Floating point exceptions
    7. 13.6 Hints and tips
  26. Chapter 14. Introduction to the Debug and Trace Features
    1. Abstract
    2. 14.1 Debug and trace features overview
    3. 14.2 Debug architecture
    4. 14.3 Debug modes
    5. 14.4 Debug events
    6. 14.5 Breakpoint feature
    7. 14.6 Debug components introduction
    8. 14.7 Debug operations
  27. Chapter 15. Getting Started with Keil Microcontroller Development Kit for ARM®
    1. Abstract
    2. 15.1 Overview
    3. 15.2 Typical program compilation flow
    4. 15.3 Getting started with μVision
    5. 15.4 Project options
    6. 15.5 Using the IDE and the debugger
    7. 15.6 Using the instruction set simulator
    8. 15.7 Running programs from SRAM
    9. 15.8 Optimization options
    10. 15.9 Other hints and tips
  28. Chapter 16. Getting Started with the IAR Embedded Workbench for ARM®
    1. Abstract
    2. 16.1 Overview of the IAR embedded workbench for ARM®
    3. 16.2 Typical program compilation flow
    4. 16.3 Creating a simple blinky project
    5. 16.4 Project options
    6. 16.5 Hints and tips
  29. Chapter 17. Getting Started with the GNU Compiler Collection (gcc)
    1. Abstract
    2. 17.1 The GNU Compiler Collection (gcc) toolchain
    3. 17.2 Typical development flow
    4. 17.3 Creating a simple blinky project
    5. 17.4 Overview of the command line options
    6. 17.5 Flash programming
    7. 17.6 Using Keil™ MDK-ARM with GNU tools for ARM Embedded Processors
    8. 17.7 Using CoIDE with GNU tools for ARM® Embedded Processors
    9. 17.8 Commercial gcc-based development suites
  30. Chapter 18. Input and Output Software Examples
    1. Abstract
    2. 18.1 Producing outputs
    3. 18.2 Re-targeting to the Instrumentation Trace Macrocell (ITM)
    4. 18.3 Semi-hosting
    5. 18.4 Re-targeting to peripherals
  31. Chapter 19. Using Embedded Operating Systems
    1. Abstract
    2. 19.1 Introduction to embedded OSs
    3. 19.2 Keil™ RTX Real-Time Kernel
    4. 19.3 CMSIS-OS examples
    5. 19.4 OS-aware debugging
    6. 19.5 Troubleshooting
  32. Chapter 20. Assembly and Mixed Language Projects
    1. Abstract
    2. 20.1 Use of assembly code in projects
    3. 20.2 Interaction between C and assembly
    4. 20.3 Structure of an assembly function
    5. 20.4 Examples
    6. 20.5 Mixed language projects
    7. 20.6 Intrinsic functions
    8. 20.7 Idiom recognition
  33. Chapter 21. ARM® Cortex®-M4 and DSP Applications
    1. Abstract
    2. 21.1 DSP on a microcontroller?
    3. 21.2 Dot product example
    4. 21.3 Architecture of a traditional DSP processor
    5. 21.4 Cortex®-M4 DSP instructions
    6. 21.5 Writing optimized DSP code for the Cortex®-M4
  34. Chapter 22. Using the ARM® CMSIS-DSP Library
    1. Abstract
    2. 22.1 Overview of the library
    3. 22.2 Pre-built binaries
    4. 22.3 Function naming convention
    5. 22.4 Getting help
    6. 22.5 Example 1 – DTMF demodulation
    7. 22.6 Example 2 – least squares motion tracking
  35. Chapter 23. Advanced Topics
    1. Abstract
    2. 23.1 Decisions and branches
    3. 23.2 Performance considerations
    4. 23.3 Double-word stack alignment
    5. 23.4 Various methods for semaphore implementation
    6. 23.5 Non-base Thread enable
    7. 23.6 Re-entrant Interrupt Handler
    8. 23.7 Bit Data Handling in C
    9. 23.8 Startup code
    10. 23.9 Stack overflow detection
    11. 23.10 Flash patch feature
    12. 23.11 Revision versions of the Cortex®-M3 and Cortex-M4 processors
  36. Chapter 24. Software Porting
    1. Abstract
    2. 24.1 Overview
    3. 24.2 Porting software from 8-bit/16-bit MCUs to Cortex®-M MCUs
    4. 24.3 Porting software from ARM7TDMI™ to Cortex®-M3/M4
    5. 24.4 Porting software between different Cortex®-M processors
  37. References
    1. Document
  38. Index
  39. Appendix A. Instruction Set Summary
    1. A.1 Instructions available for both Cortex®-M3 and Cortex-M4
    2. A.2 Instructions available for Cortex®-M4
    3. A.3 Floating point instructions for Cortex®-M4
  40. Appendix B. Graphical Representations of DSP Instructions
  41. Appendix C. Addition of 16-bit Thumb® Instructions in Recent Architecture Versions
  42. Appendix D. Cortex®-M3/M4 Exceptions Quick Reference
    1. D.1 Exception types and enable
    2. D.2 Stack frame format
  43. Appendix E. CMSIS-Core Functions Quick Reference
    1. E.1 Exception and interrupt numbers
    2. E.2 NVIC access functions
    3. E.3 System and systick functions
    4. E.4 Core registers access functions
    5. E.5 CMSIS intrinsic functions
    6. E.6 Debug message output function
  44. Appendix F. NVIC and SCB Registers Quick Reference
    1. F.1 NVIC registers
    2. F.2 SCB registers
    3. F.3 Other system control registers not in SCB data structure
    4. F.4 SYSTICK timer registers
    5. F.5 Memory protection unit
    6. F.6 Floating point unit
    7. F.7 SCS Peripheral and Component ID Registers
  45. Appendix G. Cortex®-M3/M4 Debug Components Programmer’s Model
    1. G.1 Processor core debug registers
    2. G.2 Flash patch and breakpoint unit
    3. G.3 Data watchpoint and trace unit
    4. G.4 Instrumentation trace macrocell
    5. G.5 Trace port interface unit (TPIU)
    6. G.6 AHB-AP (AHB access port)
  46. Appendix H. Connectors for Debug and Trace
    1. H.1 Overview
  47. Appendix I. Troubleshooting Guide
    1. I.1 Overview
    2. I.2 The debugger cannot connect to the development board
    3. I.3 The system does not start
    4. I.4 System not responding
    5. I.5 Fault exceptions
    6. I.6 Understanding the cause of the fault
    7. I.7 Other possible problems