Home> Blog> Exploring Capabilities of the MCU STM32F401CCU6 Now

Exploring Capabilities of the MCU STM32F401CCU6 Now

STM32
PCBONLINE Team Mon, Apr 08, 2024
176
STM32F401CCU6

The STM32F401CCU6 is a low-cost, versatile Microcontroller (MCU) development board produced by STMicroelectronics. Let's examine the board's hardware features, its raw processing power, and the software it can run. This article also introduces a one-stop box-build assembly manufacturer that can turn your design based on the MCU development board into real products.

Hardware Aspects of STM32F401CCU6

STM32F401CCU6 features a high-performance Arm Cortex-M4 32-bit RISC CPU operating at a frequency of up to 84 MHz, 256 KB of Flash memory, 64 KB of SRAM, SPI and I2C busses, and six general-purpose 16-bit timers including one PWM timer for motor control, two general-purpose 32-bit timers, two watchdogs, and 36 GPIO pins. It also implements a full set of DSP instructions and a memory protection unit (MPU).

The block diagram of the STM32F401CCU6 is demonstrated in the picture below.

STM32F401CCU6 hardware

Cost Breakdown of STM32F401CCU6

The cheapest STM32F401CCU6 costs approximately $2.14 on AliExpress, which puts it between the $1.7 ESP8266 and $2.5 EP32. But let's also compare the STM32F401CCU6 with other boards, like Teensy 4.1 and Arduino Mega.

The cheapest Teensy 4.1 can be purchased for $29.60 on the PJRC official website, while the cheapest Arduino Mega can be bought for approximately $8 on AliExpress.

STM32F401CCU6 price

Now you know their cost, let's examine the MCUs in terms of the raw processing power represented by the CoreMark points.

As you can see on the chart below, the STM32F401CCU6's CoreMark score is 21 times higher than that of the Arduino Mega and 21.47% lower than that of the ESP8266.

STM32F401CCU6 CoreMark

Knowing the starting price of each board, as well as their CoreMark score, let's calculate how much you would pay for one CoreMark point by using the following formula:

price per coremark formula

The price per CoreMark point for Arduino MEGA is 1.14 USD, so there's no point in putting it in the chart.

As you can see on the chart below, out of all boards examined in this article, the STM32F401CCU6 has the most expensive computing power represented by the CoreMark score. One CoreMark point for the STM32F401CCU6 costs 1.42 cents, 59.55% more expensive than the CoreMark point for the ESP8266. (If you consider ESP32 and ESP8266, you can buy them from PCBONLINE, which has strategic cooperation with the Espressif company.)

STM32F401CCU6 price per coremark

Software Capabilities of STM32F401CCU6

The STM32F401CCU6 microcontroller can be programmed in the STM32Cube IDE, Arduino IDE, and Mbed Studio IDE.

Since examining each IDE supported by the STM32F401CCU6 would be time-consuming, let's only focus on the software aspects accessible for this MCU board within the Arduino IDE using the Embedded C/C++ programming language.

The table presented below shows the compatibility of the STM32F401CCU6 with several libraries. These libraries, if compatible with the board, enable that specific board to control several displays, handle the input from the PS/2 keyboard, utilize cryptographic primitives, such as block ciphers, hash functions, and HMAC, exchange data with other boards, read RFID cards, interact with the SD card, work with the 4x4 keypad, and make use of rotary encoder and pushbuttons.

A green cell at the intersection of the board and the library indicates that the board is compatible with the library, while a red cell denotes a lack of compatibility between the two. All the libraries from the table are available on GitHub.

STM32F401CCU6 software capabilities

Code Examples of STM32F401CCU6

Before looking at the advanced projects utilizing the STM32F401CCU6, let's run some code samples on it to see what it's capable of.

Code Example N1

The first example contains the code that enables the STM32F401CCU6 to encrypt and decrypt data using the AES encryption algorithm. Note that in order for this code to work, the "aes.c" and " aes.h" files from the "Northstrix/ AES_in_CBC_mode_for_microcontrollers" repository must be placed in the same directory with the .ino file containing the code presented below.

STM32F401CCU6 code example 1

#include "aes.h"
uint32_t aes_mode[3] = {128, 192, 256};
uint8_t aes_key[32] = {
0x01,0x02,0x03,0x04,
0x10,0x11,0x12,0x13,
0x50,0x51,0x52,0x53,
0x7a,0x7b,0x7c,0x7d,
0xa0,0xa1,0xa2,0xa3,
0xbb,0xcc,0xdd,0xee,
0x32,0x33,0x34,0x35,
0xfc,0xfd,0xfe,0xff
};

void setup() {
Serial.begin(115200);
}

void loop() {
delay(3500);
int m = 2; // Set AES to 256-bit mode
String plaintext = "https://www.pcbonline.com/about/";
uint8_t first16[16];
uint8_t second16[16];
for (int i = 0; i < 16; i++){
first16[i] =  plaintext.charAt(i);
second16[i] =  plaintext.charAt(i+16);
}
uint8_t cipher_text1[16];
uint8_t cipher_text2[16];
aes_context ctx;
set_aes_key(&ctx, aes_key, aes_mode[m]);
aes_encrypt_block(&ctx, cipher_text1, first16);
aes_encrypt_block(&, cipher_text2, second16);
Serial.println("\n\nPlaintext: ");
Serial.print(plaintext);
Serial.println("\n\nCiphertext");
for (int i = 0; i < 16; i++){
if (cipher_text1[i] < 16)
Serial.print("0");
Serial.print(String(cipher_text1[i], HEX));
}
for (int i = 0; i < 16; i++){
if (cipher_text2[i] < 16)
Serial.print("0");
Serial.print(String(cipher_text2[i], HEX));
}
Serial.println("\n\nDecrypted");
uint8_t ret_text[16];
aes_decrypt_block(&ctx, ret_text, cipher_text1);
for (int i = 0; i < 16; i++){
Serial.print(char(ret_text[i]));
}
aes_decrypt_block(&ctx, ret_text, cipher_text2);
for (int i = 0; i < 16; i++){
Serial.print(char(ret_text[i]));
}
Serial.println("\n\n\n");
}

Code Example 2

The second code example contains code that enables the STM32F401CCU6 to compute a tag for the specified string using the HMAC-SHA256. Note that in order for this code to work, the "Crypto.cpp" and "Crypto.h" files from the "intrbiz/arduino-crypto" repository must be placed in the same directory with the .ino file containing the code presented below.

STM32F401CCU6 code example 2

#include "Crypto.h"

String input = "STM32F401CCU6";
byte hmackey[] = {"pcbonline.com"};

String compute_tag(String input) {
SHA256HMAC hmac(hmackey, sizeof(hmackey));
int str_len = input.length() + 1;
char input_arr[str_len];
input.toCharArray(input_arr, str_len);
hmac.doUpdate(input_arr);
byte authCode[SHA256HMAC_SIZE];
hmac.doFinal(authCode);
String cmptd_tag;
for (int i = 0; i < 32; i++) {
if (authCode[i] < 0x10)
cmptd_tag += "0";
cmptd_tag += String(authCode[i], HEX);
}
return cmptd_tag;
}

void setup(){
Serial.begin(115200);
}

void loop(){
delay(3500);
Serial.print("Input: ");
Serial.println(input);
Serial.print("Key: ");
for (int i = 0; i < sizeof(hmackey); i++)
Serial.print(char(hmackey[i]));
Serial.println();
Serial.print("Tag: ");
Serial.println(compute_tag(input));
Serial.println();
}

Code Example 3

The third code example contains code that enables the STM32F401CCU6 to encrypt and decrypt data using the Blowfish encryption algorithm. Note that in order for this code to work, the "blowfish.cpp" and "blowfish.h" files from the "ddokkaebi/Blowfish" repository must be placed in the same directory with the .ino file containing the code presented below.

STM32F401CCU6 code example 3

#include "blowfish.h"
void setup() {
  Serial.begin(115200);
}

void loop() {
Blowfish blowfish;
unsigned char key[] = "STM32F401CCU6 benefits from Blowfish";
blowfish.SetKey(key, sizeof(key));
Serial.print("\nPlaintext: ");
unsigned char text[] = "https://www.pcbonline.com/about/";
for (int i = 0; i < sizeof(text); i++)
Serial.print(char(text[i]));
Serial.print("\nKey: ");
for (int i = 0; i < sizeof(key); i++)
Serial.print(char(key[i]));
blowfish.Encrypt(text, text, sizeof(text));
Serial.print("\nCiphertext: ");
for (int i = 0; i < sizeof(text); i++) {
if (text[i] < 16)
Serial.print("0");
Serial.print(text[i], HEX);
}
blowfish.Decrypt(text, text, sizeof(text));
Serial.print("\nDecrypted: ");
for (int i = 0; i < sizeof(text); i++)
Serial.print(char(text[i]));
Serial.println();
delay(3500);
}

Advanced Projects Using STM32F401CCU6

Now you've had a glimpse of what the STM32F401CCU6 can do, let's explore the more advanced projects that showcase this board's capabilities.

Midbar (STM32F401CCU6 + Arduino Uno Version)

STM32F401CCU6 Midbar

Midbar (STM32F401CCU6 + Arduino Uno Version) is a hardware data vault that's developed to enhance data privacy by increasing the cost of unauthorized access to it. This vault can securely store login credentials, credit card information, notes, and phone numbers encrypted with the "3DES + AES + Blowfish + Serpent" encryption algorithm on an SD card connected to the STM. The STM32F401CCU6 handles the PS/2 keyboard, ST7789-controlled LCD, SD card, and cryptographic primitives, such as AES, Serpent, and HMAC-SHA256, while Arduino Uno handles the RFID card reader and random number generation.

STM32F401CCU6-powered VCP Monitor

STM32F401CCU6 VCP monitor

A mini-monitor powered by the STM32F401CCU6. It receives the image data over the VCP protocol and shows it on the TFT LCD connected to the STM32F401CCU6.

ZX Spectrum 48K emulator powered by the STM32F401CCU6

STM32F401CCU6 spectrum

The STM32F401CCU6 is powerful enough to emulate Sinclair Research's ZX Spectrum 48K and produce the grayscale output.

KhadashPay V3.0 (STM32F401CCU6 Version)

STM32F401CCU6 KhadashPay

This is a fully functional payment system built on the STM32F401CCU6, though it's not connected to any existing financial institutions.

STM32F401CCU6 RC Car

STM32F401CCU6 RC car

Another DIY RC car. This one utilizes the STM32F401CCU6 as its core.

Midbar (STM32F401CCU6 Version)

Midbar STM32F401CCU6 version

Midbar (STM32F401CCU6 Version) is an STM32F401CCU6 version of Midbar that came before the Midbar (STM32F401CCU6 + Arduino Uno Version). Aside from having some issues with the random number generation, it's a functional data vault.

STM32 Board PCB Assembly and Box-Build Manufacturer PCBONLINE

If you design an electronic product based on STM32F401CCU6 and want to turn your embedded design into real devices in your brand, you can work with PCBONLINE.

PCBONLINE is an electronics manufacturing services (EMS) supplier, providing PCB fabrication, PCB assembly, component sourcing, PCBA value-added, and box-build assembly until you receive the final products.

embedded PCB assembly PCBONLINE

Reasons to work with PCBONLINE for STM32F401CCU6 development board PCBA

PCBONLINE is a source factory manufacturer to provides you with one-stop electronics manufacturing at one-stop.

Relying on an EMS PCB assembly factory, PCBONLINE can source components at lower prices, including MCUs like STM32, ESP32, ESP8266, etc.

Engineers at PCBONLINE have powerful MCU-PCBA R&D capabilities and rich experience in solving technical issues.

We have mature, off-the-shelf MCU development solutions that you can pick up and adjust according to your demands.

High-quality and traceable electronics manufacturing certified with ISO9001:2015, IATF 16949, RoHS, REACH, UL, and IPC-A-610 Class 2/3.

We provide one-on-one engineering support throughout your embedded project developed based on any MCU, such as STM32F401CCU6. If you need PCBA and box-build assembly for your MCU boards, you can contact PCBONLINE by email at info@pcbonline.com.

Conclusion

Even though the STM32F401 doesn't support Wi-Fi out of the box, it's a functional development board that costs like a cup of coffee and has decent library compatibility. It's a great choice for a wide range of embedded systems, from consumer electronics to DIY projects, industrial equipment, and medical devices. To turn your embedded design into electronic boards and devices, choose PCBONLINE as your one-stop electronics manufacturer.

© This article is an original work of the PCBONLINE team. Please indicate the author PCBONLINE if you reprint. If the article is reproduced without permission or indicating the author's source, PCBONLINE reserves the right to investigate the infringement.
View and save our product information
PCB assembly at PCBONLINE.pdf

GET A FREE QUOTE

File Upload