I had heard about the STM32 microcontroller many years ago but had never chance to learn about it. Yesterday I created a simulation model of STM32 nucleo board in Proteus. The nucleo board is based on the STM32F401RE microcontroller. I tested it with a LED blink code. The coding was done with GCC for ARM compiler. The simulation STM32 microcontroller board with a LED attached is shown below.
The following video shows how the STM32 simulation model works.
Free Download
You can download the STM32 Nucleo Simulation Model from the link below.
Download STM32 Nucleo Simulation Model
Since I was using proteus for simulation I used the GCC compiler which was already installed in Proteus.
I think most of the people use the STM32Cube IDE to configure the microcontroller ports, clocks, peripherals etc, write the code, compile and generate .hex file and upload to the proteus simulation model.
Proteus has set the GCC compiler for ARM for the STM32 microcontroller by default, so if you want to use STM32Cube to write the code, then you have to first generate the .hex file and then you can use it with the STM32 Nucleo board simulation part in Proteus.
For the LED blink program there are many c files and header files which are too long to post it here. So I will instead post the main.c file content and the other supporting files can be downloaded from the download link below.
Download STM32 Simulation Source Code Files
The basic difference between the GCC compiler and STM32Cube compiler is that the GCC compiler is open source and can be distributed freely, where STM32Cube compiler is not open source but both are free to use. The STM32Cube helps users to figure out the pins and has user friendly interface to configure the STM32 micrcontroller peripherals and thus useful for beginners into the world of STM32 microcontroller. Learning curve might be easier with STM32Cube with its HAL function features.
The STM32F401RE Nucleo-64 board is a popular development board from STMicroelectronics, designed for prototyping and experimenting with the STM32F401RE microcontroller. It provides an easy-to-use platform for developing applications using the STM32F4 series of microcontrollers. Below is a detailed breakdown of the features and pin functionalities of the STM32F401RE-based Nucleo board.
Key Features of STM32F401RE Nucleo Board
Microcontroller :
- Model : STM32F401RE
- Core : ARM Cortex-M4 with FPU (Floating Point Unit)
- Clock Speed : Up to 84 MHz
- Memory :
- Flash: 512 KB
- SRAM: 96 KB
- Voltage Range : 1.7 V to 3.6 V
Development Environment :
- Compatible with STM32CubeIDE , Keil MDK , IAR Embedded Workbench , and other IDEs.
- Supports STM32CubeMX for graphical configuration of peripherals.
Onboard Debugger/Programmer :
- Integrated ST-LINK/V2-1 debugger/programmer.
- No external debugger required.
- Virtual COM port and mass storage support for firmware updates.
Connectivity :
- USB Interface : USB Micro-B connector for power and debugging.
- SWD (Serial Wire Debug) : For debugging and programming.
Power Supply Options :
- Powered via USB or external sources (VIN pin or 3.3V pin).
- Voltage regulator onboard for stable operation.
Expansion Connectors :
- Arduino Uno V3 Compatibility : Allows connection to Arduino shields.
- ST Morpho Headers : Provides access to all microcontroller pins for custom expansion.
LEDs and Buttons :
- User LED : LD2 (connected to pin PA5).
- User Button : B1 (connected to pin PC13).
- Reset Button : For resetting the microcontroller.
Additional Features :
- RTC Crystal : Onboard 32.768 kHz crystal for real-time clock functionality.
- JTAG/SWD Debugging : Full support for debugging interfaces.
Pin Functionalities of STM32F401RE Nucleo Board
The STM32F401RE Nucleo board exposes most of the microcontroller's pins through its headers. Below is a summary of the pin functionalities:
1. Power Pins
- 3.3V : Provides 3.3V power output.
- 5V : Provides 5V power output (from USB or external source).
- GND : Ground pins.
- VIN : External power input (7V to 12V).
2. Analog Pins
- A0–A5 : Analog input pins connected to the ADC channels of the STM32F401RE.
- A0: PA0
- A1: PA1
- A2: PA4
- A3: PB0
- A4: PC1
- A5: PC0
3. Digital I/O Pins
- The Nucleo board provides access to all GPIO pins of the STM32F401RE. These pins can be configured as inputs, outputs, or alternate functions (e.g., UART, SPI, I2C, etc.).
- Example pins:
- D0–D15 : Digital I/O pins mapped to specific GPIO ports.
- D0: PA3 (UART2_RX)
- D1: PA2 (UART2_TX)
- D2: PA10
- D3: PB3
- D4: PB5
- D5: PB4
- D6: PB10
- D7: PA8
- D8: PA9
- D9: PC7
- D10: PB6 (SPI_CS)
- D11: PA7 (SPI_MOSI)
- D12: PA6 (SPI_MISO)
- D13: PA5 (SPI_SCK, User LED)
- D14: PB9 (I2C1_SDA)
- D15: PB8 (I2C1_SCL)
- D0–D15 : Digital I/O pins mapped to specific GPIO ports.
4. Communication Interfaces
- UART :
- UART2: PA2 (TX), PA3 (RX)
- UART6: PC6 (TX), PC7 (RX)
- SPI :
- SPI1: PA5 (SCK), PA6 (MISO), PA7 (MOSI)
- SPI2: PB13 (SCK), PB14 (MISO), PB15 (MOSI)
- I2C :
- I2C1: PB8 (SCL), PB9 (SDA)
- I2C2: PB10 (SCL), PB11 (SDA)
- CAN :
- CAN1: PA11 (CAN_RX), PA12 (CAN_TX)
5. Special Function Pins
- LD2 (User LED) : Connected to PA5.
- B1 (User Button) : Connected to PC13.
- BOOT0 : Controls boot mode (used for bootloader entry).
6. Arduino-Compatible Pins
- The Nucleo board includes Arduino Uno V3-compatible headers, allowing the use of Arduino shields. These headers expose:
- Analog Inputs : A0–A5
- Digital I/O Pins : D0–D15
- PWM Pins : Several digital pins support PWM output.
- I2C and SPI : Dedicated pins for I2C and SPI communication.
7. ST Morpho Headers
- The ST Morpho headers provide access to all pins of the STM32F401RE microcontroller, including those not exposed on the Arduino headers. These are useful for advanced projects requiring full access to the microcontroller's capabilities.
Pin Mapping Overview
Summary
The STM32F401RE Nucleo-64 board is a versatile and powerful platform for developing applications with the STM32F401RE microcontroller. Its key features include an integrated debugger, Arduino compatibility, and access to all microcontroller pins through ST Morpho headers. The board's pin functionalities allow for flexible use of GPIOs, communication interfaces (UART, SPI, I2C), and analog inputs, making it suitable for a wide range of embedded projects.