I need help with trying to figure out how to set my time using a push button and the RTC peripheral on the STM32G031K8 board. I can't seem to figure out how to get it to increment instead it just keeps getting reset to 00:00:00.
What do I need to do to be able to be able to set the time through the use of a push button.
Is there a way to set the hours and min separately or does the RTC need to be set all at once?
Here is my call back function where I am trying to set just the hours for the time being.
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
RTC_TimeTypeDef sTime;
if (GPIO_Pin == B1_Pin ) {
HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD);
sTime.Hours++;
}
if (GPIO_Pin == B2_Pin) {
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
}
}Thanks
Jacamo