I’m very much still learning the STM32 and all my work starts so far starts with examples. I can run the VisualGDB NewEmbedded Project -> STM32CubeMX Samples -> STM32F413ZH-Nucleo -> Examples -> RTC -> RTC_Calendar and it seems to work fine. But when I put it in a larger app that started from the VisualGDB UART tutorial, it doesn’t. I think I’ve tracked it down to the RTC_EnterInitMode subroutine in stm32F4xx_hal_rtc.c. It looks like HAL_GetTick isn’t incrementing the tickstart value:
tickstart = HAL_GetTick();
/* Wait till RTC is in INIT state and if Time out is reached exit */
while((hrtc->Instance->ISR & RTC_ISR_INITF) == (uint32_t)RESET)
{
if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
}
I’ve been trying to figure out what the STM32 HAL RTC example might be doing to make HAL_GetTick work but I’m not doing in the app I wrote from the VisualGDB UART example. I don’t know if it makes any difference but my app is C++ and the HAL RTC example is straight C. My code does have a SysTick_Handler in main.cpp as shown below. The HAL example seems to bury the SysTick_Handler in various other files but it does seem to do the same thing.
void SysTick_Handler(void)
{
HAL_IncTick();
HAL_SYSTICK_IRQHandler();
}
Any suggestions will be greatly appreciated.