I'm using the stm32f3discovery board to try and generate the signal for a ws2812 light strip.
src/system_stm32f30x.c, which I copied from the StdPeriph examples. I'm currently using the internal HSI, and the clock speed is 48MHz.
I'm using gcc-arm-none-eabi-4_8-2014q3 to compile.
If I leave
src/system_stm32f30x.c as is, I get compiler warnings about unused variables, HSEStatus, and StartUpCounter, but my program works correctly. If I rename the variables to test1 and test2, it still works as expected, so it appears that it doesn't matter what the variables are named, it just matters that they are taking up memory (I guess).
However, if I comment these variables in order to get rid of the warning, my program no longer works correctly. The first pulse of the PWM signal is either grossly too short, or way to long. It causes the first LED on my strip to flash erratically (though the rest of the LEDs are fine).
My code is here: https://github.com/synic/neoclock/tree/stm32f303
What could it be?
#definedin your code?
system_stm32f30x.c, it looks like
StartUpCountershould never be defined IFF your code is using the HSI oscillator.
Their definition is in the code:
So, it appears that something is undefine-ing
PLL_SOURCE_HSI, and hence allowing
HSEStatusto be defined.
I can't see anything in the source file
src/system_stm32f30x.cto cause that.
src/system_stm32f30x.cfile at github is not the one being used in your build, or
PLL_SOURCE_HSIto become undefined and
PLL_SOURCE_HSEto be defined (which seems unlikely to get both), or
stm32f30x.hcontains a syntax error which is causing some of this.
1 and 3 seem more likely.
Those two variables are local to SetSysClock. So their names can be safely changed.
Commenting out their definition should cause the compile of that source file to fail.
If the build is producing a program, then
src/system_stm32f30x.cis not part of the program, or an old object is being used, or their is an inconsistency in the question.
If the HSI oscillator is being used in one case, and not in another, it is plausible that the PWM period is inconsistent.