Could there be a bug in correcting daylight saving time (DTS) in the real-time clock (RTC)?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
alli_264371
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

I use PSoC 4200 BLE and RTC module with DTS correction and it only works correctly if the module is initialized in the same year.
When next year comes, the correction no longer works.
If I initialize the module at the end of the year, the correction will not work at all.
This is because the calculation of the Unix time value of the correction time occurs at the moment when it is applied, and it would be necessary to increment the value of the year so that the value of the Unix time corresponds to the next year.

</

void RTC_Update(void)
{
static uint32 RTC_currentTickNumber = 0u;
RTC_currentTickNumber += RTC_updateTimePeriod;

if(RTC_currentTickNumber >= RTC_tickRefOneSec)
{
RTC_unixTime++;
RTC_currentTickNumber =
(uint32) RTC_currentTickNumber - RTC_tickRefOneSec;

#if(0u != RTC_INITIAL_DST_STATUS)
if(RTC_unixTime == RTC_unixTimeDstStart)
{
RTC_dstStatus = 1u;
RTC_dstTimeOffset = RTC_SECONDS_PER_HOUR;
}

if(RTC_unixTime == (RTC_unixTimeDstStop - RTC_dstTimeOffset))
{
RTC_dstStatus = 0u;
RTC_dstTimeOffset = 0u;

Here mast be an increase of year value in RTC_dstStartTime struct and RTC_dstStopTime struct
RTC_unixTimeDstStart = RTC_GetDstUnixTime(&RTC_dstStartTime);
RTC_unixTimeDstStop = RTC_GetDstUnixTime(&RTC_dstStopTime);
}
#endif /* (0u != RTC_INITIAL_DST_STATUS) */

#if(0u != RTC_INITIAL_ALARM_STATUS)
if((RTC_unixTime + RTC_dstTimeOffset) == RTC_unixTimeAlarm)
{
RTC_currentTimeDate.status |= (1uL << RTC_STATUS_ALARM_OFFSET);
RTC_alarmCurStatus = RTC_alarmCfgMask;

RTC_unixTimeAlarm =
RTC_GetNexAlarmTime(RTC_unixTime + RTC_dstTimeOffset,
(uint8)RTC_alarmCfgMask);

/* Call callback function only after new alarm time is obtained.
* Cypress ticket #264756
*/
if (RTC_alarmCallbackPtr != NULL)
{
RTC_alarmCallbackPtr();
}
}
#endif/* (0u != RTC_INITIAL_ALARM_STATUS) */
}
}

/>

https://youtu.be/cqfrZvlawEo


I cannot confirm email and add messages due to a bug on your site, the email section is not active
0 Likes
1 Solution

Hello,

For RTC alarm functionality, please refer to the 'RTC_P4_WDT_Example' code example from the PSoC Creator. This example project demonstrates the basic operation of the RTC: set/get the current Date/Time, use the DST feature, and use the alarm feature. The project sends Date and Time and the alarm status over UART through terminal.

Thanks,
P Yugandhar.

View solution in original post

0 Likes
6 Replies