This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SD write/read TMS570LS3137 HDK (Guide?)

Other Parts Discussed in Thread: HALCOGEN, TMS570LS3137, TMS570LS1227

Hi guys,

You have been very helpful to our team recently, thanks!

We just had a question regarding the SPI2 and the micro SD slot. We want to read/write to a SD and were wondering if you had a guide or a tutorial on hand we could follow, or is perhaps what we are trying to achieve very similar to the MbiSPI example in Halcogen?

Thanks,

Peter Th.

  • Hello:

    We have received your post and will check if we have anything available on this subject.

    Regards.

  • Hello:

    We don't have any reference code to read/write to a SD card available. The only code we have is a very simple connectivity test we use to test the boards. Please let me know if you would be interested on receiving this code.

    Regards,

    Enrique

  • Ah, that's unfortunate.

    But YES, I guess anything might be helpful. I guess this connectivity test would be used to test connectivity to the micro SD slot via the SPI2?

    Thanks,

    Peter Th.

  • Hi Peter,

    Attached is my source code for HDK SDCARD connectivity test.

    Regqards,

    QJ

    2330.SDCard.c0841.SDCard.h7282.spi.c1351.spi.h

     

  • Thanks,

    Just for reference, we are using TMS570LS3137 HDK.

    Anyway, in spi.h there is a prototype for spiGroupNotification, but there is no implementation for it in spi.c. Is that supposed to be so? The in code documentation for spiGroupNotifcation says "It is call when a transfer is complete" and the application will provide the implementation. Would you happen to have an appropriate implementation on had for this particular case?

    Also, the spi code generated by HALCOGEN looks very different from the provided sample code.

    Thanks,

    Peter Th.

    P.S.

    I remember having issues with spiGroupNotification when running the included tutorial (for example the LED test) on the quick start CD that came with the board. We ended up just removing "them" from the code and that particular LED test then compiled and ran fine.

     Furthermore, but I suspect far less significant, three IOMM functions in the SDCard.c were also causing compiling issues so we commented them out. 

  • Hi Peter,

    I didn't use Halcogen because the Halcogen was not ready for this device when when I developed HDK test code. The notification functions are defined in another file. They are empty function, and I don't use them in my test project.

    /* SPI interrupt notification (Not used but must be provided) */

    void spiNotification(spiBASE_t *spi, unsignedflags)

    { return;}

    /* SPI interrupt notification (Not used but must be provided) */

    void spiGroupNotification(spiBASE_t *spi, unsignedgroup)

    { return; }

    Regards,

    QJ

  • Wow, thanks QJ for answering fast!

    Ah so the notification is just an empty function. Well during debugging, when we run the  SDC_init() routine in SDCard.c, the program stalls on the first SPI_send() function call.

    Specifically it gets stuck on the:  while ((spiREG2->FLG & 0x0200) == 0);
    Which has the comment  "// Wait until TXINTFLG is set for previous transmission"

    I thought this was due to the fact that we were missing the interrupt function, but now I suspect its because we are missing the IOMM_PINMUX_MIBSPI2() function(s)!? Is there a code you have for this one?

    Thanks,

    Peter Th

  • Hi Peter,

    SDCARD uses SPI2, so you don't need pinmux function. The code only support SDCARD with SPI mode, and its capacity should be <2GB. I use 1GB SDCARD for testing.

    Regards,

    QJ

  • We are using a 2GB card.
    We garbed your code and managed to integrated it into our test code (which runs inside a RTOS scheduler).

    The only thing that didnt combine were the first three function calls in SDC_init() in the SDCard.c (The IOMM functions).

    When we run SDC_init() it get stuck at the location mentioned in the previous post.
    Any ideas?

    Peter Th. 

  • AAAh, nevermind.

    We forgot to run the spiInit(), instead running sciInit().
    Hopefully things will work now.

    Thank you very much for your help!

    Peter Th 

  • Hello,

    Is some SD card demo code available my HDK built-in reader.

    If I am right it is attached to SPI2 and therefore KEIL MDK confidence test demo is not that directly portable.

    It surprises me a bit that such demo is not publicly available whilst the HDK comes with reader.

    Is TI planning to include such code in Halcogen examples further release?

    Thank you!

  • In the post, QJ has already provided the source code. (look for the Green verified answer)

    Do that answer your question?

    Regards,

    Haixiao

  • Dear Haixiao,

    Actually, to be frank, it does not, because the example is pre-Halcogen one and it is not clear for me how to combine it with a big existing project developed using halcogen for all hardware setup.

    Thank you and QJ anyway for your answers

  • 1464.SD_CARD_1227ZWT.rar

    Dear QJ,

    Recently I have try to read SD Card, using the source code just you build.
    This time I use TMS570LS1227 HDK to rebuild the project. I have try to check one by one, but seems that I cannot find the error.
    But when I run the program it always show "FR not ready" so it means cannot initialize the SD card. I use 4GB micro sd, is this too big?
    Would you please help me check my project QJ? I am wondering what is the problem. I attached the screen shot of my error project & my project including the Halcogen setting. I appreciate your time for help me.

    Thank you very much.


    Best Regards,

    Lukman