Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clock settings easily selectible #21

Open
maxgerhardt opened this issue Mar 3, 2023 · 2 comments
Open

Make clock settings easily selectible #21

maxgerhardt opened this issue Mar 3, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@maxgerhardt
Copy link
Member

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.

@maxgerhardt maxgerhardt added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 3, 2023
@tmolteno
Copy link

tmolteno commented May 1, 2023

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.

@ldab
Copy link
Contributor

ldab commented Jun 29, 2024

One could simply add something like this to platformio.ini:

build_flags = 
  -DSYSCLK_FREQ_8MHz_HSI=8000000
  -USYSCLK_FREQ_48MHz_HSE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants