Illusion14 300

This question is certainly in the minds of many electronics makers:

“Should I use a 32 bits microcontroller instead of an 8 bits microcontroller ?”

As an Arduino maker I considered upgrading some designs to STM32. So I ran preliminary tests. My first surprise was that my code was using much more storage space and I had to move to devices with even more flash and RAM. The fact that these devices run in 3.3V is another concern.

I will publish a paper on how to choose the rigt MCU for Arduino projects later. For now, let’s focus on the storage capabilities and resources needed to run a program created in the Arduino IDE.

The following table shows the storage capabilities and resources needed to run blink for a couple of  MCUs. Painted  in green are negligible consumption of less or equal to 1% and painted in yellow are consumptions above 1%. You will certainly be quite surprised:

Arduino Uno / Nano Arduino core
644 Narrow
MightyCore
1284 Narrow
MightyCore
Arduino Mega
Arduino core
Arduino Zero
Arduino core
Cortex M3
Blue pill
STM32duino core
Cortex M4
Arduino core_STM32
ESP32
Arduino
-esp32 core
MCUAtmega328Atmega644Atmega1284Atmega2560SAMD21G18STM32F103C8STM32F401RCESP32WROOM
Flash (Kb)3264128256256642561280
RAM (Kb)24168322064320
EEPROM (Kb)1244
Bootloader size (Kb)0.5118162020In ROM.
"Blink" used Flash930 (3%)1122 (1%)1214 (0%)1460 (0%)10624 (4%)15828 (24%)23516 (4%)194472 (14%)
"Blink" used RAM9 (0%)9 (0%)9 (0%)9 (0%)2732 (8%)3088 (15%)3244 (1%)13332 (4%)

So we can see that

  • The code generated for all 32 bits devices is much heavier. It is even incredibly big on ESP32!
  • These 32 bits MCU do not have EEPROM. They can use emulated EEPROM that consumes more flash resources.
  • The more complex the MCU, the bigger the bootloader. This also reduces the available resources.

The conclusion of this raw test is that if you don’t need the extra features of 32 bits MCUs (like many communication ports, more pins, possibly faster SPI etc), but your program needs a lot of flash and RAM, it is really worth considering last generation 8 bits MCUs. These devices architecture is mature. They are running pretty well, and offer huge storage capabilities, to the opposite of what we naturally believe.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *