Nano vs STM32F Prog space and Global variables

Hi Every one.

I down loaded the STM32F1XX libraries with the board manager and did a test.

The Nano with Blink (Build in examples)
Use 924 bytes of program storage
Global variables 9

The STM32F103C with its own Blink under other board examples
Use 12804 bytes of program storage
Global variables 2064

Why this huge increase on the STM32F?

Thanks in advance.

My best guess is the STM32F example implements ST's HAL (Hardware Abstraction Layer). Think of HAL as Arduino junk in steroids. But then again, the STM32F103C is a much much more complicated MCU than what is on the Arduino Nano, hence the extra junk of abstraction. The "clock initialization" alone would take up space that an AVR MCU can do is less than 5 lines of code or so.

The same applies to e.g. the Due.

You will have to look at what e.g. digitalWrite() exactly does.

My wild guess is that due to the internal 'complexity', more registers need to be manipulated. This might mainly be in the initialisation of the processor (init() function).

Add blinking of another pin in both codes and see how much the code grows in both cases; you don't need to physically connect a led. You can repeat for a third pin. Draw your conclusions based on that.

Blink on a nano is 924 bytes of program space.

Blink on a STM32F103C is 10196 bytes of program space.

Blink on a DUE is 10,864 bytes of program space.

Blink on a ESP32 is 198,834 bytes of program space.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.