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.

TMS320F28379D: SPI

Part Number: TMS320F28379D

Hi everyone!

I have some questions about the SPI setting of TMS320F28379D.

I have tried to use the DSP as SPI  master to write data to the slave piece named IVQ3005 part,but I can't get the right wave output from the slave part,and it seems that the slave part didn't receive any data.

1. The slave part only use the SPI_CLK , SPI_MOSI and a SPI_Chipselect wire,so I set the dsp SPI-A in the three-wire mode.So,what about the concerned GPIO 16~GPIO 19 setting?I tried to configure them as below,and Initial the SPIA with the function InitSpia() below in the mode :8-bit per char ,disable loopback,disable FIFO, three-wire enable:

void InitSpiaGpio()
{
   EALLOW;

    //
    // Enable internal pull-up for the selected pins
    //
    // Pull-ups can be enabled or disabled by the user.
    // This will enable the pullups for the specified pins.
    // Comment out other unwanted lines.
    //
    GpioCtrlRegs.GPAPUD.bit.GPIO16 = 0;  // Enable pull-up on GPIO16 (SPISIMOA)
//  GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0;   // Enable pull-up on GPIO5 (SPISIMOA)
    GpioCtrlRegs.GPAPUD.bit.GPIO17 = 0;  // Enable pull-up on GPIO17 (SPISOMIA)
//  GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0;   // Enable pull-up on GPIO3 (SPISOMIA)
    GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0;  // Enable pull-up on GPIO18 (SPICLKA)
//    GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0;  // Enable pull-up on GPIO19 (SPISTEA)

    //
    // Set qualification for selected pins to asynch only
    //
    // This will select asynch (no qualification) for the selected pins.
    // Comment out other unwanted lines.
    //
    GpioCtrlRegs.GPAQSEL2.bit.GPIO16 = 3; // Asynch input GPIO16 (SPISIMOA)
//  GpioCtrlRegs.GPAQSEL1.bit.GPIO5 = 3;  // Asynch input GPIO5 (SPISIMOA)
    GpioCtrlRegs.GPAQSEL2.bit.GPIO17 = 3; // Asynch input GPIO17 (SPISOMIA)
//  GpioCtrlRegs.GPAQSEL1.bit.GPIO3 = 3;  // Asynch input GPIO3 (SPISOMIA)
    GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3; // Asynch input GPIO18 (SPICLKA)
//    GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // Asynch input GPIO19 (SPISTEA)

    //
    //Configure SPI-A pins using GPIO regs
    //
    // This specifies which of the possible GPIO pins will be SPI functional
    // pins.
    // Comment out other unwanted lines.
    //
    GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; // Configure GPIO16 as SPISIMOA
//  GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 2;  // Configure GPIO5 as SPISIMOA
    GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; // Configure GPIO17 as SPISOMIA
//  GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 2;  // Configure GPIO3 as SPISOMIA
    GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1; // Configure GPIO18 as SPICLKA
//    GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1; // Configure GPIO19 as SPISTEA

    EDIS;
}
void InitSpia(void)
{
    // Initialize SPI-A

    // Set reset low before configuration changes
    // Clock polarity (0 == rising, 1 == falling)
    // 16-bit character
    // Enable loop-back
    SpiaRegs.SPICCR.bit.SPISWRESET = 0;
    SpiaRegs.SPICCR.bit.CLKPOLARITY = 1;
    SpiaRegs.SPICCR.bit.SPICHAR = (8-1);//(16-1)
    SpiaRegs.SPICCR.bit.SPILBK = 0;//1;loopback disable(0)

    // Enable master (0 == slave, 1 == master)
    // Enable transmission (Talk)
    // Clock phase (0 == normal, 1 == delayed)
    // SPI interrupts are disabled
    SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
    SpiaRegs.SPICTL.bit.TALK = 1;
    SpiaRegs.SPICTL.bit.CLK_PHASE = 1;//0
    SpiaRegs.SPICTL.bit.SPIINTENA = 0;

    // Set the baud rate
    SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = SPI1_BRR;

    // Set FREE bit
    // Halting on a breakpoint will not halt the SPI
    SpiaRegs.SPIPRI.bit.FREE = 1;

    SpiaRegs.SPIPRI.bit.TRIWIRE = 1;//SPI 3-wire mode enable
    SpiaRegs.SPIFFTX.bit.SPIFFENA = 0;//disable FIFO

    // Release the SPI from reset
    SpiaRegs.SPICCR.bit.SPISWRESET = 1;
}

Is there any error in my code ?

2.The second question is whether the operation of writing a data to the TXBUF means the master transmit the data to the slave?Can the following code implement the function of transmit TxData via the MOSI to the slave?

uint8_t REF_SPI_ReadWriteByte(uint8_t TxData)
{
    uint8_t dummy = 0;

    // waiting for the complement of  previous character shifting
    while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG == 1) { }

    SpiaRegs.SPICTL.bit.TALK = 1; // Enable Transmit path
    SpiaRegs.SPITXBUF = TxData; // Master transmits data

    if(SPIA_FIFO)
        while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) {} // Waits until data rx’d--FIFO mode
    else
        while(SpiaRegs.SPISTS.bit.INT_FLAG !=1){}//Non-FIFO mode


    dummy = SpiaRegs.SPIRXBUF; // Clears junk data from itself bc it rx’d same data tx’d
    return dummy;

}

3. The last question is, Is there a way to see if the SPI is working correctly?I have tried to add GpioDataRegs.GPADAT.bit.GPIO18(which has been configured as the SPICLKA) to Watch  Variables during debug with CCS,but it seemd that the value hadn't changed ever even during master tring to trismit data.Did this means that the SPI didn't work correctly?How can I fix this problem?

Thanks a lot.



  • 1. Your GPIO configuration seems fine. Have you tried connected an oscilloscope or logic analyzer to the SPI signals to confirm that the outputs are as expected?

    2. Yes, assuming the SPI is enabled correctly, a write to TXBUF should trigger a transmission. I do see an issue with your code--when your character size is less than 16, you need to left justify the data in TXBUF. In your case, this means shifting TxData to the left by 8 bits.

    3. I don't think watching GPIO18 is going to tell you much. If you have access to the equipment, doing as I suggested in 1 will give you a better idea of how the SPI is working.

    Whitney