Menu

SD card 16Gb managing basic difficulties found

2019-06-15
2019-10-06
  • Giuseppe D'Elia

    Giuseppe D'Elia - 2019-06-15

    Hi all,
    I tried to manage a SD card by exploiting the SD.h library in the last release of GCB.

    Unfortunately, I have not yet succeed to initialize the card, despite many attempts.

    I read the involved Sections of the Part1_Physycal_Layer_Simplification_Ver.6.00 and I wrote a very simple initialization code.
    Although I followed the directives of the aforementioned document, I still had not success.

    The first command, the CMD0 one, seem working. As a matter of fact I received a R1=0x01 response.

    However, the second command, the CMD8 one , that is necessary (I think) for my card, does not receive any response. In fact, I read a 0xff response.

    Accordingly, I considered also the possibility that my card is a V1 type and I used directly the CMD1 command instead than CMD8. The received response is 0xFF, still wrong.

    I attach the code.

    I hope somebody can help.
    Thanks

     
  • Anobium

    Anobium - 2019-06-15

    Hi

    Try a card of 2gb or less, or, use the code posted to the forum to write raw blocks to the card.

     
  • Giuseppe D'Elia

    Giuseppe D'Elia - 2019-06-16

    Hi Anobium,
    thank you for the answer.

    I checked the Init procedure used in the SD_565.h by Kent. It does exacly the some procedure I use till the final point after ACMD41.
    Accordingly, I think the problem is the card, a Samsung micro SDHC one.
    I will change the card first as soon as possible, according to your suggestion.
    Giuseppe

     
  • kent_twt4

    kent_twt4 - 2019-06-16

    I too had a problem with the SD V1 cards for the longest while. Until, I found they do not like a high speed clock. So 64MHz or 32MHz speed might not work, but 16Mhz would. Also be sure to respect <400 khz SPI rate during initialization per standards.

    Using the debug capabilities of the SD_565.h can tell you a lot about the card being used. Setup can be fickle. After multiple formats and abuse, a card can just stop working. The library has been tested up to 16GB or HC capacity.

    PS: I found a Saleae (clone) logic analyzer vital in seeing that command responses take effect. I bought the 8bit one, but wished I had the 16bit one for glcds.

     

    Last edit: kent_twt4 2019-06-16
  • Giuseppe D'Elia

    Giuseppe D'Elia - 2019-10-04

    @Anobium & Kent
    Hi All,
    For a wile I decided to be not concerned with the very serious problems I had with SD Card management. As it can be understand from this thread.
    I did'nt understand why everything was not warking at all.

    I was using two SanDisk 2GB , 4GB cards and a PNY 16 GB one, with the micro SD card support of ST7735 GLCD.
    Without any success!!
    I read the SD card Specification from the SD Association as well as those from SANDisk and so much internet. No success at all!

    Recently I bought a chinese micro sd card shield SPI. After that a lot is changed. I made a SD reading code by myself .
    Now I can read a 15GB PNY sd card very easily from my PIC18F45K42. Moreover, it also work with a 64MHz clock and a SPI_Baud_Rate_Register=7, i.e. with a 4MHz SPI clock. And this also at the initialization stage!! Very surprised, and unbeleaved. It is very stable.

    However, if I use the same code and the same card on the ST7735 Micro SD card support it does not work. Moreover, if I attempt to read the Sandisk 2GB and 4Gb sd cards on the new chinese shield with the new code they still does not work!!
    As a conclusion, I believe that these cards are not fine. Also, in my opinion, the ST7735 SD card support is not fine too.

    Now the interesting news.
    I made a code managing the files and directory on the card. Obviously, due to the limited amount of DMA I can go down the directory three how i want. However I cannot go up the three but for jumping directly to the Root directory.
    It seem to work fine.

    I also managed the BMP standard and I have build a code to read a .BMP image from the SD card and download it on the ST7735 GLCD. I managed the transition from the 24bits per pixel of the BMP standard to the RGB 565 of the ST7735. It seem to work fine.

    Now I'm happy.
    I attach a picture of the ST7735 with the image.

    The very surprise is that everything, i.e., code, compiler and GLCD is very stable at the highest clock frequency.

    
    
     
  • Anobium

    Anobium - 2019-10-04

    well done!!

     
  • kent_twt4

    kent_twt4 - 2019-10-04

    Excellent work!

    The 2GB and 4GB cards are probably good? My notes say that SPI fast will not work with (some or all?) SCSD cards if that's what they are.

    Using fast SPI during initialization may work for some cards, but for backward or SD specs compatibility you don't lose much with SPI slow during this period.

     
  • Giuseppe D'Elia

    Giuseppe D'Elia - 2019-10-06

    @ Anobium and Kent,
    Thank you for your answers. Unfortunately it is not how Kent has supposed.

    I made all the work with the oscillator frequency equal to 8MHz and the SPI parameter baudrate equal to 31. This correspond to a SPI frequency of 128KHz
    ( according to the the PIC 18F45k42 datasheet, the SPI frequency is given by the formula Freq_Osc/(2(1+Baud_param)) ) ,
    well under the maximum one prescribed by the SD Specifications.

    At the end of the work, when everything was working with the 15Gb SPY sdcard (and I was able to initialize only this card) I increased the oscillator frequency and decreased the SPI parameter
    obtaining a 64MHz Oscillator frequency and a SPI frequency equal to 4MHz (this correspond to the Baud_param=7).
    Obviously I was very surprised that the card was initialized also at a so high frequency!

    Now I'm attempting to use EEPROM memory of the PIC to remove the limitations of the code I use to manage files and directories (I will use only short names).

    Giuseppe

    .

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.