Jeremy Hsiao

A minor RTC defect at the example of LPCUSBlib_MassStorageHost in LPCOpen 2.1

Discussion created by Jeremy Hsiao on Apr 21, 2017

In the example of LPCUSBlib_MassStorageHost in LPCOpen 2.1 for LPC1769, it seems that there is a minor code defect at setting RTC (time will be used in FAT32).

 

int rtc_initialize (void)
{
...
Chip_RTC_SetFullAlarmTime(LPC_RTC, &rtcTime);

...

}

 

It should be

 

int rtc_initialize (void)
{
...
Chip_RTC_SetFullTime(LPC_RTC, &rtcTime);

...

}

 

Besides, this function also seems to contain defect (but it is not called in example code):

 

int rtc_settime (const RTC *rtc)
{
RTC_TIME_T rtcTime;

rtcTime.time[RTC_TIMETYPE_SECOND] = rtc->sec;
rtcTime.time[RTC_TIMETYPE_MINUTE] = rtc->min;
rtcTime.time[RTC_TIMETYPE_HOUR] = rtc->hour;
rtcTime.time[RTC_TIMETYPE_DAYOFMONTH] = rtc->wday;
rtcTime.time[RTC_TIMETYPE_DAYOFMONTH] = rtc->mday;
rtcTime.time[RTC_TIMETYPE_MONTH] = rtc->month;
rtcTime.time[RTC_TIMETYPE_YEAR] = rtc->year;

Chip_RTC_GetFullTime(LPC_RTC, &rtcTime);

return 1;
}

 

It should be:

 

int rtc_settime (const RTC *rtc)
{
RTC_TIME_T rtcTime;

rtcTime.time[RTC_TIMETYPE_SECOND] = rtc->sec;
rtcTime.time[RTC_TIMETYPE_MINUTE] = rtc->min;
rtcTime.time[RTC_TIMETYPE_HOUR] = rtc->hour;
rtcTime.time[RTC_TIMETYPE_DAYOFMONTH] = rtc->wday;
rtcTime.time[RTC_TIMETYPE_DAYOFMONTH] = rtc->mday;
rtcTime.time[RTC_TIMETYPE_MONTH] = rtc->month;
rtcTime.time[RTC_TIMETYPE_YEAR] = rtc->year;

Chip_RTC_SetFullTime(LPC_RTC, &rtcTime);

return 1;
}

Outcomes