RTC strange data with calendarTimeGet

Hi

We have a project with a custom pcb with a micro synergy R7FS5D97C.

We are using SSP version 1.7.5 and we are working with e2studio v7.8.0.

We are trying to work with the micro's RTC.

The code to initialize is the next:

subclk_st1 = g_cgc.p_api->clockCheck(CGC_CLOCK_SUBCLOCK); //This api return SSP_ERR_CLOCK_INACTIVE = 400

subclk_start = g_cgc.p_api->clockStart(CGC_CLOCK_SUBCLOCK, NULL); //This api return SSP_SUCCESS = 0

subclk_st2 = g_cgc.p_api->clockCheck(CGC_CLOCK_SUBCLOCK); //This api return SSP_ERR_CLOCK_ACTIVE = 401
R_BSP_SoftwareDelay(1900, BSP_DELAY_UNITS_MILLISECONDS); //Wait while subclock stabilizes

subclk_st3 = g_cgc.p_api->clockCheck(CGC_CLOCK_SUBCLOCK); //This api return SSP_ERR_CLOCK_ACTIVE = 401

g_rtc_init1 = g_rtc_clock.p_api->open(g_rtc_clock.p_ctrl, g_rtc_clock.p_cfg); //This api return SSP_SUCCESS = 0
if (g_rtc_init1 != SSP_SUCCESS) return g_rtc_init1;

R_RTC->RCR2_b.HR24 = 1; // Set 24 hour mode via direct reg access

subclk_st4 = g_cgc.p_api->clockCheck(CGC_CLOCK_SUBCLOCK); //This api return SSP_ERR_CLOCK_ACTIVE = 401

g_rtc_init2 = g_rtc_clock.p_api->periodicIrqRateSet(g_rtc_clock.p_ctrl, RTC_PERIODIC_IRQ_SELECT_1_SECOND); //This api return SSP_SUCCESS = 0
if (g_rtc_init2 != SSP_SUCCESS) return g_rtc_init2;

subclk_st5 = g_cgc.p_api->clockCheck(CGC_CLOCK_SUBCLOCK); //This api return SSP_ERR_CLOCK_ACTIVE = 401

g_rtc_init3 = g_rtc_clock.p_api->calendarCounterStart(g_rtc_clock.p_ctrl); //This api return SSP_SUCCESS = 0
if (g_rtc_init3 != SSP_SUCCESS) return g_rtc_init3;

subclk_st6 = g_cgc.p_api->clockCheck(CGC_CLOCK_SUBCLOCK); //This api return SSP_ERR_CLOCK_ACTIVE = 401

g_rtc_init4 = g_rtc_clock.p_api->irqEnable(g_rtc_clock.p_ctrl, RTC_EVENT_PERIODIC_IRQ); //This api return SSP_SUCCESS = 0
if (g_rtc_init4 != SSP_SUCCESS) return g_rtc_init4;

 

The configuration for the RTC driver is:

 

In the g_rtc_callback we have the next code:

if (RTC_EVENT_PERIODIC_IRQ == p_args->event)
{
if (_io_get_GLed_isOn) { _io_set_GLed_off; } //this led blinks every second correctly
else { _io_set_GLed_on; }

g_rtc_get_err = g_rtc_clock.p_api->calendarTimeGet(g_rtc_clock.p_ctrl, &g_system_time); //This api return SSP_SUCCESS = 0

}

Now when we paint g_system_time in the lcd with this function:
tft_bf_count = (uint16_t)sprintf ((char *)tft_buffer, "%i / %i / %i %02i : %02i : %02i ", g_system_time.tm_mday, (g_system_time.tm_mon + 1), (g_system_time.tm_year + 1900), g_system_time.tm_hour, g_system_time.tm_min, g_system_time.tm_sec);

the result in the screen is: 16 / 6 / 2020 13:160:120 where minutes and seconds have inconsistent values above 59.

 

Can someone help us? give us a clue that we are doing wrong.

 

Thanks