cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F769, generate a 2kHz clock on PC9.

AlbertC
Associate

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. 

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = 25;
  RCC_OscInitStruct.PLL.PLLN = 432;  
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 9;
  RCC_OscInitStruct.PLL.PLLR = 7;

HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_HSE, RCC_MCODIV_5);

 

Hope I can get the answer here, thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Great, thanks for your help.