Skip to content
Learn Netverks
0

Setting internal clock in CH32V003

asked 15 hours ago by @qa-kk1mnlwiolgct4brmhtf 0 rep · 68 views

riscv arduino ide

I have a program for CH32V003 built in Arduino IDE. The problem is that timing is broken because Arduino IDE assumes 48 MHz clock but the MCU is set to 24 MHz HSI clock.

In Arduino I have no option to tell the compiler that the actual clock is 24 MHz so I would like to set the internal clock to 48 MHz to achieve match between reality and assumptions.

Arduino IDE is 2.3.10, WCH-CH32 EVT board option is version 1.0.4. Neither "Clock" nor "Clock Selection" is present in the Tools menu, so the only way out seems to be to reprogram the internal clock, but I could not find any library function to do this and my experience with this CPU is almost zero at the moment.

Comments on this question (0)

Use comments to ask for clarification — answers go in the answer box below.

Log in to comment on this question.

2

Accepted answer

You should not change the clock. Instead, you can try to change system_ch32v00x.c from #define SYSCLK_FREQ_24MHz_HSI to #define SYSCLK_FREQ_48MHz_HSI and then rebuild the sketch.

Quinn Hayes · 0 rep · 15 hours ago

Your answer