2021-10-20 6:49 AM
in software package STM32L0 1.12.1
in file stm32l0xx_hal_rcc_ex.c
in function
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)The RTC and LCD have their own settings, though they share the same clock.
These settings are usually handled correctly, e.g.
/*------------------------------- RTC/LCD Configuration ------------------------*/
if ((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)
#if defined(LCD)
|| (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LCD) == RCC_PERIPHCLK_LCD)
#endif /* LCD */
)but they're not correctly handled everywhere; at the end of the block quoted above, there is this initialization:
__HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);However, if the function was called to initialize the LCD and not the RTC, this is wrong, as it will disable the clock.
This is what that one-line init should actually be:
#if defined(LCD)
if((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)
&& (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LCD) == RCC_PERIPHCLK_LCD))
{
if(PeriphClkInit->RTCClockSelection != PeriphClkInit->LCDClockSelection) {
/* RTC and LCD share the same clock; cannot have different settings for the two of them */
return HAL_ERROR;
}
}
if((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)) {
__HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);
} else {
__HAL_RCC_RTC_CONFIG(PeriphClkInit->LCDClockSelection);
}
#else
__HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);
#endifHowever, you might probably want to do the RTCClockSelection!=LCDClockSelection check before this point, before touching other registers, to avoid leaving the system in an inconsistent state.
Solved! Go to Solution.
2021-10-25 9:10 AM
Hi @Community member ,
Thanks for bringing this limitation to our attention.
I reported it in an internal ticket to development team.
Internal ticket number: 116449 (This is an internal tracking number and is not accessible or usable by customers).
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2021-10-25 9:10 AM
Hi @Community member ,
Thanks for bringing this limitation to our attention.
I reported it in an internal ticket to development team.
Internal ticket number: 116449 (This is an internal tracking number and is not accessible or usable by customers).
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.