VietNam National University
University of Engineering and Technology
EMBEDDED SYSTEM FUNDAMENTALS
(ELT3240, NHẬP MÔN HỆ THỐNG NHÚNG)
Dr. Nguyễn Kiêm Hùng
Email: kiemhung@vnu.edu.vn
Objectives
In this lecture you will be introduced to:
– A brief overview of the STM32F4 microcontroller
architecture
3
Outline
• The STM32F4 Microcontroller
– Central Processing Unit
– Memory
– General Purpose Input and Output Ports
– Clock and Timer Modules
– Analog Modules
– Digital Communication Modules
– Other Modules
• The STM32F4 Board: Nucleo-F401re
– General Information
– Pin Layout
– Powering the Board and Programming the Microcontroller on It
4
The STM32F4 Microcontroller
Functional Block Diagram of the STM32F4 Microcontroller
Central Processing Unit
CPU is responsible for organizing all operations within the
microcontroller.
The programmer constructs his or her algorithm and forms
the corresponding C, C++, or assembly code.
This code is debugged and embedded into flash memory of
the microcontroller by the help of an integrated development
environment.
The CPU executes the commands by using its resources (such
as peripheral units).
Central Processing Unit
Block diagram of the CPU for the STM32F4 microcontroller
Central Processing Unit
CPU components
Nested Vectored Interrupt Controller
Debug Access Port and Serial Wire Viewer
Memory Management Units
Embedded Trace Macrocell Module
The Bus Matrix
Registers
Memory (memory)
Data to be processed and code to be executed is stored in
memory of the microcontroller.
Memory Types
• Random Access Memory (RAM)
– Stores temporary data.
– Contents of RAM are lost when the power fed to it is turned off.
• Read Only Memory (ROM), Flash memory
– stores code or data permanently.
– Even if the power fed to it is turned off, contents of ROM are
kept.
Memory
The STM32F4 microcontroller
memory map
Memory
Memory Related Modules
• Direct Memory Access (DMA) module.
• Flexible Memory controller (FMC).
• Chrom-art accelerator controller (DMA2D) module.
General Purpose Input and Output
Ports
• The microcontroller needs a medium to transfer data to and
from the outside world.
• This is done by using ports of the microcontroller. A port is a
collection of pins grouped together.
• Each pin can be taken as a wire with its electronic control
circuitry.
• The STM32F4 microcontroller has eight input and output
ports called A, B, C, D, E, F, G, and H. Total number of pins in
these ports is 114.
Clock and Timer Modules
• With each clock cycle (MCLK), the processor performs an
action that corresponds to an instruction phase.
• Cycles Per Instruction (CPI) is the average number of clock
cycles required for a processor to execute an instruction.
• Millions of instructions per second (MIPS) is a unit used to
characterize a processor’s performance and corresponds to
the processor frequency (MCLK) divided by the average cycles
per second (CPI).
Analog Modules
• When we want to process an analog signal via the STM32F4
microcontroller, we will need an analog to digital converter
(ADC).
• In the same manner, we will need a digital to analog converter
(DAC) if we want to feed an analog circuit via the STM32F4
microcontroller.
• The STM32F4 microcontroller has specific modules to handle
the ADC and DAC operations.
Digital Communication Modules
• Digital communication modules are used to communicate with external
devices using dedicated communication protocols.
• The STM32F4 microcontroller has the following modules for digital
communication.
– three inter integrated circuit (I2C) modules
– four universal synchronous/asynchronous receiver/transmitter
(USART) modules
– four universal asynchronous receiver/transmitter (UART) modules
– six serial peripheral interface (SPI) modules
– two controller area network (CAN) modules
– one universal serial bus on-the-go full-speed (USB OTG_FS) module
– one universal serial bus on-the-go high-speed (USB OTG_HS) module
– one ethernet media access control (MAC) module with DMA
Other Modules
• There are also other modules under the STM32F4
microcontroller.
• We will not deal with them here.
• Please see the microcontroller user’s guide for these.
Outline
• The STM32F4 Microcontroller
– Central Processing Unit
– Memory
– General Purpose Input and Output Ports
– Clock and Timer Modules
– Analog Modules
– Digital Communication Modules
– Other Modules
• The STM32F4 Board: Nucleo-F401re
– General Information
– Pin Layout
– Powering the Board and Programming the Microcontroller on It
17
INTRODUCTION TO NUCLEO – F401RE
BOARD FEATURES
Provides an affordable and flexible way for users to try out new
concepts and build prototypes
STM32 microcontroller
32.768 kHz crystal oscillator
• Two types of extension resources
• Arduino Uno Revision 3 connectivity
• STMicroelectronics Morpho extension pin headers for full
access to all STM32 I/Os
• On-board ST-LINK/V2-1 debugger/programmer with SWD connector
• Selection-mode switch to use the kit as a standalone ST-
LINK/V2-1
• Flexible board power supply
• USB VBUS or external source (3.3 V, 5 V, 7 - 12 V)
• Power management access point
• User LED (LD2)
•Two push buttons: USER and RESET
• USB re-enumeration capability: three different interfaces supported
on USB
• Virtual Com port
• Mass storage (USB Disk drive) for drag'n'drop programming
• Debug port
• Comprehensive free software libraries and examples available with
the STM32Cube MCU Package
• Support of a wide choice of Integrated Development Environments
(IDEs) including IAR Embedded Workbench®, MDK-ARM, and
STM32CubeIDE
INTRODUCTION TO NUCLEO – F401RE
Pinout
The STM32F4 Board
Powering the Board and Programming the Microcontroller on It
The microcontroller on the STM32F4 board can be programmed easily
by the onboard ST-LINK/V2-B debugger/programmer. To do so, we
should connect the board to PC via mini USB cable through its USB
connector CN1.
The USB connection for debugging/programming purposes can also be
used to power the board.
We can also use an external 5 V power supply to power the board.
The STM32F4 microcontroller operates within voltage levels 1.8 V to
3.6 V.