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.

TMS570LC4357: SD card driver in TMDX570LC43HDK and with custom board.

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN, TMS570LS3137

Hi Team,

I need a help to configure the SPICS1 instead of SPICS0 in Custom board is it the PC3 register to be use?

Function to SELECT and DESELECT is Chip select is PC3 = 0x01 for CS[0] 

In my case, Did I need to use PC3 = 0x02 for CS[1] -- SD_mibspiREG->PC3 

and I am not using this SPI enable pin "SPI2ENA".

Please confirm. 

Thanks in advance. 

Santhosh

  • Hi Team,

    I am working with "TMS570LC43x_HDK_SDCard_mibspiDMA"  project for SD card. 

    What are the setting need to configure for MIBSPI2 and DMA BTC in HalCoGen.

    Which MIBSPI2 Transfer Groups are used in this configuration in my case I need to change CS_0 to CS_1 Chip select. 

    here in the below configuration it says first 3 Transfer group uses the CS_0 Chip select 0.

    which Transfer Group is used in the code all 3 are changed to CS_0 ?

    If I need to change the VCLK1 from 75MHz to 80MHz and automatically Prescale will change. In this case did we need to modify the API set_max_speed ? FMT0 and FMT1 2<<8 ?

    Please confirm which Data Format is used in code Data format 0 , 1 or 2 all are changed in the configuration.

    Did I need to modify any part of the code for removing the implementation of the SPIENA SPI enable pin because I have used SPICS_1 So I couldn't use SPIENA it is in same pin in MCU?

    Thanks in advance. 

    Santhosh

  • In my case, Did I need to use PC3 = 0x02 for CS[1] -- SD_mibspiREG->PC3 

    In the SD example code, we use the SPI_nCS[x] pin as GIO. 

    1. configure SPI_nCS[1] as GIO pin: PC0 &= 0xFD; (b11111101) --> bit 1 is cleared

    2. configure SPI_nCS[1] as output: PC1 |= 0x02;  //output

    3. set or clear bit 1 of PC3 register to assert or de-assert chip select signal

  • Hi QJ Wang,

    Is this correct setting for SDCARD of SPI_CS[1] 

    1. configure SPI_nCS[1] as GIO pin: PC0 &= 0xFD; (b11111101) --> bit 1 is cleared

    2. configure SPI_nCS[1] as output: PC1 |= 0x02;  //output

    DIR is selected it means output.

    3. set or clear bit 1 of PC3 register to assert or de-assert chip select signal

    In this SDCard spiDMA example, It uses the external (IS42S16400F-7BL) SDRAM for DMA which is not present in my custom board for SPI SDCard connect board.

    I have noticed the EMIF driver is configured for external SDRAM.  

    I need a code only uses the internal DMA for SPI connection for SDCard. 

    Did you have any other example which uses the SPI with DMA or without DMA for SDCard.

    Thanks in advance. 

    Santhosh

  • HI Santosh,

    You don't need to use EMIF memory. I modified the code to use EMIF memory instead of MCY internal SRAM based on one customer's request. I will change it back to use the MCU internal SRAM.

  • Hi Santosh,

    You can use SRAM instead of SDRAM by changing the instruction in linker cmd file:

    Change

        SD_RDATA_SECTION : {} > SDRAM

    to

        SD_RDATA_SECTION : {} > RAM

  • If you don't want to use DMA, please undefine the MIBSPI_DMA_MODE in sdc-hdk-hercules.c:

  • Hi QJ Wang,

    How do I need to change the External SDRAM to Internal SRAM by only in HL_sys_link.cmd file in source folder. 

    Did I need to change it in code also anywhere?

    undefine the MIBSPI_DMA_MODE to remove DMA

    In my custom board we are not using MIBSPI2 ENA and MIBSPI2 SCS[0] connected. Instead of this we are using MIBSPI2 SCS[1] for Chip select only.  

    Did I need to change anything in configurator 

    Pin Muxing : 

    Input Pin Muxing :

    Did I need to change first 3 Transfer Group 0 , 1 and 2 to CS_1 from CS_0 Chip select

    line number 2325 in ff.c

    FRESULT f_open (
    FIL *fp, /* Pointer to the blank file object */
    const TCHAR *path, /* Pointer to the file name */
    BYTE mode /* Access mode and file open mode flags */
    )

    res = chk_mounted(&path, &dj.fs, (BYTE)(mode & ~FA_READ)); line number 2325 in ff.c

    Name : res
    Default:FR_NOT_READY

    Check the above HalCoGen and code changes made for SD Card using SPI2 and CS_1 port instead of CS_0 and ENABLE.

    SCI output:

    Still the 

    Please check this configuration and coding changes I have made and let me know the feedback. 

    Thanks in advance.

    Santhosh

  • Hi QJ Wang,

    Did you have any code for SDCard using normal SPI not the MIBSPI where I can change the SPICS0 to SPICS1 and without SPIENA pin . 

    Thanks 

    Santhosh

  • Hi Santhosh,

    Attached is an example using SPI2 without DMA. The example is used on TMS570LC43x HDK.

    TMS570LC43x_SDCard_Demo.zip:

    TMS570LC43x_SDCard_Demo.zip

  • Hi QJ Wang,

    I have tried your code with SPI in HDK board but I am getting an error code as FR_NOT_READY for ls and cat command. 

    In this code did we need SPI ENA - SPI enable pin ?

    Please let me know what will be the issue in this code. I didn't changed any code. 

    Thanks in advance.

    Santhosh

  • Hi QJ Wang,

    TMS570LC43x_SDCard_Demo.zip:

    This build has the issue in TMS570LC43x HDK board itself it is not working fine. 

    Can you please check it once. because the "TMS570LC43x_HDK_SDCard_mibspiDMA" build is working fine in the same board.

    In my custom board it connected with SPI2_CS1 and SPI2 ENA is not connected with the SD card. through SPI2. 

    Let me know what my be the issue in that case.

    Thanks in advance.

    Santhosh

  • Hi QJ Wang,

    Configuration in TMS570LC43x_SDCard_Demo.zip: in demo code.

    SPI2 Data Formats is it 1000kHz is okay?

    SPI2 Ports.

    PINMUX

    Please check the configuration.

    Thanks in Advance

  • SPIENA is not used. The demo code uses SPI2 and SPI2_CS0.

  • Hi QJ Wang,

    1. I am getting an overflow issue while it is writing in SD card sometime it is taking 50ms to 200ms.

    Normally it is taking 7ms to 10ms for writing the buffer. But in 3sec period it is 50ms for write in SD card 

    Sometime it is taking ON time is 174.6ms and total time is 200ms.

    What is the issue in the SD card disk write code in close command.

    The disk write function is inside the close function. 

    Thanks in advance. 

  • HI QJ Wang,

    The above waveform is from our custom board using project "TMS570LC43x_SDCard_Demo" with normal SPI2.

    So I too trying to work on the MiBSPI  using TMS570LC43x_HDK_SDCard_mibspiDMA - MiBSPI2 

    here In HDK it is working fine but in our custom board I need to co0nfigurature for CS_1 instead of CS_0.

    I come across the forum "TMS570LS3137: Read SD CARD"

    The SD card example uses MibSPI2, here is the config of MibSPI transfer group:

    The TG0 is used to transfer command, and TG1 is to transfer data from the file.

    I seen your comment, I never seen TG1 in the disk_write and disk_read function in Sd card. 

    In HDK, inside disk_initialize function if (send_cmd(CMD0, 0) == 1)  is true the return value is 1 from send_cmd function. 

    But from my custom board if (send_cmd(CMD0, 0) == 1)  is false the return value is 0xFF from send_cmd function. I couldn't find the issue. 

    Please help me in this fix. 

    Thanks in advance.

  • In my example, the cache is disabled. Also the CS1 should be used in the Transfer Groups Config GUI.