News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

SD Card FAT16/32 "Date created" issues

Started by trastikata, Sep 10, 2023, 04:49 PM

Previous topic - Next topic

trastikata

Hello all,

today I had some free time and decided to make a SD card file explorer for a touch screen but have some issues, maybe someone could give me a hint where might be the problem.

Browsing and displaying Directories and Files is OK, except (please refer to the two attached screenshots):

- The size I get from the SD card is 1KB less for every file
- For one of the files "RF.JPG", the hour when the file was modified is +1 compared to the PC version

What could be the reason for the lost kilobyte and the extra hour for one of the files? Obviously the FAT offsets are correct, so what am I missing here?

PC.jpg
SC.JPG

Wimax

#1
Hello Trastikata,

In my application I have only the root directory where all the files are expected to be. I had the problem to retreive the date & time creation infos back from the SD and to send these information via a serial link together with the file names and extensions.
I modified the Proc FAT_FindRootDirEntry:

Case 2
                    '
                    ' Once found first $00 entry, must have reached end of valid files in directory
                    '
                    If FAT_RootDirPosition(0) = 0 Then Return

                    If FAT_CheckFileEntryStatus(pFileDir) = True Then
                        Inc wRootDirFileNum
                        '
                        ' Found required entry in directory
                        '
                        If wRootDirFileNum = Disk_swFileSearchNumber Then
                            '
                            ' Transfer file name
                            '
                            bRootDirFilePos = 0
                            Repeat
                                FileName_Name[bRootDirFilePos] = FAT_RootDirPosition(bRootDirFilePos)
                                Inc bRootDirFilePos
                            Until bRootDirFilePos = 8
                            '
                            ' Transfer file extension
                            '
                            FileName_Name[8] = 0                            ' String terminator
                            Repeat
                                FileName_Name[bRootDirFilePos] = FAT_RootDirPosition(bRootDirFilePos)
                                Inc bRootDirFilePos
                            Until bRootDirFilePos = 11
                            FileName_Name[11] = 0                           ' String terminator
                            '*********************************************************
                            '** ADD VARS FOR TIME & DATE CREATION INFO  RETRIEVE    **
                           
                            Time[0]=FAT_RootDirPosition(14)
                            Time[1]=FAT_RootDirPosition(15)
                           
                            Date[0]=FAT_RootDirPosition(16)
                            Date[1]=FAT_RootDirPosition(17)
                            FAT_GetFileSize()                               ' Obtain the file size (in bytes)
                            Result = True
                        EndIf
                    EndIf

Comparing a DIR on the PC and the same via the MCU I see that the creation time & creation date seem to be correct, while file length (in KB) is always 1 KB smaller (File_dSize/1024, but it should be rounded to the next higher integer).
ALL.JPG