Skip to content

examples: change all clocks for ch32v003 to use internal oscillator by default #87

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lokuciejewski
Copy link

Some examples for ch32v003 use SYSCLK_FREQ_48MHZ_HSE as their clock source which prevents them from working on any board that does not have the external oscillator installed.

I changed all examples to use SYSCLK_FREQ_48MHZ_HSI and added explicit clock initialisation in pwm example. Now the examples should work on any ch32v003 board.

@Codetector1374
Copy link
Member

Not sure if this is the right thing to do though, given that most examples are meant to work on specific boards / pinout etc. Changing the oscillator to HSI is not the only thing you need to change to have examples work on a different board than what is intended.

@lokuciejewski
Copy link
Author

Oh, my bad, I guess I must have missed that those are for specific boards. But I think it would be good to make the examples as board-independent as possible - after all, the hal is for the specific microcontroller, not any specific board.

@Codetector1374
Copy link
Member

Well I think being board specific is kind of unavoidable for embedded stuff. It can potentially be worked around with having configuration file etc but I think that actually does more damage than good, because it would add complexity to what is supposed to be a "simple example" use of the HAL.

The HAL is for the chip, not the board designed around it.

@lokuciejewski
Copy link
Author

lokuciejewski commented Mar 1, 2025

Yeah, I agree the examples should not be overcomplicated and I am not proposing to add any board-specific configuration files. Changing to internal oscillator shouldn't break the compatibility with these boards - it would only enable those examples to work on any ch32v003 chip.
But if you still think this is unnecessary, then I can just close this PR without merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants