This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to set the date and time to the file on SD card or Flash disk on nRF52840

Hi

I'm trying to file open and write for logging temperature data and others on nRF52840.

I successfully open, read and write on SD card or flash in nRF52840.

I also have used  nrf_cal_set_time(year, month-1, day, hour, minute, second) in nrf_calendar.c successfully.

It's a great and file to display date and time.

But, after file creation using f_open(), f_write() and f_close(), I found that the default date&time of the file is always 01/01/2016.

I appreciate that if you let us know what is wrong from my side and how to change or set the date & time of file property.

Thanks

Minsoo Jang

Parents
  • Okay. I think I see now. In our SDK we don't use timestamps in the Fatfs library, and AFAIK we haven't done any testing with these timestamps either. This is an external library, and I have not been able to find where the time of day is set when _FS_NORTC is set to 1, so I'm afraid what help I can provide is rather limited...

    From ff.h: If the system does not have an RTC function or a valid timestamp is not needed, _FS_NORTC = 1 is set to disable the timestamp function (so you won't be able to get the current time like this). If _FS_NORTC = 1 all objects will have a fixed timestamp defined by the _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR. To enable timestamp functionalities, the get_fattime() function needs to be added to the project and you'll have to get the current time from a real-time clock.

    Best regards,

    Simon

Reply
  • Okay. I think I see now. In our SDK we don't use timestamps in the Fatfs library, and AFAIK we haven't done any testing with these timestamps either. This is an external library, and I have not been able to find where the time of day is set when _FS_NORTC is set to 1, so I'm afraid what help I can provide is rather limited...

    From ff.h: If the system does not have an RTC function or a valid timestamp is not needed, _FS_NORTC = 1 is set to disable the timestamp function (so you won't be able to get the current time like this). If _FS_NORTC = 1 all objects will have a fixed timestamp defined by the _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR. To enable timestamp functionalities, the get_fattime() function needs to be added to the project and you'll have to get the current time from a real-time clock.

    Best regards,

    Simon

Children
Related