2021-11-26 07:21 AM
it seems my project hangs at this line ?
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
What could be wrong?
2021-11-26 08:46 AM
Is this a custom board or known good hardware? Seems like you have a problem with the LSE connection.
You can try increasing the timeout value (LSE_STARTUP_TIMEOUT) to tens of seconds to see if it helps.
Edit:
Also, "hangs" is ambiguous. It is expected that the LSE will take some time to become stable. Does it return successfully after a few seconds or does it fail and return HAL_TIMEOUT?
2021-11-29 12:37 AM
Its a custom board, i will show the schematic and PCB design.
increasing timeout does not help.
After further investigation i see the Backup Domain Write Protection disabling goes in timeout.
Can't figure out why this is happening.
Any idea's?
/* Wait for Backup domain Write protection disable */
tickstart = HAL_GetTick();
while(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
{
if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
}
2021-11-29 01:47 AM
Is there a write to the DBP bit before the snippet you've posted?
Read out and check if RCC_APB1ENR.PWREN is set.
JW
2021-11-29 01:57 AM
There is a write to PWR_CR_DBP before the snipped i posted, but the bit refuses to set
yes PWREN bit is set
I notice that the external xtal is not running, (measure nothing on scope), does this have influence at that point of the initialisation?
Wondering why i dont measure anything, as this is a recommended part by STM. I have tried all "LSE drive capability settings"...