Other Parts Discussed in Thread: MSP430FR5994
I have attached a camera to the MSP430FR5994 launchpad and use the Out-Of-Box sample code to store a photos on the launchpad's SDCard. I successfully store images and create log files. But the hour field in file time/date stamps are wrong - they are 1 hour less than specified value (hour 5 becomes 4, hour 6 becomes 5).
My code has a default time-stamp calendar and allows a user to change it ("calendar" is a "Calendar struct" which hold the fields of the time-stamp. The debugger shows the correct value in the calendar fields. So the problem is downstream (I think). The mmc.c translation unit (HAL library) has get_fattime() function which is called by FATFS to pack the calendar into a DWORD (per the DOS format). This function had a bug which I corrected (the original failed to shift the "seconds" field to the right 1 bit position). But other than this, the FATFS system is unchanged.
Can anyone running the sample code on the msp430FR5994 launchpad confirm that files are created at the expected times? If this problem is unique to my porting then any guidance is most appreciated.
Jim
Below are five items:
- The first item is the modified get_fattime() code snippet.
- the second image shows the default calendar settings in the code window. The terminal window (lower right) shows the user supplied timestamp. Both use hour 05.
- the third image shows the sdcard's directory (viewed using a windows 10 machine). Here the date hour is 04. I expected 05.
- the fourth image shows the debugger window. it shows that calendar has the correct date values (hour 5).
- the fifth image shows a debugger window where the execution is breakpointed in the mkdir. The "tim" variable receives mmc's get_fattime() which should have the packed timestamp from calendar. The contents of the DWORD tim are 0x13156896 (HR:13, Min:04. sec:22). Certainly not what I expected (perhaps calendar holds the creation date of the directory but the directory was created around 5 as well so I don't understand this
thank you
jim
DWORD get_fattime(void) { DWORD tmr; /* Pack date and time into a DWORD variable */ Calendar curTime = sdInterface->sdGetRTCTime(); tmr = ((DWORD)(curTime.Year-1980)<<25) | ((DWORD)(curTime.Month) << 21) | ((DWORD)(curTime.DayOfMonth) << 16) | (curTime.Hours << 11) | (curTime.Minutes << 5) | (curTime.Seconds >> 1); //modified to truncate into two second intervals - jn return tmr; }