cancel
Showing results for 
Search instead for 
Did you mean: 

f_utime FATFS wrong time and date

gb
Associate
Posted on June 27, 2016 at 15:27

Hi .

I'm using FatFS on SDCARD with STM32F40x.

I call f_utime after closing a file that  I create.

I followed exactly this post

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex%5fmx%5fstm32%2ff%5futime&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=689

f_utime returns FS_OK = 0 but when I insert my SDCARD on my PC and I read the file I created , I find the date and time of file completed wrong (in Windows I don't see last modified field, in Total commander I see wrong date like 1/1/2096)

I verified that this instructions are correct

fno.fdate = (WORD)(((RTC_years1 - 1980) << 9) | RTC_months1 << 5 | RTC_daysm1);

    fno.ftime = (WORD)(RTC_hours1 << 11 | RTC_minutes1 << 5 | RTC_seconds1 / 2);

in debug I stop at this point and manaully check fdate and ftime: they are correct

return f_utime(obj, &fno);  //returns 0 -> ok

Any ideas?

Thanks

1 REPLY 1
troy1818
Senior
Posted on June 27, 2016 at 21:31

Hi,

Sounds strange, I would suggest to debug lower layers to see what is happening.

When calling f_utime you should get a call to the function disk_write() in the implementation file for fatFS (diskio.c ?). Make sure that this is happening.