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.

TMS320F28377S: SPI Communication Problem Between two F28777S controller.

Part Number: TMS320F28377S

Hi,

i try to data communication between two F28377S IC. i set one of them as master and another one is slave.

The master one sending allways data , but slave one is reading sometimes true value sometimes wrong value, it looks like there is not snchronization bettwen master and slave, when i read sheets, SPISTEA provide syncronization between two IC but when i look by ossiloscope in this pin , it is allways low.

Master IC Code:

void spi_fifo_init()
{
    //
    // Initialize SPI FIFO registers
    //
    SpiaRegs.SPIFFTX.all = 0xC022;    // Enable FIFOs, set TX FIFO level to 4
    SpiaRegs.SPIFFRX.all = 0x0022;    // Set RX FIFO level to 4
    SpiaRegs.SPIFFCT.all = 0x00;

    SpiaRegs.SPIFFTX.bit.TXFIFO=1;
    SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;

    //
    // Initialize core SPI registers
    //
    InitSpi();
}

interrupt void spiTxFifoIsr(void)
{
    GPIO_WritePin(49, 0);
   SpiaRegs.SPITXBUF=sdata;      // Send data
   SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1;  // Clear Interrupt flag
   PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ACK
   GPIO_WritePin(49, 1);
}

interrupt void spiRxFifoIsr(void)
{
    rdata=SpiaRegs.SPIRXBUF;         // Read data
    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
    SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
}
void InitSpi(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 = 0;
    SpiaRegs.SPICCR.bit.SPICHAR = (16-1);
    SpiaRegs.SPICCR.bit.SPILBK = 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 = 0;
    SpiaRegs.SPICTL.bit.SPIINTENA = 1;

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

    // Set FREE bit
    // Halting on a breakpoint will not halt the SPI
    SpiaRegs.SPIPRI.bit.FREE = 1;
    // Release the SPI from reset
    SpiaRegs.SPICCR.bit.SPISWRESET = 1;
}

-----------------------------------------------------------------------------------------------------------------------------

SLAVE IC Code:

void spi_fifo_init()
{
    //
    // Initialize SPI FIFO registers
    //
    SpiaRegs.SPIFFTX.all = 0xC022;    // Enable FIFOs, set TX FIFO level to 4
    SpiaRegs.SPIFFRX.all = 0x0022;    // Set RX FIFO level to 4
    SpiaRegs.SPIFFCT.all = 0x00;

    SpiaRegs.SPIFFTX.bit.TXFIFO=1;
    SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;

    InitSpi();
}
interrupt void spiTxFifoIsr(void)
{
   SpiaRegs.SPITXBUF=rdata;             // Send data
   SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1;  // Clear Interrupt flag
   PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ACK
}
interrupt void spiRxFifoIsr(void)
{
    GPIO_WritePin(50, 1);
    rdata=(SpiaRegs.SPIRXBUF);
    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
    SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
    GPIO_WritePin(50, 0);
}
void InitSpi(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 = 0;
    SpiaRegs.SPICCR.bit.SPICHAR = (16-1);
    SpiaRegs.SPICCR.bit.SPILBK = 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 = 0;///
    SpiaRegs.SPICTL.bit.TALK = 1;
    SpiaRegs.SPICTL.bit.CLK_PHASE = 0;
    SpiaRegs.SPICTL.bit.SPIINTENA = 1;

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

    // Set FREE bit
    // Halting on a breakpoint will not halt the SPI
    SpiaRegs.SPIPRI.bit.FREE = 1;
    // Release the SPI from reset
    SpiaRegs.SPICCR.bit.SPISWRESET = 1;
}

 

Waiting you comments..

Thank you.

  • If your SPISTEA pin is always low but the other signals are working as expected, I suspect there may be an issue with the GPIO configuration. Can you double check how you've configured the SPISTEA pin? If it all looks correct but still isn't working, could you try configuring it as a GPIO output and toggling it, so that you can check on an oscilloscope you're using the right pin and the connection is good?

    Whitney
  • H,
    Thank you for your answer. i saw that the master is allways sending data (without stop), i think because of that SPISTEA pin is never going high..because there is not any time between previous package and new package , and i try to set some time between these package but i can not find which configuration is related with it.
    Could you help me to find how i can arrange this? than i will see that SPISTEA is going high or not?
  • Our hardware will hold SPISTE low if transfers are back-to-back, particularly with the FIFO. It seems a little unlikely to me that this is what's happening in your code since you're only putting 1 item in the FIFO at a time. You should be able to test it by putting a delay in the master code right after you write to the TX buffer.

    You can also try experimenting with using a software-controlled GPIO as the chip select on the master side instead of letting the hardware control SPISTE.

    Whitney