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.

TMS320F28335: SPI communication between two F28335 development boards

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE

Hi,

I am trying to use two f28335 development boards for SPI communication. Here one board act as Master and another board acts as slave. Could anyone help me by sending a sample code. It is very hard to understand the application note as there is no clear direction to make it work.

Thanks.

K.K

  • Hi K.K.P,

    Which application note are you referring to?

    Have you checked the SPI examples in C2000WARE (C:\ti\c2000\C2000Ware_x\device_support\f2833x\examples\spi_loopback)?

    We do not have examples for the slave side of the communication, but you can modify the code for the Master to fit the slave side.

    Note: Make sure to disable the internal loopback in order to do external communication.

    Best Regards,

    Marlyn

  • Hi Marlyn,
    I tried with the example and I couldn't make it to work. My intention is to use one f28335 as slave and one as master. slave will send the data and master will read the data sent by the slave.
    The pin connection between Master and Slave is as follows:
    GPIO16 of master-->  GPIO17 of slave  
    GPIO17 of master-->  GPIO16 of slave    
    GPIO18 of master-->  GPIO18 of slave 
    GPIO1 of master-->  GPIO19 of slave  
    Could you please let me know where I am making the mistake?
    Thanks.
    K.K.P
    I referred: TMS320x2833x, 2823x Serial Peripheral Interface (SPI) document. 
     
    my slave init and FIFO setting code is here.
    void
    spi_init()
    {
            SpiaRegs.SPICCR.bit.SPISWRESET= 0;                      // 7      SPI SW Reset
            SpiaRegs.SPICCR.bit.SPICHAR = 0xF;                      // 3:0    Character length control
            SpiaRegs.SPICCR.bit.SPILBK = 0;                             // 4      Loop-back enable/disable
            SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;                 // 6      Clock polarity

            SpiaRegs.SPICTL.bit.SPIINTENA = 0;                      // 0      Interrupt enable
            SpiaRegs.SPICTL.bit.TALK = 1;                                 // 1      Master/Slave transmit enable
            SpiaRegs.SPICTL.bit.MASTER_SLAVE = 0;              // 2      Network control mode
            SpiaRegs.SPICTL.bit.CLK_PHASE = 0;                     // 3      Clock phase select
            SpiaRegs.SPICTL.bit.OVERRUNINTENA = 0;          // 4      Overrun interrupt enable

            SpiaRegs.SPICCR.bit.SPISWRESET= 1;                      // 7      SPI SW Reset
            SpiaRegs.SPIPRI.bit.FREE = 1;  // Set so breakpoints don't disturb xmission
    }



    void
    spi_fifo_init()
    {
            SpiaRegs.SPIFFTX.bit.TXFFIL = 0x00;                      // 4:0    Interrupt level
            SpiaRegs.SPIFFTX.bit.TXFFIENA = 0;                     // 5      Interrupt enable
            SpiaRegs.SPIFFTX.bit.TXFFINTCLR = 1;                 // 6      Clear INT flag
            SpiaRegs.SPIFFTX.bit.TXFFINT = 0;                       // 7      INT flag
            SpiaRegs.SPIFFTX.bit.TXFFST = 0;                        // 12:8   FIFO status
            SpiaRegs.SPIFFTX.bit.TXFIFO = 1;                        // 13     FIFO reset
            SpiaRegs.SPIFFTX.bit.SPIFFENA = 1;                    // 14     Enhancement enable
            SpiaRegs.SPIFFTX.bit.SPIRST =1;                         // 15     Reset SPI

            SpiaRegs.SPIFFCT.all=0x0;
     }
    in the mail loop I am sending by:
    for(;;){
    SpiaRegs.SPITXBUF=sdata;
    delay();
    }
    My master init and FIFO setting code is here:
    void
    spi_init()
    {
            SpiaRegs.SPICCR.bit.SPISWRESET= 0;                      // 7      SPI SW Reset
            SpiaRegs.SPICCR.bit.SPICHAR = 0xF;                      // 3:0    Character length control
            SpiaRegs.SPICCR.bit.SPILBK = 0;                             // 4      Loop-back enable/disable
            SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;                 // 6      Clock polarity

            SpiaRegs.SPICTL.bit.SPIINTENA = 0;                      // 0      Interrupt enable
            SpiaRegs.SPICTL.bit.TALK = 1;                                 // 1      Master/Slave transmit enable
            SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;              // 2      Network control mode
            SpiaRegs.SPICTL.bit.CLK_PHASE = 0;                     // 3      Clock phase select
            SpiaRegs.SPICTL.bit.OVERRUNINTENA = 0;          // 4      Overrun interrupt enable

            SpiaRegs.SPIBRR=0x007F;

            SpiaRegs.SPICCR.bit.SPISWRESET= 1;                      // 7      SPI SW Reset
            SpiaRegs.SPIPRI.bit.FREE = 1;  // Set so breakpoints don't disturb xmission
    }


    void
    spi_fifo_init()
    {
            SpiaRegs.SPIFFRX.bit.RXFFIL = 0x00;                      // 4:0    Interrupt level
            SpiaRegs.SPIFFRX.bit.RXFFIENA =0;                      // 5      Interrupt enable0
            SpiaRegs.SPIFFRX.bit.RXFFINTCLR = 1;                 // 6      Clear INT flag
            SpiaRegs.SPIFFRX.bit.RXFFINT = 0;                       // 7      INT flag
            SpiaRegs.SPIFFRX.bit.RXFFST = 0;                         // 12:8   FIFO status
            SpiaRegs.SPIFFRX.bit.RXFIFORESET = 1;               // 13     FIFO reset
            SpiaRegs.SPIFFRX.bit.RXFFOVFCLR = 0;               // 14     Clear overflow
            SpiaRegs.SPIFFRX.bit.RXFFOVF = 0;                      // 15     FIFO overflow
            SpiaRegs.SPIFFCT.all=0x0;
     }
    and in the main loop I read the slave data by:
    for(;;){
            GpioDataRegs.GPASET.bit.GPIO1 = 1;
            rdata = SpiaRegs.SPIRXBUF;
            GpioDataRegs.GPACLEAR.bit.GPIO1 = 1;
            delay();  
    }
  • Hi,

    Are you using the LaunchPad or ControlCARD platform?

    Have you looked at the signals on an oscilloscope? This will help guide you were the problem is. First make sure you have a clean CLK signal coming the Master and that you are indeed transmitting something from the Master. Once you have verified this you can check to see if the CLK on the slave side is correct and that you are able to send data there, taking into account the SPISTE signal.

    Also, it would be useful to observe the SPITXBUF and SPIRXBUF in the expression watch window to verify the values are getting written to the buffers.

    Best Regards,

    Marlyn