cancel
Showing results for 
Search instead for 
Did you mean: 

RTC GET_Time Help

Francesco Di Cecio
Associate
Posted on June 08, 2017 at 18:14

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;
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

6 REPLIES 6
Nesrine M_O
Lead II
Posted on June 09, 2017 at 14:57

Hi

Di_Cecio.Francesco

,

Have a look to this example under the STM32F4 cube firmware package it may be very helpful:

STM32Cube_FW_F4_V1.0\Projects\STM324xG_EVAL\Examples\RTC\RTC_Calendar

-Nesrine-

farouk majdoub
Associate II
Posted on June 15, 2017 at 17:06

Hello @

Di_Cecio.Francesco

,

you have to refresh time and date each time ;

while(1)

{

RTC_DateTypeDef sDate;

RTC_TimeTypeDef sTime;

HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);

HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);

Min=sTime.Minutes;

Hour=sTime.Hours;

Sec=sTime.Seconds;

}

And check your default clock for RTC, LSE (Low Speed External ) or LSI ( Low Speed Internal,

if you will use LSE, you have to add (weld) extra component on the pcb, Quartz 32,768khz and two 22pf capacitors,

without these

component, the RTC time will always be Paused.

Farouk

Posted on June 15, 2017 at 17:23

Have you read the manual?

0690X00000607IIQAY.png

And read RM0090, 26.3.6  Reading the calendar.

JW

Posted on July 03, 2017 at 02:27

Hello

Waclawek.Jan

by the way, i want to ask you about this manual, from where did you get this format (*.hlp or *.cnt) ? (like in the screenshot)

all documents that i have are in pdf format!

thanks !!

Farouk

Posted on July 05, 2017 at 23:52

Farouk,

this screenshot is from [STM32Cube_FW_F4_V1.4.0]\Drivers\STM32F4xx_HAL_Driver\STM32F417xx_User_Manual.chm

Jan

Posted on July 09, 2017 at 07:53

Big thanks Jan,

Farouk