cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

alli_264371
Contributor

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
5 Replies