SDIO - Update the modified time of files in SD Card

  • Ameba x 1
  • SD card or MicroSD card x 1
  • SD sniffer x 1 (optional)
In the previous examples, the “last modified time” of the directories and files created by Ameba are all the same. This is because that Ameba did not retrieve the time when it creates the directory/file, it uses a predefined time value. This example shows how you can update the “last modified time”. Open the sample code in “File” -> “Examples” -> “AmebaSdFatFs” -> “last_modified_time” Compile and upload to Ameba, then press the reset button. Execution result screenshot: 1 You can further try to use time components(e.g., NTP, RTC,…) to get accurate time value.
Code reference
The initialization and create files part are introduced in previous examples. To update “last modified time”, we use setLastModTime(). The first argument is the absolute path of the file, and the following six arguments are year, month, day, hour, minute, second.
fs.setLastModTime(absolute_filename, year, month, date, hour, minute, second);
To retrive the last modified time of a file, you can use getLastModTime().
fs.getLastModTime(absolute_filename, &year, &month, &date, &hour, &minute, &second);
Please confirm that QQ communication software is installed