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
  • Hi

    I assume you have used the nrf5-calendar-example as reference for the nrf_cal_set_time() function? The nRF52840 will need to get the date/time from somewhere, and if you don't provide it, it seems like it falls back to the default 01/01/2016. In the default example, the application will wait for you to set the time over UART by entering the year, month, day, hour, minute and second in a terminal.

    Can you also provide some information on what SDK version you're using?

    Best regards,

    Simon

  • Hi

    Thank you very much for your reply and sorry for my late response.

    I'm developing program on SDK 12.0.2 and already has been used nrf5-calendar-example.

    As I said, nrf_cal_set_time(year, month, day, hour, minute, second) and print_current_time() are no problem when it runs on program. My programs run and display like following successfully:

    NPC5,190,03/26/21 - 19:37:18,25.91 C ,59.62 %,1002,4.4V

    NPC5,191,03/26/21 - 19:37:19,25.88 C ,58.39 %,1019,4.4V

    ...

    However, although I created new file(temper.csv) and write on the that file after nrf_cal_set_time and nrf_cal_get_time usage on program, the file's date is always  01/01/2016 when I see that file via USB port like following:

    test_temper.jpg (652×36)

    TEMPER.CSV 2016-01-01 AM 12:00 17KB

    I'm sure you must have simple solution for this matter.

    Thanks in advance

    Michael Jang

Reply
  • Hi

    Thank you very much for your reply and sorry for my late response.

    I'm developing program on SDK 12.0.2 and already has been used nrf5-calendar-example.

    As I said, nrf_cal_set_time(year, month, day, hour, minute, second) and print_current_time() are no problem when it runs on program. My programs run and display like following successfully:

    NPC5,190,03/26/21 - 19:37:18,25.91 C ,59.62 %,1002,4.4V

    NPC5,191,03/26/21 - 19:37:19,25.88 C ,58.39 %,1019,4.4V

    ...

    However, although I created new file(temper.csv) and write on the that file after nrf_cal_set_time and nrf_cal_get_time usage on program, the file's date is always  01/01/2016 when I see that file via USB port like following:

    test_temper.jpg (652×36)

    TEMPER.CSV 2016-01-01 AM 12:00 17KB

    I'm sure you must have simple solution for this matter.

    Thanks in advance

    Michael Jang

Children
Related