Site icon Renzo Mischianti

Black Pill STM32F4: pinout, specs, and Arduino IDE configuration – 4

Spread the love

This article will explain how to program the Black Pill STM32F4 microcontrollers. It can be considered the big brother of the STM32F1 series, more powerful, and with all the features of the F1 version.

Black Pill STM32F4: pinout, specs, and Arduino IDE configuration

One of the most exciting features of the Black Pill variant of STM32 has a built-in ROM bootloader that cannot be disabled or erased, and this makes it a fool-proof way always to be able to recover your microcontroller code.

But now we start to look at the STM32 family of microcontrollers, and then we’ll go deep into the STM32F4 series and learn how to use/program.

SMT32 details

The STM32 family of 32-bit microcontrollers is based on the Arm® Cortex®-M processor.

These products combine very high performance, real-time capabilities, digital signal processing, low-power / low-voltage operation, and connectivity while maintaining full integration and ease of development.

The range of STM32 microcontrollers, based on an industry-standard core, comes with a vast choice of tools and software to support project development, making this family of products ideal for small projects and end-to-end platforms.

Here the most commons STM32 STM32F103C8T6 STM32F401 STM32F411 ST-Link v2 ST-Link v2 official

Specs

There is a wide variety of stm32; here is a schematization of the main categories.

STM32 family of 32bit microcontrollers categories

A more detailed classification can do with the part number decoding:

STM32F051R8
STM32xxwwyz

Family: [xx]

CodeCoreMax freq [MHz]Max FLASH [KB]Max SRAM [KB]Target
F0Cortex-M04825632Mainstream
F1Cortex-M372102496Mainstream
F2Cortex-M31201024128High performance
F3Cortex-M4F7251280Mainstream
F4Cortex-M4F1802048384High performance
G0Cortex-M0+6412836Mainstream
G4Cortex-M4F170512128Mainstream
F7Cortex-M7F2162048512High performance
H7Cortex-M7F48020481024High performance
WBCortex-M4F641024256Wireless
WLCortex-M44825664Wireless
L0Cortex-M0+3219220Ultra-low-power
L1Cortex-M33251280Ultra-low-power
L4Cortex-M4F801024320Ultra-low-power
L4+Cortex-M4F1202048640Ultra-low-power
L5Cortex-M33F110512256Ultra-low-power
U5Cortex-M33F1602048786Ultra-low-power

Package pin count [y]

CodeNumber of pins
A169
B208
C48
F20
G28
H40
I176
J8/72
K32
M81
N216
Q132
R64
T36
U63
V100
Z144

FLASH memory size [z]

CodeFLASH size [KB]
416
632
864
B128
Z192
C256
D384
E512
F768
G1024
H1536
I2048

STM32F4 details

STM32F4 series of high-performance MCUs with DSP and FPU instructions

The ARM® Cortex®-M4-based STM32F4 MCU series leverages ST’s NVM technology and ART Accelerator™ to reach the industry’s highest benchmark scores for Cortex-M-based microcontrollers with up to 225 DMIPS/608 CoreMark executing from Flash memory at up to 180 MHz operating frequency.
With dynamic power scaling, the current consumption running from Flash ranges from 89 µA/MHz on the STM32F410 up to 260 µA/MHz on the STM32F439.
The STM32F4 series consists of eight compatible product lines of digital signal controllers (DSC), a perfect symbiosis of the real-time control capabilities of an MCU, and the signal processing performance of a digital signal processor (DSP):

STM32F4xx comparison table

Pinouts

The F401 model is one of the most popular, also considering the very affordable cost.

STM32 STM32F401 STM32F401CCU6 pinout low resolution

WeAct STM32F401CCU6 Black-Pill: high-resolution pinout and specs

The 411 version is certainly more performing, which also has an extra SPI, timer and I2S.

STM32 STM32F411 STM32F411CEU6 pinout low resolution

It is important to note pins 10 and 41 that F411 is not tolerant to 5V (check the red color of the square).

WeAct STM32F411CEU6 Black-Pill: high-resolution pinout and specs

But the 5V tolerance is one of the most important features of these F4xx series.

Arduino STM32 from STMicroelectronics

We must add the URL descriptor to our Arduino IDE.

https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

Go to File –> Preferences and add the URL on “Additional Boards Manager URLs.”

Arduino IDE adds Arduino STM32 URL descriptor.


Then you must add a new board to Boards Manager

Select board manager

The boards to select are STM32 MCU-based boards.

Arduino IDE selects STM32 MCU official-based boards

Now you can choose the specified device:

Arduino IDE Arduino SMT official select stm32f4 board series

Now we are going to select the specified board.

Arduino IDE: Arduino SMT official, select specified stm32f401cc board

As already said, these devices have a DFU bootloader already uploaded, so you can use USB to program, and you must select the DFU bootloader.

STM32 Arduino IDE select Upload with DFU Bootloader

To use Serial to debug your code, you must select "USB support (if It's available): "CDC (generic 'Serial' supersede U(S)ART)"

STM32 Arduino IDE select: CDC generic ‘Serial’ supersede U(S)ART

Install STM32CubeProgrammer

To work, you also need to install the STM32CubeProgrammer released from STMicroelectronics.

You can download It from here.

Select boot mode

Put this device in boot mode:

Now you have the red PWR led only.

My device has an LED on PA13.

/*
  Blink for STM32F4

  Turns an LED on for one second, then off for one second, repeatedly.

  http://www.mischianti.org
*/

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);

//  while (!Serial) {
//    ; // wait for serial port to connect. Needed for native USB port only
//  }
  Serial.println(F("Serial OK!"));

  pinMode(PC13, OUTPUT);
}

void loop() {
  digitalWrite(PC13, HIGH);
  Serial.println(F("HIGH!"));
  delay(1000);
  digitalWrite(PC13, LOW);
  Serial.println(F("LOW!"));
  delay(1000);
}

Now start the upload.

      -------------------------------------------------------------------
                       STM32CubeProgrammer v2.9.0                  
      -------------------------------------------------------------------



USB speed   : Full Speed (12MBit/s)
Manuf. ID   : STMicroelectronics
Product ID  : STM32  BOOTLOADER
SN          : 31A035713237
FW version  : 0x011a
Board       : --
Device ID   : 0x0433
Device name : STM32F401xD/E
Flash size  : 8 MBytes (default)
Device type : MCU
Revision ID : --  
Device CPU  : Cortex-M4



Memory Programming ...
Opening and parsing file: sketch_feb22a.ino.bin
  File          : sketch_feb22a.ino.bin
  Size          : 24296 Bytes
  Address       : 0x08000000 


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
erasing sector 0000 @: 0x08000000 done
erasing sector 0001 @: 0x08004000 done
Download in Progress:


File download complete
Time elapsed during download operation: 00:00:01.101

RUNNING Program ... 
  Address:      : 0x8000000
Start operation achieved successfully


If all It’s ok, your C13 LED starts to blink, and as if by magic new Serial port has appeared, for me COM12.

STM32 STM Serial DFU bootloader with Serial declaration

When connecting the serial monitor to the COM port, you get this result:

Serial OK!
HIGH!
LOW!
HIGH!
LOW!
HIGH!
LOW!
HIGH!
LOW!
HIGH!

Thanks

  1. STM32F1 Blue-Pill: pinout, specs, and Arduino IDE configuration (STM32duino and STMicroelectronics)
  2. STM32: program (STM32F1) via USB with STM32duino bootloader
  3. STM32: programming (STM32F1 STM32F4) via USB with HID boot-loader
  4. STM32F4 Black-Pill: pinout, specs, and Arduino IDE configuration
  5. STM32: ethernet w5500 with plain HTTP and SSL (HTTPS)
  6. STM32: ethernet enc28j60 with plain HTTP and SSL (HTTPS)
  7. STM32: WiFiNINA with ESP32 WiFi Co-Processor
    1. STM32F1 Blue-pill: WiFi shield (WiFiNINA)
    2. STM32F4 Black-pill: WiFi shield (WiFiNINA)
  8. How to use SD card with stm32 and SdFat library
  9. \STM32: SPI flash memory FAT FS
  10. STM32: internal RTC, clock, and battery backup (VBAT)
  11. STM32 LoRa
    1. Unleashing IoT Potential: Integrating STM32F1 Blue-Pill with EByte LoRa E32, E22, and E220 Shields
    2. Unleashing IoT Potential: Integrating STM32F4 Black-Pill with EByte LoRa E32, E22, and E220 Shields
  1. STM32 Power saving
    1. STM32F1 Blue-Pill clock and frequency management
    2. STM32F4 Black-Pill clock and frequency management
    3. Intro and Arduino vs STM framework
    4. Library LowPower, wiring, and Idle (STM Sleep) mode
    5. Sleep, deep sleep, shutdown, and power consumption
    6. Wake up from RTC alarm and Serial
    7. Wake up from the external source
    8. Backup domain intro and variable preservation across reset
    9. RTC backup register and SRAM preservation
  1. STM32 send emails with attachments and SSL (like Gmail): w5500, enc28j60, SD, and SPI Fash
  2. FTP server on STM32 with w5500, enc28j60, SD Card, and SPI Flash
  3. Connecting the EByte E70 to STM32 (black/blue pill) devices and a simple sketch example

Spread the love
Exit mobile version