2024-04-18 09:56 AM
Hi,
I'd like to have a 2kHz clock source on PC9, I was wondering if I can use TIM3_CH4 or TIM8_CH4 to do it. May you please help me to figure out it?
My question is how to generate a 2 kHz clock on PC9 if I would like to use TIM3_CH4 or TIM8_CH4?
However, I can generate a clock with MCO2 function on PC9. I use the commend below, and I can get 5MHz clock if I used MCO2 on PC9.
HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_HSE, RCC_MCODIV_5);
Hope I can get the answer here, thank you.
Solved! Go to Solution.
2024-04-18 10:17 AM - edited 2024-04-18 10:19 AM
Yes, you should be able to configure the TIM to toggle channel outputs
The PSC and ARR values are programmed with N-1 to Divide by N
Getting 1 MHz from 216 MHz would get a PSC of 216-1
Getting from 1 MHz to 4 KHz, ARR = 250-1
Toggling at 4 KHz would result in 2 KHz square wave.
CC4 = 0 ?? Bigger numbers would allow you to change phase wrt to other channels.
There should be some Toggle examples within the CubeF7 repository / board examples.
2024-04-18 10:17 AM - edited 2024-04-18 10:19 AM
Yes, you should be able to configure the TIM to toggle channel outputs
The PSC and ARR values are programmed with N-1 to Divide by N
Getting 1 MHz from 216 MHz would get a PSC of 216-1
Getting from 1 MHz to 4 KHz, ARR = 250-1
Toggling at 4 KHz would result in 2 KHz square wave.
CC4 = 0 ?? Bigger numbers would allow you to change phase wrt to other channels.
There should be some Toggle examples within the CubeF7 repository / board examples.
2024-04-29 06:51 PM
Great, thanks for your help.