Home> Blog> Explore MCU Boards Based on Teensy 4.1 and STM32F407VET6

Explore MCU Boards Based on Teensy 4.1 and STM32F407VET6

Microcontroller
PCBONLINE Team Wed, Mar 20, 2024
510
Teensy 4.1 and STM32F407VET6

With each passing year, microcontrollers (MCUs) are getting more powerful and affordable. This trend has influenced developers to release open-source libraries that can be used by anyone free of charge. Embedded system engineers can learn to program these devices and develop their single-chip boards and even devices conveniently.

Without further ado, let's examine two MCU/single-chip boards with powerful microcontrollers: Teensy 4.1 and STM32F407VET6. This article also introduces printed circuit board (PCB) assembly services, which transform the design into real boards and final products.

Hardware Aspects of Teensy 4.1 and STM32F407VET6

Teensy 4.1 is a high-performance development board that boasts a powerful ARM Cortex-M7 processor operating at 600MHz, a Float point math unit (64 & 32 bits), 7936K Flash, 1024K RAM, 4K of emulated EEPROM, 55 digital input/output pins, 3 SPI busses, 3 I2C ports, SD Card slot, port Ethernet 10/100 Mbit, RTC for date/time, Cryptographic Acceleration & Random Number Generator.

STM32F407VET6 is a development board that features a 32-bit ARM Cortex-M4 processor operating at frequencies up to 168 MHz, 512K Flash memory, SD Card slot, up to 192K of RAM, 3 SPIs, and Up to 140 I/O ports with interrupt capability.

Cost Breakdown

Before delving into software capabilities, let's analyze what you're paying for in terms of hardware computing power when you buy these MCUs.

On the PJRC official website, the price for Teensy 4.1 starts at $29.60, while the cheapest STM32F407VET6 costs approximately $8 on Aliexpress. (The one-stop electronics manufacturer PCBONLINE also sources MCUs and components. It can be more affordable if you order in bulk from us.)

Microcontroller price

The microcontrollers have frequencies of 600 MHz and 186 MHz, respectively. But frequency alone doesn't provide you with much information about the processing capabilities. The actual processing power of the MCUs can be assessed by their CoreMark scores. At a default frequency of 600 MHz, the Teensy 4.1 has a CoreMark score of 2314 points, whereas the STM32F407VET6 achieves 363 points at a default frequency of 168 MHz.

CPU frequency

Now that the Frequencies of the MCUs integrated into the boards, as well as their CoreMark scores, are known, let's calculate how much you would pay for one CoreMark point by using the following formula:

price per coremark point

As you can see on the chart below, even though the Teensy 4.1 is more expensive than the STM32F407VET6, its processing power, represented by the CoreMark score, is actually cheaper than the processing power of STM32F407VET6. If the processing power of Teensy 4.1 had been priced equivalently to that of the STM32F407VET6, the price for Teensy 4.1 would've started from almost $51.

price per coremark

Software Aspects of Teensy 4.1 and STM32F407VET6

To their advantage, both Teensy 4.1 and STM32F407VET6 can be programmed in the Arduino IDE. This compatibility enables the developer to leverage a wide array of open-source libraries. Additionally, it minimizes the effort required to port code from one platform to another. In many instances, the developer may only need to reassign pins when porting the code because the same libraries are supported by both MCUs.

The table presented below shows the compatibility of each MCU with several libraries. I tested these libraries while working with both microcontrollers. Some of these libraries enable microcontrollers to interact with the ST7735 or ILI9341-controlled display, handle the PS/2 keyboard, or employ cryptographic primitives, such as block ciphers and hash functions. A green cell at the intersection of the board and the library indicates that the board is compatible with the library. In contrast, a red cell denotes a lack of compatibility between the two.

All the libraries from the table are available on GitHub.

libraries

Moreover, the Teensy 4.1 can interact with the USB keyboard connected to its built-in USB host, even if the keyboard is connected via a USB hub. Teensy 4.1 can also act as if it were a Human Interface Device (HID) device, like a USB mouse, keyboard, joystick, MIDI device, audio device, Flight Sim controls, and MTP disk. In theory, STM32F407VET6 should act as if it were an HID device, like a USB keyboard or mouse. Also, take into account that STM32F407VET6 has issues with properly getting input from the Serial Terminal, something that Teensy 4.1 has absolutely no problems with.

Application Of MCU Boards Based on Teensy 4.1 and STM32F407VET6

Aside from industrial automation, which is the most obvious case, single-chip computers or MCU development boards based on Teensy 4.1 and STM32F407VET6 can be used in various fields, such as home automation, automotive systems, consumer electronics, medical devices, robotics, etc.

The presence of a functional hardware random number generator (RNG) in both microcontrollers permits their use in cryptography-related fields where high-quality random number generation is essential.

Before getting into complex projects built on Teensy 4.1 and STM32F407VET6, take a look at these simple yet practical examples of what these Microcontrollers can do.

Example 1

STM32F407VET6 application example1
application example 1

In the first example, you can find the connection table and the code that enables the STM32F407VET6 to handle the Nintendo Wii Nunchuk. Note that in order for this code to work, the NintendoExtensionCtrl library must be installed.

STM32
Minimum pattern width/pattern interval
3V3
VCC
PB8
SCL
PB9
SDA
GND
GND

#include <NintendoExtensionCtrl.h>

Nunchuk wii_nunchuk;

bool pressed_c;
bool pressed_z;
bool held_left;
bool held_up;
bool held_right;
bool held_down;
byte threshold = 16;

void setup() {
Serial.begin(115200);
wii_nunchuk.begin();
while (!wii_nunchuk.connect()) {
Serial.println("Nunchuk not detected!");
delay(1000);
}
}

void loop() {
boolean success = wii_nunchuk.update(); // Get new data from the controller

  if (!success) { // Ruh roh
Serial.println("Controller disconnected!");
delay(1000);
} else {
if (wii_nunchuk.buttonC() == true) {
if (pressed_c == false) {
Serial.println("C");
}
pressed_c = true;
} else {
pressed_c = false;
}

    if (wii_nunchuk.buttonZ() == true) {
if (pressed_z == false) {
Serial.println("Z");
}
pressed_z = true;
} else {
pressed_z = false;
}

    byte XAxis = wii_nunchuk.joyX();
byte YAxis = wii_nunchuk.joyY();

    if (XAxis > (255 - threshold)) {
if (held_right == false) {
Serial.println("Right");
}
held_right = true;
} else {
held_right = false;
}

    if (XAxis < threshold) {
if (held_left == false) {
Serial.println("Left");
}
held_left = true;
} else {
held_left = false;
}

    if (YAxis > (255 - threshold)) {
if (held_up == false) {
Serial.println("Up");
}
held_up = true;
} else {
held_up = false;
}

    if (YAxis < threshold) {
if (held_down == false) {
Serial.println("Down");
}
held_down = true;
} else {
held_down = false;
}
}
}

Example 2

Teensy 4.11 application example2

The second example contains the code that enables Teensy 4.1 to generate random numbers using its hardware random number generator.

#define TRNG_ENT_COUNT 16

static uint32_t rng_index;

void trng_init() {
CCM_CCGR6 |= CCM_CCGR6_TRNG(CCM_CCGR_ON);
TRNG_MCTL = TRNG_MCTL_RST_DEF | TRNG_MCTL_PRGM; // reset to program mode
TRNG_MCTL = TRNG_MCTL_SAMP_MODE(2); // start run mode, vonneumann
TRNG_ENT15; // discard any stale data, start gen cycle
}

uint32_t trng_word() {
uint32_t r;
while ((TRNG_MCTL & TRNG_MCTL_ENT_VAL) == 0 &
(TRNG_MCTL & TRNG_MCTL_ERR) == 0) ; // wait for entropy ready
r = *(&TRNG_ENT0 + rng_index++);
if (rng_index >= TRNG_ENT_COUNT) rng_index = 0;
return r;
}

void setup() {
Serial.begin(115200);
while (!Serial);
delay(2000);
trng_init();
}

void loop() {
Serial.println(trng_word());
delay(100);
}

Example 3

Teensy 4.1 application LCD

In the third example, you can find the code that displays three text lines on the ILI9341-controlled LCD connected to the Teensy 4.1 via SPI.

#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS    39                                                        // TFT CS  pin is connected to Teensy pin 39
#define TFT_RST   40                                                        // TFT RST pin is connected to Teensy pin 40
#define TFT_DC    41                                                        // TFT DC  pin is connected to Teensy pin 41
                                                                            // SCK (CLK) ---> Teensy pin 13
                                                                            // MOSI(DIN) ---> Teensy pin 11

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

void setup() {
tft.begin();
tft.setRotation(1);
tft.fillScreen(0x0000);
tft.setTextColor(0xffff);
tft.setTextSize(2);
tft.setCursor(10, 20);
tft.print("It's me");
tft.setCursor(10, 45);
tft.print("Hi");
tft.setCursor(10, 70);
tft.print("I'm the PCBONLINE");
}

void loop(){

}

Complex Projects Using Teensy 4.1 and STM32F407VET6

Now that you've acquainted yourself with a glimpse of what these MCUs can do - let's explore the more complex projects that showcase the capabilities of both Teensy 4.1 and STM32F407VET6.

The Teensy 4.1, for example, can be used as a core of a complex synthesizer or to emulate an old Amiga computer. Let's start with the synthesizers:

Jeannie DIY Synthesizer

jeannie Teensy 4.1 application

Jeannie is an advanced DIY 8-voice polyphonic synthesizer built on the Teensy 4.1. It offers 15 banks of 63 waveforms, a waveshaper to fine-tune sound characteristics, and a multimode filter that provides low/high/band-pass functions. A built-in 16-step sequencer makes it possible to use this synthesizer as a groove box capable of producing entire tracks.

Dirtywave M8 Synthesizer + Sampler + Sequencer

ESP IoT Dirtywave M8

The Dirtywave M8 is a portable tracker sequencer and synthesizer built on Teensy 4.1. It comes with 8 tracks of instruments that can be freely assigned and offer a wide range of sounds encompassing waveform synthesis, FM, virtual analog, sample playback, and MIDI output.

Amiga Emulator on Teensy 4.1

Amiga emulator on Teensy4.1

The Amiga family of personal computers, introduced in the mid-80s, offered a significant advancement in graphics and sound capabilities compared to the previous 8-bit systems. Jean-Marc has created an Amiga emulator that utilizes a Teensy 4.1 microcontroller capable of emulating the Amiga systems computer at full speed. The games are loaded from the microSD card and can be accessed via a file list. Recently, Jean-Marc posted an update on Github that provides HDD support and improved sound.

Also, Teensy 4.1 and STM32F407VET6 can function as a core of a sophisticated data vault called Midbar.

Midbar (Teensy 4.1) V3.0

Midbar Teensy4.1

Midbar (Teensy 4.1) V3.0 is a secure data vault. It can store sensitive information like login credentials, credit card details, phone numbers, and notes. Midbar uses a combination of the "3DES + AES + Blowfish + Serpent" encryption algorithms in CBC mode to protect your data from unauthorized access and employs HMAC-SHA256 to verify the integrity of each record. This version of Midbar can also function as a book reader for books encrypted with the Serpent encryption algorithm in CBC mode.

Midbar (STM32F407VET6 + Arduino Uno Version)

Midbar STM32F407VET6

Just like Midbar (Teensy 4.1) V3.0, Midbar (STM32F407VET6 + Arduino Uno Version) is a data vault. The primary distinction between them lies in the PCBA used as a core of the device. Midbar (STM32F407VET6 + Arduino Uno Version) employs the STM32F407VET6 as its core and uses the Arduino Uno as a peripherals driver to take care of the RFID card reader and Nintendo 64 Controller.

PCB Assembly Services to Turn Your MCU Development Boards into Life

MCUs such as Teensy 4.1 and STM32F407VET6 are the main chips. To use them for single-chip computer development and IoT applications, such as smart mixers, projectors, and so on, you need to design them on a printed circuit board. Besides the PCB (printed circuit board) layout, you may need to work on the software and enclosure accordingly so that they can be made into the PCBA (printed circuit board assembly) and final products.

If you have developed an electronic product based on an MCU, such as Teensy 4.1 and STM32F407VET6, and want to have your design manufactured, you can have one-stop PCBA manufacturing from PCBONLINE to make them real products.

MCU board PCB assembly PCBONLINE

PCBONLINE, founded in 1999, has two large advanced PCB manufacturing bases, one PCB assembly factory, and an R&D team. It provides PCB fabrication, MCU and all the other component sourcing, PCB assembly, PCBA value-added, enclosures, and final product box build assembly.

Advantages of PCBONLINE in electronics manufacturing for MCU development boards

PCBONLINE has strong R&D and electronics manufacturing capabilities to meet your custom demands.

Relying on an EMS PCB assembly factory, PCBONLINE can take part in co-procurement with other larger EMS from original component factories directly, and all our component suppliers are first-class and have kept a long-term cooperation.

Provide software and hardware R&D and box build assembly for single-chip/MCU development boards, industrial control, FPGA boards, and IoT applications.

Affordable electronics manufacturing as PCBONLINE is a source factory PCBA manufacturer that independently completes electronics hardware building.

We protect your software property security. For IC programming, we can apply a temporary Cloud account only accessible by you, and you control the program transfer into the MCU directly without our downloading it into our computer first.

Free R&D, PCBA samples, and functional testing for bulky electronics production.

We have successfully manufactured many PCBA and final product projects for MCU development, industrial control, IoT smart appliances, wireless long-distance data transfer, and FPGA applications. Suppose you need electronics manufacturing, including R&D, PCB, components, electronic assembly, value-added services such as IC programming, and box-build assembly. In that case, you can send your inquiry to PCBONLINE by email at info@pcbonline.com.

Conclusion

Over time, Microcontrollers have evolved into all-in-one solutions with integrated processing units, memory, I/O ports, and other essential components on a single board. Nowadays, even an $8 single-chip board with a modern microcontroller can execute tasks comparable to the average home computer from the late 1980s, making it an attractive and economically viable choice to function as a core of various cost-effective and versatile embedded systems.

© 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