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

CREATE FILE WITH TIME AND DATE IN RL-FLASH

Hi, I'm using RL-flash and I would like to know how to set for create FAT file with time/date from RTC. All my files are 01/01/2008 12:00. Which register i can set to update this time and date?
Thanks

Parents
  • This is how it may look like:

    U32 fs_get_time (void)
    {
            U32 h,m,s,time;
            h = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_HOUR);
            m = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_MINUTE);
            s = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_SECOND);
            time = (h << 16) | (m << 8) | s;
            return (time);
    }
    
    U32 fs_get_date (void)
    {
            U32 d,m,y,date;
            d = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_DAYOFMONTH);
            m = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_MONTH);
            y = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_YEAR);
            date = (y << 16) | (m << 8) | d;
            return (date);
    }
    
    
    
    //in main file, in the function where file is created
    void FILE_Create()
    {
            ...
            fs_get_time();
            fs_get_date();
    
            file = fopen(filepath, "w");
            ...
    }
    

    RTC must be initialised and enabled before it is to be used, even if the RTC has a battery back up. The date, time registers need not be modified in the initialisation.

Reply
  • This is how it may look like:

    U32 fs_get_time (void)
    {
            U32 h,m,s,time;
            h = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_HOUR);
            m = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_MINUTE);
            s = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_SECOND);
            time = (h << 16) | (m << 8) | s;
            return (time);
    }
    
    U32 fs_get_date (void)
    {
            U32 d,m,y,date;
            d = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_DAYOFMONTH);
            m = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_MONTH);
            y = (U8)RTC_GetTime(LPC_RTC, RTC_TIMETYPE_YEAR);
            date = (y << 16) | (m << 8) | d;
            return (date);
    }
    
    
    
    //in main file, in the function where file is created
    void FILE_Create()
    {
            ...
            fs_get_time();
            fs_get_date();
    
            file = fopen(filepath, "w");
            ...
    }
    

    RTC must be initialised and enabled before it is to be used, even if the RTC has a battery back up. The date, time registers need not be modified in the initialisation.

Children