Skip to main content
Explorer
April 18, 2024
Solved

STM32F769, generate a 2kHz clock on PC9.

  • April 18, 2024
  • 1 reply
  • 921 views

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.

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    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.

    1 reply

    Graduate II
    April 18, 2024

    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.

    AlbertCAuthor
    Explorer
    April 30, 2024

    Great, thanks for your help.