wch: discussion on the clock tree implementation #117781
Unanswered
nzmichaelh
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Similar to #110177, I thought I'd start a discussion on how to handle the ch32v clock tree. The problem I'm trying to solve is setting up the CH32V203 ADC clock, which must be less than 14 MHz, which means that the APB2 must be less than 112 MHz. See #115736 for related work.
The CH32V series, including the ch32v003, ch32v00x, ch32v20x/ch32v30x all have a Reset and Clock Control (RCC) unit that configures the clocks. The clock tree is similar but different and can be broken down into families:
The ch32v203rb tree seems to be the same as the ch32v208.
The main parts of the RCC are:
I've ignored the USB, Ethernet, and I2S clocks.
We use Devicetree to configure the tree. For example, a clock is defined for hsi, hse, and lsi like:
Clocks are then routed, such as setting the hsi as the pll input and the pll as the rcc input:
The
pllhas properties such as the multiplier, which are defined on the node and implemented in thewch_rccdriver.Peripherals reference a RCC clock like:
where the macro expands to
CH32V20X_V30X_CLOCK_CONFIG(APB2, 0), which includes the parent bus.The implementation has a mix of styles:
hsi, that expose the board configurationThis is a summary of the state. I'll follow up with a look into how the stm32 does this.
All reactions