platformio / platform-ststm8

ST STM8: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/ststm8
Apache License 2.0
41 stars 26 forks source link

STM8S_BLUE c_cpp_properties.json wrong F_CPU #25

Closed ipa64 closed 3 years ago

ipa64 commented 3 years ago

Hi, By default F_CPU for STM8S_BLUE "STM8S103" is wrong in the c_cpp_properties.json file "F_CPU=160000000L" (160MHz) instead of "F_CPU=16000000L" (16MHz)

Thank you

ipa64 commented 3 years ago

Hi, that was my mistake in fact c_cpp_properties.json is build from platformio.ini But: After debug I noticed F_CPU default value is 1600000UL (1,6Mhz), but I didn't find where is it defined. Yes I can redefined it but it could be better to modify the definition file for this board.

Edit on 30.10 In fact by default STM8s103f3 run on HSI at 2MHz, that should be the default value in board definition.

Thank you

maxgerhardt commented 3 years ago

It's defined in

https://github.com/platformio/platform-ststm8/blob/cc3da36621bc32e1df23cc110963daeb6e1b187c/boards/stm8sblue.json#L5

And according to datasheet (https://www.st.com/en/microcontrollers-microprocessors/stm8s103f3.html) that's the maximum frequency. If a project / board doesn't have an HSE, users can always redefine it in the platformio.ini with

board_build.f_cpu = 2000000

just like docs show.

valeros commented 3 years ago

The f_cpu field contains the max frequency. Please edit this value if you need as @maxgerhardt suggested.