Skip to main content
Graduate
September 26, 2025
Question

STM32F446RET6 Timer and clock

  • September 26, 2025
  • 1 reply
  • 178 views

Hi, 

 

I designed the us and ms delay functions using timer 2 and 4.

Junzhe_0-1758900040115.png

Junzhe_1-1758900047568.jpg

 

Initially in the PLL source, I was using HSI, but it had some errors, so I switched it to HSE. I was using my delay function to control the DAC output, but when I switched to HSE, all my delay functions became twice as long.

Junzhe_2-1758900122851.png

This is my code.

while (1)

{

/* USER CODE END WHILE */

 

/* USER CODE BEGIN 3 */

 

HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 2854); //

Delay_us(500);

HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 868);

Delay_us(500);

HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 1861);

Delay_ms(10);

}

 This is the waveform of the oscilloscope.

Junzhe_4-1758900460320.png

 

 In the clock tree settings, I only switched the clock source to HSE, and the divider settings did not change. I wonder why this happened.

 

Best,

 

 

    This topic has been closed for replies.

    1 reply

    Super User
    September 26, 2025

    Change HSE to 8 MHz if that's what's on your board.

    You don't mention your board, but most of the ST boards have this as 8 MHz.

    TDK_0-1758903818500.png