2024-10-17 04:13 AM
Hello,
I am using Nucleo-F401RE MB1136, want to run the board using the HSE, installed 8Mhz crystal on X3 with 22pf capacitors on C33 & C34 and 0 Ohm resistors on R35 & R37.
Using the CubeMx, configured the HSE pin as Crystal/Ceramic Resonator, set the clock in the Crystal Configuration for HSE as 8Mhz, tried both the ways, directly using HSE as System Clock and with using the PLL block.
Still not able to run the code as the code gets stuck in SystemClock_Config(void), no pulse is generated on the crystal.
Is there any step that i missed or some configuration, please guide me if possible. I am new into the Stm world. Provided the snippet of the CubeMx generated code.
Thank You
__weak HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
{
uint32_t tickstart;
uint32_t pll_config;
/* Check Null pointer */
if (RCC_OscInitStruct == NULL)
{
return HAL_ERROR;
}
/* Check the parameters */
assert_param(IS_RCC_OSCILLATORTYPE(RCC_OscInitStruct->OscillatorType));
/*------------------------------- HSE Configuration ------------------------*/
if (((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE)
{
/* Check the parameters */
assert_param(IS_RCC_HSE(RCC_OscInitStruct->HSEState));
/* When the HSE is used as system clock or clock source for PLL in these cases HSE will not disabled */
if ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_HSE) || \
((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_PLL) && ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSE)))
{
if ((__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET) && (RCC_OscInitStruct->HSEState == RCC_HSE_OFF))
{
return HAL_ERROR;
}
}
else
{
/* Set the new HSE configuration ---------------------------------------*/
__HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);
/* Check the HSE State */
if ((RCC_OscInitStruct->HSEState) != RCC_HSE_OFF)
{
/* Get Start Tick */
tickstart = HAL_GetTick();
/* Wait till HSE is ready */
while (__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
{
if ((HAL_GetTick() - tickstart) > HSE_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
}
Solved! Go to Solution.
2024-10-17 04:58 AM - edited 2024-10-17 04:59 AM
Incidentally, this could also be a source of error: if you have not removed SB16 or SB50 while trying to use your own crystal at X3, the crystal will be disturbed by the MCO of the ST-LINK/V2-1.
2024-10-17 04:51 AM - edited 2024-10-17 04:52 AM
Hello @AkshaySindal and welcome to the community,
Could you please share your ioc file?
Are you sure the crystal you mounted is OK?
2024-10-17 04:54 AM - edited 2024-10-17 04:57 AM
Meanwhile, you can use STLINK-MCO as clock source for the MCU instead of installing an external crystal.
The source of STLINK-MCO is generated from a 8MHz Crystal.
So, you need just to check that SB16 and SB50 are soldered. You need also to remove the crystal and the capacitors you've already soldered and configure HSE in Bypass mode.
2024-10-17 04:58 AM - edited 2024-10-17 04:59 AM
Incidentally, this could also be a source of error: if you have not removed SB16 or SB50 while trying to use your own crystal at X3, the crystal will be disturbed by the MCO of the ST-LINK/V2-1.
2024-10-17 04:58 AM
@AkshaySindal did you mistakenly mark the solution?
2024-10-17 05:16 AM
yes i did it by mistake!
2024-10-17 05:19 AM
2024-10-17 06:02 AM
I don't see an issue in the ioc file.
But did you check the recommendations shared by @Peter BENSCH , you need to disconnect STLINK-MCO from OSC_IN OSC_OUT pins of the MCU or just use STLINK-MCO as it is as I described in a previous comment.
2024-10-17 06:12 AM
I am trying his recommendation, can you please guide me on how to disconnect the STLINK-MCO from the MCU.
2024-10-17 06:27 AM
That's described in the board's User Manual.
See also the board schematics.