This document discusses ARM Cortex-M microcontrollers and their features. It provides information on ARM architecture and RISC processors. Specific Cortex-M models are described including their instruction sets, pipelines, registers and memory architecture. STM32 microcontrollers are mentioned. General purpose input/output and how to configure pins for different functions like GPIO, analog or alternate functions are explained. Examples of working with registers to read button states and toggle LEDs are provided. The concept of bit banding memory is also introduced.
3. RISC
reduced instruction set computer
• RISC processors use a small and limited number of
instructions
• RISC machines mostly uses hardwired control unit
• RISC processors consume less power and have high
performance
• Each instruction is very simple and consistent
• RISC processors use simple addressing modes
• RISC instruction is of uniform fixed length
• Large Number of Registers
4. ARM Cortex-M
• Microcontrollers
• ASIC (Application-specific integrated circuit)
• ASSP (Application-specific standard product)
• FPGA
• SoC (System-on-crystal)
5. ARM Cortex-M
Arm Core
Cortex
M0
Cortex
M0+
Cortex
M1
Cortex
M3
Cortex
M4
Cortex
M7
Cortex
M23
Cortex
M33
Cortex
M35P
ARM architecture ARMv6-M ARMv6-M ARMv6-M ARMv7-M ARMv7E-M ARMv7E-M
ARMv8-M
Baseline
ARMv8-M
Mainline
ARMv8-M
Mainline
Computer architecture
Von
Neuman
Von
Neumann
Von
Neumann
Harvard Harvard Harvard Von Neumann Harvard Harvard
Instruction pipeline 3 stages 2 stages 3 stages 3 stages 3 stages 6 stages 2 stages 3 stages 3 stages
Thumb-1 instructions Most Most Most Entire Entire Entire Most Entire Entire
Thumb-2 instructions Some Some Some Entire Entire Entire Some Entire Entire
Multiply instructions
32x32 = 32-bit result
Yes Yes Yes Yes Yes Yes Yes Yes Yes
Multiply instructions
32x32 = 64-bit result
No No No Yes Yes Yes No Yes Yes
Divide instructions
32/32 = 32-bit quotient
No No No Yes Yes Yes Yes Yes Yes
Saturated instructions No No No Some Yes Yes No Yes Yes
DSP instructions No No No No Yes Yes No Optional Optional
Interrupt latency
(if zero-wait state RAM)
16 cycles 15 cycles
23 for NMI
26 for IRQ
12 cycles 12 cycles 12 cycles
15 no security
ext
27 security ext
TBD TBD
10. ARM Cortex-M
Processor registers
The processor has the following 32-bit registers:
• 13 general-purpose registers, r0-r12
• Stack Pointer (SP) alias of banked registers,
SP_process and SP_main
• Link Register (LR), r14
• Program Counter (PC), r15
• Special-purpose Program Status Registers,
(xPSR).
18. General-purpose I/O
Main features
• Up to 16 I/Os under control
• Output states: push-pull or open drain + pull-up/down
• Output data from output data register (GPIOx_ODR)
• Speed selection for each I/O
• Input states: floating, pull-up/down, analog
• Input data to input data register (GPIOx_IDR)
• Bit set and reset register (GPIOx_BSRR) for bitwise write access to GPIOx_ODR
• Locking mechanism (GPIOx_LCKR) provided to freeze the I/O configuration
• Analog function
• Alternate function input/output selection registers (at most 16 AFs per I/O)
• Fast toggle capable of changing every two clock cycles
• Highly flexible pin multiplexing allows the use of I/O pins as GPIOs or as
one of several peripheral functions
27. ARM Cortex-M
Bit Banding
Address in the bit band alias region = Bit band alias base address + bit word offset
Where bit word offset = Byte offset from bit band base X32 + bit number X4
• PERIPH_BASE = 0x40000000 (PER_Base)
• GPIOD->ODR = 0x40020C14 (WORD)
• Bit Band Alias base = 0x42000000 (BBA_Base)
• PIN = 12
• BIT = BBA_Base + (WORD – PER_Base)*32 + PIN*4;
Byte offset from bit band base Bit number