1.39.17.48 RTC_RTCCTimeGet Function

C

void RTC_RTCCTimeGet (struct tm * currentTime )

Summary

Gets the current time and date.

Description

This function gets the current time and date. The time and date are returned in the struct tm structure. The isdst, tm_wday, tm_yday member of the currentTime data structure are not updated and should be ignored. The year specified in the tm_year field of current time will be years since 1900.

Precondition

RTC_Initialize must have been called for the associated RTC instance. The RTC should have been configured for Real Time Clock Calendar operation.

Parameters

Param Description
currentTime pointer to a struct tm type pointer which will contain the current time when the function return

Returns

None.

Example

struct tm initialTime;
struct tm currentTime;

RTC_Initialize();

// Set the time as 22:31:23 and date as 7 April 1980.
// The Reference Year Configuration in MHC should be within
// 64 years of 1980. Also note that tm structure needs the tm_year to
// specified as years since 1900.

initialTime.tm_sec = 23;
initialTime.tm_min = 31;
initialTime.tm_hour = 22;
initialTime.tm_mday = 7;
initialTime.tm_mon = 3;
initialTime.tm_year = 80;

RTC_RTCCTimeSet(&initialTime);

// Get the current time.
RTC_RTCCTimeGet(&currentTime);

Remarks

None.