Author Topic: Error when uncomment SDCARD_SUPPORT  (Read 7077 times)

Offline dep937

  • Newbie
  • *
  • Posts: 6
    • View Profile
Error when uncomment SDCARD_SUPPORT
« on: October 22, 2012, 03:09:52 PM »
When I uncomment the line to get SD Card support I have some errors.

Code: [Select]
#define SDCARD_SUPPORT                                                 // SD-card interface
#ifdef SDCARD_SUPPORT
    #define SD_CARD_RETRY_INTERVAL       5                               // attempt SD card initialisation at 5s intervals
    #define UT_DIRECTORIES_AVAILABLE     5                               // this many directories objects are available for allocation
    #define UTMANAGED_FILE_COUNT        10                               // allow this many managed files at one time
    #define UTFAT_LFN_READ                                               // enable long file name read support
    #ifdef UTFAT_LFN_READ
        #define MAX_UTFAT_FILE_NAME     (100)                            // the maximum file name length supported
    #endif
    #define UTFAT_WRITE                                                  // enable write functions
    #ifdef UTFAT_WRITE
        #define UTFAT_FORMATTING                                         // enable formatting SD cards (requires also write)
        #define UTFAT_FULL_FORMATTING                                    // enable formatting SD cards including zeroing of data sectors as well as FAT sectors
    #endif
    #define UTFAT16                                                      // support FAT16 as well as FAT32
    #define SUPPORT_FILE_TIME_STAMP                                      // when activated fnGetLocalFileTime() must exist, which return the date and time information
#endif

This is the list of error, I try to follow, but I cant find what is wrong.
 
compiling LPC17XX.c...
..\..\..\Hardware\LPC17XX\LPC17XX.c(315): warning:  #111-D: statement is unreachable
..\..\..\Hardware\LPC17XX\LPC17XX.c(4484): error:  #20: identifier "ucSeconds" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4485): error:  #20: identifier "ucMinutes" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4486): error:  #20: identifier "ucHours" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4487): error:  #20: identifier "ucDayOfMonth" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4488): error:  #20: identifier "ucMonthOfYear" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4489): error:  #20: identifier "usYear" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4490): error:  #20: identifier "ucSeconds" is undefined
..\..\..\Hardware\LPC17XX\LPC17XX.c(4491): error:  #20: identifier "usYear" is undefined

I think that this must be a silly mistake, but can´t find it.

Thanks

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Error when uncomment SDCARD_SUPPORT
« Reply #1 on: October 22, 2012, 04:00:22 PM »
Hi

It looks as though the define SUPPORT_FILE_TIME_STAMP is the problem. Thsi enables a time/date stamp to be written to the SD card each time files/directories are created or file content edited. In the version V1.4-1 for the LPC17xx this is not supported correctly by the RTC.

I have a new version that needs some more tests before being released but does have this supported. It also needs the RTC to be enabled and configured - also set up with the correct time/date to work correctly. Below is the code at the location generating the error in your present case - it will be seen that some variables have been replaced for some direct RTC accesses. It may be adequate for this to work but there is no guaranty (seeing as though the RTC does need to be configured correctly before - which may/or may not be the case).

Code: [Select]
// This routine supports date and time stamping of files and directories. If the information is not available it could return 1
// so that a fixed stamp is set. It is assumed that the RTC in the LPC17xx will be used if the support is activated
//
extern int fnGetLocalFileTime(unsigned short *ptr_usCreationTime, unsigned short *ptr_usCreationDate)
{
    unsigned short usSec;
    unsigned short usMinutes;
    unsigned short usHours;
    unsigned short usDayofMonth;
    unsigned short usMonthofYear;
    unsigned short usYear;

    do {
        usSec = (unsigned short)RTC_SEC;                                 // get a snap shot from RTC variables
        usMinutes = (unsigned short)RTC_MIN;
        usHours = (unsigned short)RTC_HOUR;
        usDayofMonth = (unsigned short)RTC_DOM;
        usMonthofYear = (unsigned short)RTC_MONTH;
        usYear = (unsigned short)RTC_YEAR;
    } while (usSec != (unsigned short)RTC_SEC);                          // if there was a second overflow while collecting the date repeat (saves disabling interrupts)
    if (usYear < 2011) {                                                 // if the year is invalid report that there is no valid time/date
        return 1;                                                        // utFAT will take fixed timestamp instead
    }
    *ptr_usCreationTime = (usSec | (usMinutes << 5) | (usHours << 11));
    *ptr_usCreationDate = (usDayofMonth | (usMonthofYear << 5) | ((usYear - 1980) << 9));
    return 0;                                                            // successful
}

Regards

Mark