FAT32 SD cards use with sdfshc32d.pbp


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    68

    Default FAT32 SD cards use with sdfshc32d.pbp

    I used the sdfshc32d.pbp extension and it works great, but if the card socket fails so the card looses connection, the program freezez or, better say starts cycling around a piece of code and does not time out so everything stops working (no hardware SPI used and micro runs at 4 MHz)

    I tried to add a loop counter into the code and it seems to be working - if card is missing or it's connector failed it now normally returns and keeps going ignoring the card failure otherwise the timeout did not work - it seems to me it's original timeout counter does not work

    ...
    loopcount var byte
    loopcount= 0
    waitforcmdtimeout: 'THIS IS ORIGINAL SUBROUTINE LINE IN THE CODE
    if loopcount = 255 then
    SD_CS = 1
    return
    endif
    loopcount = loopcount +1
    ...


    Maybe someone can advise if and why my approach is not good...

    Thank you

    Alexey

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


    Did you find this post helpful? Yes | No

    Default Re: FAT32 SD cards use with sdfshc32d.pbp

    Are you using the Card Detect pin on the SD socket?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    68


    Did you find this post helpful? Yes | No

    Default Re: FAT32 SD cards use with sdfshc32d.pbp

    Hello Dave,

    No I do not. Actually my schematic allows me to use it but I prefer to let the process fail and return with a fault code then ignore it because I noticed socket i use may disconnect because of a hard vibration and I do not want this to cause failure of the whole system (it did not with FAT16 library but it does with FAT32). Also I want the system keep working (with lost ability for data logging) if the card dies. I was thinking to add use of the card detect switch to save some time on timeouts in the faulty situations which I can predict and design the system that may tolerate some unpredictable errors (like died card or faulty connector). My understanding is that the sdfshc32d.pbp does not use the card detect option itself although it does configure the input pin

    Thank you,
    Alexey

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


    Did you find this post helpful? Yes | No

    Default Re: FAT32 SD cards use with sdfshc32d.pbp

    What about something simple like
    If (FAT_error != 0) Then WhatEvever
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    68


    Did you find this post helpful? Yes | No

    Default Re: FAT32 SD cards use with sdfshc32d.pbp

    Hello Dave,

    I learnt that the subroutine waitforcmdtimeout: cycles indefinitely when card is not there and you try to make a record, so sdfshc32d.pbp does not return control into the main code and there is no way to check FAT_error status. I may check SD_CD before writing but I suspect that the same may happen if card dies and does not respond (or connector fails which already happened to me once and this is why I started panicing) and it seems that limiting sycles to 255 helps (I checked and normally my loopcount = 2 after return, so actually only one sycle is needed and 255 is more than enough but still does not make a critical delay).

    By the way, I have another strange thing here, do not know why - I have to initialize the card twice for it to work (tried many different cards, and all work only after init two times. This does not bother me too much, because it still works fine. I had the same with FAT16 library. Not sure, maybe all these things I have because my schematic does not have pull up resistors on card - perhaps need to try to add them to see if this changes something. However all works fine so far

    Alexey
    Last edited by Alexey; - 18th August 2012 at 09:23.

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


    Did you find this post helpful? Yes | No

    Default Re: FAT32 SD cards use with sdfshc32d.pbp

    The pull-ups are a must.

    As far as the 32 bit card routine not working is something I have not experienced. I use the same base code and only change the SD card include if it is a project that needs a 32 bit card.

    Have you seen this?
    http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 2

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