TMS320F28388D: Configuration of F28388D' SPI

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE, TMDSHSECDOCK, TMDSCNCD28388D, LMX2595, SYSCONFIG

Tool/software:

Hi Support team,

We plan to use F28388D's SPI to control some other slave SPI devices.

Is there any sample SPI code we can follow to develop our code?

I have installed C2000Ware 6.00.00.00 and CCS 20.2.0 on my windows laptop. I use the TMDSCNCD28388D version MCU063B-003 and TMDSHSECDOCK controlCARD Docking Station rev F boards for my testing.

Hopefully we can get the SPI signals from the TMDSHSECDOCK controlCARD Docking Station board.

Looking forward to your response.

Best regards,

Lin

  • Hello,

    Could anybody help me on that? We are still facing the problem.

    Thanks,

    Lin

  • Hello,

    Can anybody help me on the SPI setting?

    Thanks,

    Lin

  • I'm very sorry about the delay in response.

    There are examples for the F28388D at the following location:

    • {C2000Ware Install Location}\driverlib\f2838x\examples\c28x\spi\CCS

    Regards,
    Jason Osborn

  • Hi Jason,

    It's fine.

    I have found the example links and imported the spi_ex1_loopback project. I tried to configure the SPI to control TI's LMX2595 PLL chipset.

    The current status is that I can configure LMX2595 by sending SPI write command with SPI_writeDataBlockingNonFIFO() function. However, when I use SPI read command with SPI_readDataBlockingNonFIFO() function, I can only read back the lowest 8-bit data on the MISO line. I hope to get 16-bit data on the MISO line. BTW, I set SPI data width to 8 bit for LMX2595 configuration.

    Could you help me on the SPI readback issue? If you need more information, I can send you the main source code, .syscfg files and Saleae capture file.

    Looking forward to your further reply.

    Best regards,

    Lin

  • Based on the description here, I would use the FIFO. That would be the simplest way to implement what you're looking for with minimal additional complexity.

    Regards,
    Jason Osborn

  • Hi Jason,

    Thanks for your quick reply and suggestion.

    Yes, I did also try using the SPI_writeDataBlockingFIFO( ) and (SPI_readDataBlockingFIFO( ). I enabled the FIFO by checking the box of Use FIFO in the SysConfig GUI. But this time I get all 1's or 0xFF from the readback.

    Did I miss any setting for the FIFO before I used it? 

    To provide more information for you, I attached my SPI_Read function code. Could you please check it out?

    uint16_t lmx2595_read_register(uint8_t regAddr)
    {
        uint8_t tx[3] = { (0x80 | regAddr), 0x00, 0x00 };
        uint8_t rx[3];
    
        // Clear RX FIFO first
        SPI_clearRxFIFO(SPIA_BASE);
    
        // --- Send 24-bit read command (3 writes = 24 clocks) ---
        SPI_writeDataBlockingFIFO(SPIA_BASE, tx[0] << 8);  // Send MSB
        SPI_writeDataBlockingFIFO(SPIA_BASE, tx[1] << 8);  // Send mid
        SPI_writeDataBlockingFIFO(SPIA_BASE, tx[2] << 8);  // Send LSB
    
        // Wait for TX complete
        while(SPI_isBusy(SPIA_BASE));
    
        // Wait until 3 bytes are received in RX FIFO
        while(SPI_getRxFIFOStatus(SPIA_BASE) < 3);
    
        // --- Read the 3 response bytes from RX FIFO ---
        rx[0] = (uint8_t)(SPI_readDataBlockingFIFO(SPIA_BASE) >> 8);
        rx[1] = (uint8_t)(SPI_readDataBlockingFIFO(SPIA_BASE) >> 8);
        rx[2] = (uint8_t)(SPI_readDataBlockingFIFO(SPIA_BASE) >> 8);
    
        // Combine middle and last bytes to get 16-bit register value
        uint16_t regVal = ((uint16_t)rx[1] << 8) | rx[2];
    
        return regVal;
    }
    

    Best regards,

    Lin

  • I'd say first, the SPI_isBusy() loop probably isn't necessary.

    Second, and more importantly, the bit shifting of the SPI_read/write function calls isn't necessary when using the FIFO.

    Regards,
    Jason Osborn

  • Hi Jason,

    Thanks for your reviewing my code and pointed some key factors.

    I commented out the SPI_isBusy() line and took away the bit shifting in the read function. One more thing I need to clarify is that in my running code actually no SPI_clearRxFIFO(SPIA_BASE); line. (if adding that line, will get a link error: undefined symbol).

    So the latest status is that with the bit shifting in the read function, I will get all 0's data; without bit shifting in the read function, I will get all 1's data. Both cases are not correct.

    Do you have any further code modification?

    Thanks,

    Lin

  • I didn't notice that- the correct function you're looking for is SPI_resetRxFIFO(), not clearRxFIFO.

    Are you able to monitor the data lines with an oscilloscope or data analyzer? I'd suggest doing so, if possible, to verify that data is actually being transmitted/received.

    Other than this, are you seeing all 1/0 in the regVal return variable, or in the rx array? Put a breakpoint just before the return variable in that function and take a look at the full contents of the rx array. If what you're seeing doesn't make any sense, also use the CCS register view to look at the contents of the SPI Rx emulation register at the same breakpoint, and let me know what all you see in the array and register.

    Regards,
    Jason Osborn

  • Hi Jason,

    Thank you very much for your correct function info and all the debugging methods.

    After replacing SPI_clearRxFIFO() with SPI_resetRxFIFO(), the SPI read function works. I verified results by comparing the rx array or regVal data with the data on MISO line (captured with Saleae Logic Analyzer). Now I can get the whole 16-bit readback data.

    The the contents of the SPI Rx emulation register are as below for 4 cases (0x0488, 0x005B, 0x0164, 0x2518):

    SPIRXEMU         0x0088/0x005B/0x0064/0x0018           0x00006106@data
           ERXBn         0x0088/0x005B/0x0064/0x0018

    Here is one question about the SPI Rx emulation register: why does it only show the lowest 8-bit, not 16-bit or not one by one 8-bit?

    Best regards,

    Lin

  • Hi Lin,

    I will be taking over support on this thread. Let me familiarize myself with your setup and questions and get back to you.

    Best Regards,

    Delaney

  • Hi Lin,

    It sounds like your original issue was resolved based on your latest response. For your question about the emulation register: can you verify that "Continuous Refresh" is toggled on in the Register viewer? I believe all 16-bits should show up in the register. Another thing to try would be calling the SPI_readRxEmulationBuffer() function to read the emulation buffer - does this return the full 16-bit value?

    Best Regards,

    Delaney

  • Hi Delaney,

    Thanks for your following up.

    Yes, the issued has been resolved. Only thing is that the register contents do not match with the readback values. I tried that ways, but still not matching.

    However, as the main issued is resolved. The left is minor. So if you want we can close this case.

    Regards,

    Lin

  • Hi Lin,

    I will close the thread then and look into this on my end to see if there is any issue with the CCS register mappings for this peripheral that we may need to fix in upcoming CCS releases.

    Best Regards,

    Delaney

  • Thanks, Delaney.