MicroSD Cards and SDFS


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    mackrackit,

    In my project, data is read from the MicroSD card and sent to a TFT LCD display. As you can imagine, speed is very important. Let's say that I have the following bytes in my TXT file and I want to read them

    Code:
    203
    37
    92
    When you read these values with SDFS you get something like

    Code:
    FAT_dest[0] = 50     'ASCII number for "2"
    FAT_dest[1] = 48     'ASCII number for "0"
    FAT_dest[2] = 51     'ASCII number for "3"
    FAT_dest[3] = 13     'ASCII number for "CR"
    FAT_dest[4] = 10     'ASCII number for "LF"
    FAT_dest[5] = 51     'ASCII number for "3"
    FAT_dest[6] = 55     'ASCII number for "7"
    FAT_dest[7] = 13     'ASCII number for "CR"
    FAT_dest[8] = 10     'ASCII number for "LF"
    FAT_dest[9] = 57     'ASCII number for "9"
    FAT_dest[10] = 50     'ASCII number for "2"
    Then, you have to do some data manipulation to obtain the bytes that you need, 203, 37, and 92. This takes too much time . Is there any way or is there any format for my TXT file that I can use were I would obtain a SDFS reading like the following?

    Code:
    FAT_dest[0] = 203  
    FAT_dest[1] = 37
    FAT_dest[2] = 92
    This would speed up my program a lot and I would obtain much better graphics in my TFT display. Thank you for your help.

    Robert

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I do not have a good answer at the moment. I mostly use SD card for logging and yes the FAT file system can be a bit slow.

    How often is the display updated in your app?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    ........ and yes the FAT file system can be a bit slow.
    So, is the FAT32 (SDFSHC32) much faster than FAT (SDFS3)? I didn't go for the FAT32 because it takes a lot of space in the chip.

    The display changes whenever a new screen is selected and hopefully the transition should be smooth. What do you think would be the best way to read the data from the card the way I need it?

    Robert

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Can not say exactly but FAT32 should be a little slower, larger sectors to read I guess.

    Can you have the data on the card in CSV format instead of line by line? Be a little less reading.

    Might post your code, maybe someone will see something?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Can not say exactly but FAT32 should be a little slower, larger sectors to read I guess.
    Good guess! I did some research in google and FAT32 is slower than FAT. I think that I found a solution to the problem I'm having, but I have to test it before I post it here.

    My code is just the SDFS code, the EasyHID code, and the code to drive the TFT display all mixed together. I'm just testing everything together and so far my program is working fine.

    Robert

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    mackrackit,

    I probably found a way to speed up the process of writing to the TFT display. If you write bytes to the SD card with values from 0 to 255, which is what I need

    Code:
    ' Write to file
    FOR I = 0 TO 255
        FAT_src[0] = I
        FAT_count = 1
        Gosub FSfwrite
        Serout2 PORTC.6, 84, [ "Write ", Dec FAT_error, $d, $a]
        If (FAT_error != 0) Then Stop
    NEXT I
    The program will sucessfully write 256 bytes to the txt file (a bunch of weird characters ). Now, when you try to read them back, it will always give you wrong values between the byte 210th and the byte 250th. However, by using only 7 bits in every byte (from 0 to 127) I can make my display work pretty fast. Have you seen this happen to you? Any comments?

    Now, for some strange reason my SD card is only working the first time after I reprogram the 18F4550 chip. The second time that I restart the chip I get the following errors for the FSinit

    Code:
    FAT_error = 6
    SDC_status = 2 
    SDC_response = 63
    I know what the FAT_error = 6 is (Init error), but the others I'm not sure what they are. Have you encounter these kind of errors before? Remember, it always works right after I reprogram the MCU. Any ideas?

    Thank you for all your help

    Robert

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Not sure about the writing problem.

    The errors.
    Open SDFS and about 70 lines down it has the errors listed. #2 is "card not present", #63 I do not see.

    But, to get around the problem I have this in my "SDINIT" routine.
    Code:
    IF (FAT_error = 6) THEN SD_MAIN
    Here is a snippet from my code template.
    Code:
    '###############################################
     SD_MAIN:
        TOGGLE PORTD.7
        GOSUB SDINIT
        GOSUB SDFILENAME
        GOSUB SDOPEN_W
        GOSUB SD_WRITE
        GOSUB SDCLOSE
     RETURN      '##############################################################
    SDINIT:
    ' FSInit initializes the card and reads all the preliminary information from it
    Gosub FSInit
    Serout2 PORTC.6, 16572, ["Init: ", Dec FAT_error, " ", Dec SDC_status, " ", Dec SDC_response, $d, $a]
        IF (FAT_error = 6) THEN SD_MAIN
        If (FAT_error != 0) Then Stop
        ' Display card directory
        Gosub FINDfirst        ' Find first file on card
        While (FAT_error = 0)
            Serout2 PORTC.6,16572, [Str FAT_FileName\11, $d, $a]
            Gosub FINDnext    ' Find next file on card
        Wend
        RETURN
     '################################################################
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts