How to HSI stm32f103C8 and big memory usage

So the first thing to find out is which of the two STM32 you’re using (mapple or stm32 provided one). The board’s JSON file says

So the board speed setup is in

So you just have to define USE_HSI_CLOCK. Do that by adding

build_flags = -D USE_HSI_CLOCK

to the platformio.ini. That should be it and the board should be choosing the HSI & 72MHz configuration.

Note that this makes it impossibles to use the USB interface is it needs the HSE to generate a stable 48MHz for the USB system.

You may also try to use board = bluepill_f103c8.json to use the STM32 core (platform-ststm32/boards/bluepill_f103c8.json at master · platformio/platform-ststm32 · GitHub).

Well that’s just the thing with frameworks. Lots of boiler-plate code is compiled, even though your code just uses the GPIO and PWM (aka timers) on the board. You can generate .map files (Generate a .map file - #8 by krishna_chaitanya) and look at them using Amap | Sergey Sikorskiy to know which exact file / function / object is taking up which memory.