4.33.1. Module Files
The Real Time Clock (RTC) module uses an NXP PCF2131 IC as RTC.
The communication with the IC is made via I2C.
RTC_TIME_DATA_s is defined in
It holds the RTC data in the format of the IC.
To avoid reading the RTC IC frequently, an RTC system timer is defined
rtc.c with the name
It has the format
RTC_SYSTEM_TIMER_EPOCH_s. This struct has two elements:
the time in Unix format, which means seconds since January 1st 1970
an additional field with milliseconds
RTC_IncrementSystemTime() is used to increment the RTC
It must be called every millisecond.
It does the following:
increment the milliseconds field if its value is under 999
otherwise set the millisecond field to 0 and increment the time in Unix format by one second
A getter and a setter function have been defined:
They get or return an element of the type
The RTC system timer is set at startup via the function
It reads the RTC time from the RTC IC over I2C and uses the value to set
the RTC system timer.
To set the RTC Time over CAN, the queue
ftsk_rtcSetTimeQueue is used.
If a message to set the RTC is received, the data is written in the queue.
RTC_SetOverCanMessage() reads the queue if it is not empty,
and uses the data to set the RTC time of the IC over I2C and then to set
the RTC system timer value.
RTC_Trigger() function is called periodically. It calls