2 years, 1 month ago.

About the time for SD card

Hi everyone. Thx for reading my question. i would like to ask the question about time for SD card. when i save the data the time always at 2028 1/1 just like below. /media/uploads/david8251/sd.png

i would like to fix it to the now's (time date) and next time when i save the data again if it can also automatically change the newest time. Another question is how can i use the newest date and time for my txt name automatically.

#include "mbed.h"
#include "SDFileSystem.h"
SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
int main() {
    int i=0,j=1;  
    mkdir("/sd/mydir", 0777);

        FILE *fp = fopen("/sd/mydir/sdtest.txt", "a");
        if(fp == NULL) {
            error("Could not open file for write\n");

Thx very much!!!

Comment on this question

1 Answer

2 years, 1 month ago.

I use a 1768 with SD Card .This is my solution:
The SD software use the RTC clock : see
You have to start the RTC and provide a backup battery during power-off. see
I hope this can help you


posted by jajn HA 28 Dec 2016

To post an answer, please log in.