after some package struggling i got my code compiling for a bare STM32f103C8 but i want to run it on the internal HSI. i use Arduino Framework and after some research i found that i need to add or change some code anywere for using HSI instead of external crystal. iĀ“ve soldered the chip with some other components on a pcb with 4pin ST LINK Header and without a crystal.
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.
then i thought the project needs some dedicated files, so i start a new project with bluepillf103C8. i then click on build and upload but the compiler give me the same problems cuz the project before. the compiler isnt in the new project. i can also close the wrong project from the workspace but it doesnt compile the right project ā¦ whats going wrong here? iĀ“ve also killed all terminal, press clean ā¦ no change at all
then on the bluePill project i removed @~4.5.0 and changed the pinMode PWM definition to OUTPUT and compiling works. iĀ“ve uploaded it to the chip but it doenst run cuz the HSI occurs not to be enabled. if i go to the OSC pin with my probe it starts to run but with very low speed.
Iām not quiet believing that PWM is unavailble for after 4.5.0, it should just be accessed differently? You should always try to use the latest version of everything.
Now youāre using a different board with a different STM32 core (the stm32 implementation), there the flag USE_HSI_CLOCK has no effect, The right way to overwrite the weak function used for clock initialization, as seen here
So you have to write in your main.cpp code a function
extern "C" { /* must use C-linkage */
void SystemClock_Config(void)
{
//init code here
}
}
Additionally you need lib_archive = no in the platformio.ini to make weak linking work.
The initialization code for the clock can be generated by using STM32CubeMX (STM32CubeMX - STM32Cube initialization code generator - STMicroelectronics). Start a new project for the STM32F103C8T6, go to the clock tree setup, select HSI and as input and 72MHz as the main CPU frequency, then let CubeMX solve for the PLL parameters. Then export the project and look at the src folder, a file in there will have the needed function for the clock setup.
it appears on every project iam working on. dont know how to fix this.
iĀ“ve tried updateing all my stuff but getting thousand compiler warnings now cuz BOOLEAN: