Open maxgerhardt opened 1 year ago
Note to others :
I had to modify these settings to get my code to work properly when I chose my own target...
To modify your clock settings for your own board. You have to change the appropriate file. For the ch32v003, this file is
system_ch32v00x.c
At the top of the file, uncomment the appropriate line. I changed to the 48 MHz HSI clock using the following:
//#define SYSCLK_FREQ_8MHz_HSI 8000000
//#define SYSCLK_FREQ_24MHZ_HSI HSI_VALUE
#define SYSCLK_FREQ_48MHZ_HSI 48000000
//#define SYSCLK_FREQ_8MHz_HSE 8000000
//#define SYSCLK_FREQ_24MHz_HSE HSE_VALUE
//#define SYSCLK_FREQ_48MHz_HSE 48000000
To get to this file in VsCode, right click on the function SystemCoreClockUpdate() in your main.c. Then choose "go to definition". This will take you to the right file.
One could simply add something like this to platformio.ini
:
build_flags =
-DSYSCLK_FREQ_8MHz_HSI=8000000
-USYSCLK_FREQ_48MHz_HSE
With the default settings, we compile the
system_ch32v....c
file of the NoneOS SDK, which is default-configured for the development boards, requiring a HSE (external crystal oscillator of e.g. 8MHz) to work correctly.We need to adapt the .c file so that the user has the chance to select the appropriate clock for their board nicely and document it.