AnsweredAssumed Answered

RTC GET_Time Help

Question asked by Francesco Di Cecio on Jun 8, 2017
Latest reply on Jul 9, 2017 by farouk majdoub

Plese.
I have some problems with RTC Calendar.
I do not understand how to use it. You can send me some examples for STM32f407VGTx Discovery. (HAL Library)
With HAL_RTC_SetTime (& hrtc, & sTime, RTC_FORMAT_BCD) I set the time: 05:05:00.
In the While loop, with HAL_RTC_GetTime (& hrtc, & sTime, RTC_FORMAT_BCD)
I would like to retrieve the time and see it increase but it is stopped.(05:05:00).

Thank you

Francesco Di Cecio.

 

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_hal.h

RTC_HandleTypeDef hrtc;

void SystemClock_Config(void);
void Error_Handler(void);
static void MX_GPIO_Init(void);
static void MX_RTC_Init(void);

uint8_t Hour;
uint8_t Min;
uint8_t Sec;


int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_RTC_Init();

  /* USER CODE BEGIN 2 */
  RTC_TimeTypeDef RTC_Time;
  while (1)
  {
    HAL_RTC_GetTime(&hrtc, &RTC_Time, RTC_FORMAT_BCD);
    Hour = RTC_Time.Hours;
    Min = RTC_Time.Minutes;
    Sec = RTC_Time.Seconds;

  }

}

Outcomes