
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 |
MCU | Atmega328 | Atmega644 | Atmega1284 | Atmega2560 | SAMD21G18 | STM32F103C8 | STM32F401RC | ESP32WROOM |
Flash (Kb) | 32 | 64 | 128 | 256 | 256 | 64 | 256 | 1280 |
RAM (Kb) | 2 | 4 | 16 | 8 | 32 | 20 | 64 | 320 |
EEPROM (Kb) | 1 | 2 | 4 | 4 | | | | |
Bootloader size (Kb) | 0.5 | 1 | 1 | 8 | 16 | 20 | 20 | In ROM. |
"Blink" used Flash | 930 (3%) | 1122 (1%) | 1214 (0%) | 1460 (0%) | 10624 (4%) | 15828 (24%) | 23516 (4%) | 194472 (14%) |
"Blink" used RAM | 9 (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.
Related Articles
Today I came across some very interesting videos about professional frequency measurement error ( Agilent 53131A Frequency Counter Oven Upgrade) and it gave me the idea to better the precision...
Dear electronic hobbyist, If you are interested in small but powerful Arduino projects, you are going to love 644 Narrow and 1284 Narrow boards. These are basically beefed up Nano...
When I asked the potential users of the frequency counter I am working on their advice on the design, most of them wrote to me that they actually would...