[SOLVED] Why does my external clock (HSE) configuration not work?
Hi all!
I got something new for you. We have a pcb with an STM32f446re chip on it. For stability reason, we put an 20Mhz external clock on it, but the problem is, we are still running on 16Mhz (measured it with a toggled gpio on the oscilloscope.) The pulse should be 500ms long but results in 625ms.
Now, here is the system clock init function which is calles FIRST in the main:
void system_clock_config()
{
RCC_OscInitTypeDef rcc_osc_init {};
RCC_ClkInitTypeDef rcc_clk_init {};
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
rcc_osc_init.OscillatorType = RCC_OSCILLATORTYPE_HSE;
rcc_osc_init.HSIState = RCC_HSI_OFF;
rcc_osc_init.HSEState = RCC_HSE_ON;
rcc_osc_init.PLL.PLLState = RCC_PLL_ON;
rcc_osc_init.PLL.PLLSource = RCC_PLLSOURCE_HSE;
rcc_osc_init.PLL.PLLM = 10;
rcc_osc_init.PLL.PLLN = 100;
rcc_osc_init.PLL.PLLP = RCC_PLLP_DIV2;
rcc_osc_init.PLL.PLLQ = 2;
rcc_osc_init.PLL.PLLR = 2;
if (HAL_RCC_OscConfig(&rcc_osc_init) != HAL_OK)
{
while (true) {}
}
rcc_clk_init.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
rcc_clk_init.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
rcc_clk_init.AHBCLKDivider = RCC_SYSCLK_DIV1;
rcc_clk_init.APB1CLKDivider = RCC_HCLK_DIV4;
rcc_clk_init.APB2CLKDivider = RCC_HCLK_DIV2;
if (HAL_RCC_ClockConfig(&rcc_clk_init, FLASH_LATENCY_3) != HAL_OK)
{
while (true) {}
}
}
I created these configurations with help of cubeMX clock_configuration tool, it's all calculated for an 20Mhz HSE oscillator input.
EDIT: We unmounted the 20mhz oscillator and the programm did not start, so i guess HSE is working, but still, on 16Mhz. Why could that be?
Strongly appreciate your suggestions,
NG
