HAL_RTC_MSPInit generated code fails assert_params check in gpio initialization when "Generate peripheral initialization as a pair of .c/.h filer per peripheral" project option selected and PC13 is configured as RTC_OUT_CALIB.
The generated code in rtc.c passes zeros in GPIO_InitStruct to HAL_GPIO_Init, causing assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, (GPIO_Init->Pin))); to fail.
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(rtcHandle->Instance==RTC)
{
/* USER CODE BEGIN RTC_MspInit 0 */
/* USER CODE END RTC_MspInit 0 */
/* RTC clock enable */
__HAL_RCC_RTC_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**RTC GPIO Configuration
PC13 ------> RTC_OUT_CALIB
*/
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */
}
}Project settings:
STM32L071RBtx processor
Generate peripheral initialization as a pair of .c/.h files
Enable Full Assert checked
Firmware Package Name and Version: STM32Cube FW_L0 V1.12.1
Version 6.6.1 of STM32CubeMX
RTC Settings:
Activate Clock Source checked
Calibration set to "Calibration 1Hz"
PC13 configured as RTC_OUT_CALIB.
