Chapter 6

Architecture of the STM32F411RET6 Microcontroller


It is important to know the internal architecture of the STM32F411RET6 microcontroller before projects are developed using this microcontroller. This chapter describes in detail the internal architecture and key features of the STM32F411RET6 ARM microcontroller, which is the microcontroller used on the STM32 Nucleo-F411RE development board. This board incorporates the 32-bit, 64-pin STM32F411RET6 microcontroller. The features of the STM32F411RET6 microcontroller are described in reference to its various modules, such as the general purpose input-output (GPIO) ports, timers, analog-to-digital converter (ADC), digital-to-analog converter (DAC), electrical characteristics, interrupt controller, power management, power modes, clock circuitry and configuration of the clock module, SPI bus, UART, and the I2C bus.


STM32 Nucleo-F411RE development board; Nucleo-F411RE; Cortex-M4; STM32F411RET6; Interrupt controller; Clock sources; GPIOs; SPI; USART; Standby mode

6.1 Overview

In this book, we shall be using the STM32 Nucleo-F411RE development board. This board incorporates the 32-bit, 64-pin STM32F411RET6 microcontroller. In this chapter, we shall be looking at the features of the STM32F411RET6 microcontroller. It is important to know the basic internal architecture of a microcontroller before it is used successfully in a project. The internal architecture of this microcontroller is very complex and we shall only briefly look at the commonly used features of this microcontroller, such as the GPIO, timers, analog-to-digital converter (ADC) and digital-to-analog converter (DAC), interrupt controller, power management, and so on. Interested readers can get detailed information on this microcontroller from the following STMicroelectronics website:

6.2 Key Features of the STM32F411RET6 Microcontroller

The STM32F411RET6 microcontroller is based on the Cortex-M4 core and it is used on the Nucleo-F411RE development board. The key features of this microcontroller are as follows (see the above website):

  •  Cortex-M4 core
  •  1.7–3.6 V power supply
  •  Frequency up to 100 MHz
  •  512 KB flash memory
  •  128 KB static random-access memory (SRAM)
  •  Internal 16 MHz RC oscillator
  •  4–26 MHz crystal oscillator
  •  Internal 32 kHz RC oscillator
  •  100 μA/MHz run time power consumption
  •  16-Stream direct memory access (DMA) controllers
  •  11 Timers
  •  Serial wire debug (SWD) and JTAG interface
  •  52 I/O ports
  •  3 × I2C interface
  •  3 × USART
  •  5 × SPI/I2S
  •  SD/MMC/eMMC interface
  •  Real-time clock (RTC) with hardware calendar
  •  Cyclic redundancy check (CRC) calculation unit

Fig. 6.1 shows the block diagram of the STM32F411RET6 microcontroller, showing all the modules supported by the microcontroller. The Cortex-M4 core is shown at the top middle part of the figure. The I/O connectivity modules are shown at the top left-hand part of the figure. Timer modules are shown at the middle right-hand side of the figure. The GPIO and the analog input and output modules are shown at the bottom left and bottom right-hand side of the figure, respectively.

Fig. 6.1
Fig. 6.1 Block diagram of the STM32F411RET6 microcontroller.

Fig. 6.2 shows the pin configuration of the STM32F411RET6 microcontroller. The pin definitions are as follows (some pins have more than one function):

Fig. 6.2
Fig. 6.2 Pin configuration of the microcontroller.
PA0–PA15GPIO Port A pins
PB0–PB15GPIO Port B pins
PC0–PC15GPIO Port C pins
PD2GPIO Port D pin
PH0–PH1GPIO Port H pins
OSC_IN, OSC_OUTMain crystal oscillator pins
OSC32_IN, OSC32_OUT32 kHz crystal oscillator pins
VDD, VSSPower and ground pins
VSSA, VDDAReference voltage pins
NRSTReset pin
VBATExternal battery pin
BOOT0Boot0 pin
VDD12External SMPS power pin

The internal structure of the STM32F411RET6 microcontroller is shown in Fig. 6.3A and B.

Fig. 6.3
Fig. 6.3
Fig. 6.3 (A) and (B) Internal structure of the STM32F411RET6 microcontroller.

6.2.1 Power Modes

By default, the microcontroller starts in Run mode after power-up or reset. The microcontroller can be configured to operate in one of the following low-power modes.

Sleep Mode

In Sleep mode, the CPU is stopped, all peripherals continue to operate and can wake up the CPU when an interrupt/event occurs.

Stop Mode

The Stop mode achieves the lowest power consumption while retaining the contents of SRAM and registers. All clocks in the 1.2 V domain are stopped, the phase-locked loop (PLL), the HSI RC, and the high-speed external (HSE) crystal oscillators are disabled. The voltage regulator can also be put either in normal or in low-power mode.

Standby Mode

The Standby mode is used to achieve the lowest power consumption. The internal voltage regulator is switched off so that the entire 1.2 V domain is powered off. The PLL, the HSI RC, and the HSE crystal oscillators are also switched off. After entering the Standby mode, the SRAM and register contents are lost except for registers in the backup domain when selected. The devices exit the Standby mode when an external reset (NRST pin), an IWDG reset, a rising edge on the WKUP pin, or an RTC alarm/wakeup/tamper/time stamp event occurs.

6.2.2 Electrical Characteristics

It is important to know the absolute maximum electrical ratings of a microcontroller before it is used in a project. Table 6.1 illustrates the STM32F411RET6 microcontroller absolute maximum ratings that should not be exceeded. Notice that the power-supply voltage should never exceed 4.0 V.

Table 6.1

Absolute Maximum Electrical Ratings of the STM32F411RET6 Microcontroller
VDD − VSSExternal main supply voltage (including VDDA, VDD, and VBat)a− 0.34.0V
VINInput voltage on FT and TC pinsbVSS − 0.3VDD + 4.0
Input voltage on any other pinVSS − 0.34.0
Input voltage for BOOT0VSS9.0
| ΔVDDx |Variations between different VDD power pins50mV
| VSSX − VSS |Variations between all the different ground pins50

Table 6.1

a All main power and ground pins must always be connected to the external power supply.

b VIN maximum value must always be respected.

The current consumption characteristic of the STM32F411RET6 microcontroller is shown in Table 6.2. Two important parameters in this table are the I/O current capability of each I/O pin which should not exceed 20 mA. This current is normally sufficient to drive small LEDs, switches, etc. Transistor switch circuits (e.g., MOSFET switch) should be used if external devices requiring more than 20 mA are connected to an I/O pin. Also, the total current of all the I/O pins should not exceed 100 mA.

Table 6.2

Current Characteristics of the STM32F411RET6 Microcontroller
ΣIVDDTotal current into sum of all VDD_x power lines (source)a160mA
ΣIVSSTotal current out of sum of all VSS_x ground lines (sink)a− 160
IVDDMaximum current into each VDD_x power line (source)a100
IVSSMaximum current out of each VSS_x ground line (sink)a− 100
IIOOutput current sunk by any I/O and control pin25
Output current sourced by any I/O and control pin− 25
ΣIIOTotal output current sunk by sum of all I/O and control pinsb120
Total output current sourced by sum of all l/Os and control pinsb− 120
IINJ(PIN)cInjected current on FT and TC pinsd− 5/+0
Injected current on NRST and B pinsd
ΣIINJ(PIN)Total injected current (sum of all I/O and control pins)e± 25

Table 6.2

a All main power and ground pins must always be connected to the external power supply.

b This current consumption must correct be distributed over all I/O and control pins.

c Negative injection disturbs the analog performance of the device.

d Positive injection is not possible on these pins.

e When several inputs are submitted to current injection, the maximum is the absolute sum of the positive and negative injected currents.

6.2.3 The Interrupt Controller

A nested vectored interrupt controller is available on the microcontroller which can manage 16 interrupt priority levels, and can handle up to 62 maskable interrupt channels with 16 interrupt lines of the Cortex-M4. Interrupt management is provided with minimal interrupt latency which allows early processing of interrupts. The processor state is automatically saved on entry to an interrupt, and restored on interrupt exit, with no instruction overhead.

6.2.4 The Analog-to-Digital Converter (ADC)

A successive approximation ADC is used with the following specifications:

  •  12-bit resolution
  •  5.33 Msps conversion rate (higher for lower resolution)
  •  18.75 ns sampling time
  •  Up to 16 channels
  •  Internal reference voltage
  •  Single-ended and differential mode inputs
  •  Dual clock operation
  •  Single-shot or continuous mode
  •  Multiple trigger inputs
  •  Results stored in data register (or RAM)
  •  Data preprocessing (left/right alignment) and offset compensation
  •  Built-in oversampling unit
  •  Programmable sampling time

6.2.5 Digital-to-Analog Converter (DAC)

Two 12-bit DAC channels are available on the chip. The DAC has the following features:

  •  8-bit or 12-bit output mode
  •  Left/right data alignment (in 12-bit mode)
  •  Noise-wave generation
  •  Triangular-wave generation
  •  Dual DAC independent or simultaneous conversion
  •  DMA capability
  •  External triggering
  •  Sample and hold with internal or external capacitor

6.2.6 Temperature Sensor

A temperature sensor is available on the microcontroller chip that generates voltage linearly proportional with temperature. This sensor is internally connected to the ADC_IN18 analog input channel of the microcontroller. The sensor should be calibrated for good accuracy as its characteristics change from chip to chip due to process variations. The devices are calibrated at factory by ST where the calibration data are available in the system memory as read-only data (see the device data sheet).

6.2.7 Timers and Watchdogs

Timer modules are important parts of all microcontrollers. The STM32F411RET6 microcontroller includes one advanced control timer, seven general purpose timers, two watchdog timers, and a SysTick timer. Table 6.3 presents a brief summary of the timers.

Table 6.3

The STM32F411RET6 Microcontroller Timers
Timer TypeTimerCounter ResolutionCounter TypePrescaler FactorDMA Request GenerationCapture/Compare ChannelsComplementary OutputMax. Interface Clock (MHz)Max. Timer Clock (MHz)
Advanced-controlTIM116-bitUp, down, up/downAny integer between 1 and 65536Yes4Yes100100
General purposeTIM2, TIM532-bitUp, down, up/downAny integer between 1 and 65536Yes4No50100
TIM3, TIM416-bitUp, down, up/downAny integer between 1 and 65536Yes4No50100
TIM916-bitUpAny integer between 1 and 65536No2No100100
TIM10, TIM1116-bitUpAny integer between 1 and 65536No1No100100

Table 6.3

6.2.8 The Clock Circuit

The clock circuit is an important part of the microcontroller. As shown in Fig. 6.4, there two system clock (SYSCLK) sources: External clock sources and Internal clock sources.

Fig. 6.4
Fig. 6.4 System clock sources.

External Clock Sources

High Speed External (HSE): This can be an external crystal or resonator device, or an external clock signal. The frequency range of the crystal or resonator should be 4–48 MHz. It is recommended to use two capacitors in the range of 4–25 pF with the crystal circuit.

When using a clock generator circuit, the waveform can be square, sine, or triangular, and the waveform must be symmetrical, that is, 50% ON and 50% OFF times. The clock signal must be fed to the OSC_IN pin of the microcontroller. If external clock circuitry is used, then HSE oscillator should be bypassed to avoid any conflict.

Low-Speed External (LSE): This is a 32,768 Hz clock driven from an external crystal and feeding the internal RTC module.

Internal Clock Sources

High-Speed Internal (HSI): This is an accurate RC-based 16 MHz internal clock with a factory calibrated tolerance of 1%.

Multispeed Internal (MSI RC): This is a multispeed RC-based clock source providing clock in the range 100 kHz–48 MHz. This clock can be trimmed by software and is able to generate 12 different clock frequencies.

PLL: The PLL is fed by HSE, HSI16, or MSI clocks and it can generate system clocks up to 100 MHz.

Microcontroller Clock Output (MCO)

A clock output is possible from a special pin called MCO. This clock output can be used as a general purpose clock or as a clock for another microcontroller.

Low-Speed Clock Output (LSCO)

A low-speed (32,768 kHz) clock (LSCO) is available as a general purpose clock output.

Several prescalers are available in the clock circuit to configure the AHB, APB1, and APB2 bus clock frequencies for the system and the peripheral devices. The maximum frequency of the AHB and APBx is 80 MHz.

Configuring the Clock

As shown in Figs. 6.5 and 6.6, the clock circuit consists of a number of multiplexers, prescalers, and a PLL. The multiplexers are used to select the required clock source. The prescalers are used to divide the clock frequency by a constant. Similarly, the PLL is used to multiply the clock frequency with a constant in order to operate the chip at higher frequencies.

Fig. 6.5
Fig. 6.5 STM32L433RCT6P clock circuit (continued).
Fig. 6.6
Fig. 6.6 STM32L433RCT6P clock circuit.

It is important to select the correct clock source for an application. Configuring the clock sources by programming the internal clock registers is a complex task and detailed knowledge of the clock circuitry is required. In reference to Figs. 6.5 and 6.6, we can identify the following prescalers:

  • AHB prescaler: this prescaler receives the system clock SYSCLK and provides clock to the AHB bus (HCLK). The prescaler can take the values from 1,2 to up to 512.
  • APB1 prescaler: this prescaler receives the AHB clock (HCLK) and provides clock to the APB1 bus peripherals. The prescaler can take the values 1,2,4,8, and 16.
  • APB2 prescaler: this prescaler receives the AHB clock (HCLK) and provides clock to the APB2 bus peripherals. The prescaler can take the values 1,2,4,8, and 16.

6.2.9 General Purpose Input and Output (GPIO)

The STM32F411RET6 microcontroller has 64 pins and 52 of them can be used as general purpose input or output (GPIO). The GPIO is arranged into five ports, where ports A, B, and C are 16-bits wide, port H is 3-bits wide, and port D is only 1-bit. During and after reset, most ports are configured in analog input mode. Each port has the following basic features:

  •  all GPIO pins have weak internal pull-up and pull-down resistors, which can be activated under software control.
  •  port input states can be floating, pull-up, pull-down, or analog.
  •  port outputs can be configured as push-pull, open-drain or pull-up, pull-down
  •  the speed of each port can be set
  •  I/O port configurations can be locked under software control
  •  port pins can be digital I/O, analog input, or they can have alternative functions, such as DAC, SPI, USB, PWM, etc.)
  •  each port pin can be used with one of 15 alternate functions (AFs)
  •  bit manipulations can be performed on each port pin

Each GPIO port, subject to its hardware characteristics, can be configured in software in several modes:

  •  input pull-up
  •  input-pull-down
  •  analog
  •  output open-drain with pull-up or pull-down capability
  •  Output push-pull with pull-up or pull-down capability
  •  AF push-pull with pull-up or pull-down capability
  •  AF open-drain with pull-up or pull-down capability

Fig. 6.7 shows the structure of a push-pull output port pin. Similarly, an open-drain output port pin is shown in Fig. 6.8. Input pull-up and pull-down circuits are shown in Figs. 6.9 and 6.10, respectively.

Fig. 6.7
Fig. 6.7 Push-pull output pin.
Fig. 6.8
Fig. 6.8 Open-drain output pin.
Fig. 6.9
Fig. 6.9 Pull-up pin.
Fig. 6.10
Fig. 6.10 Pull-down pin.

GPIO port pins can be programmed for AFs. For AF inputs, the port must be configured in the required input mode. Similarly, for AF outputs, the port must be configured in AF output mode. When a port is configured as AF, the pull-up and pull-down resistors are disabled, the output is set to operate in push-pull or in open-drain mode. When an I/O port is configured as AF:

  •  the output buffer can be configured in open-drain or push-pull mode
  •  the output buffer is driven by the signals coming from the peripheral
  •  the Schmitt trigger input is activated
  •  the data present on the I/O pin are readapt every AHB clock cycle

The GPIO pins are + 5 V tolerant (except pins PA0 and PB5). + 5 V tolerant GPIO pins are denoted with letters FT in the data sheet.

6.2.10 I2C Interface

The microcontroller supports three I2C bus interfaces that can operate in multimaster and in slave modes. The I2C interface can operate at up to 400 kHz, but it can be increased up to 1 MHz. A hardware CRC generation/verification is included.

6.2.11 SPI Interface

Five SPI interfaces in slave and master modes are supported. Three SPI interfaces can operate at up to 50 Mbit/s while the remaining two can communicate at up to 25 Mbit/s.

6.2.12 I2S Interface

Five standard I2S interfaces are supported which can operate in master or slave modes, in simplex or full duplex communication modes. Audio sampling frequencies from 8 to 192 kHz are supported.

6.2.13 USART

Three USARTs are supported by the microcontroller. Two of the USARTs can communicate at up to 12.5 Mbit/s, the remaining one can communicate at up to 6.25 Mbit/s.

6.3 Summary

In this chapter, we have learned about the following:

  •  Key features of the STM32F411RET6 microcontroller
  •  Power modes
  •  Electrical characteristics
  •  ADC and DAC
  •  Interrupt controller
  •  Timers
  •  Clock circuit
  •  Temperature sensor
  •  I2C, SPI, and I2S interfaces
  •  GPIO ports

6.4 Exercises

  1. 1. Describe the various power modes of the STM32F411RET6 microcontroller.
  2. 2. What is the maximum current that can be drawn from a GPIO pin?
  3. 3. What is the total maximum current that can be drawn from all the GPIO pins?
  4. 4. Describe how we can drive loads requiring more than 20 mA.
  5. 5. Explain the various clock sources available on the STM32F411RET6 microcontroller.
  6. 6. Explain the difference between push-pull and open-drain output.
  7. 7. Explain the difference between pull-up and pull-down pin.
  8. 8. What do you understand if a GPIO pin is + 5 V tolerant?
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.