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: How to close SPI loopback?

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE, , CONTROLSUITE

Dear team:


I used the official sample program of SPI to do the loopback experiment, and it worked well.
But after I closed loopback and connect the SIMO and SOMI pins with a wire, It can only receive data "1" each bit, and the waveform of the receiving pin is correct. And the same problem when I use SPI to communicate externally: the waveform is correct but the received data is "1" each bit.
How can I handle this situation?


Below is my register configuration of external communication.


SpiaRegs.SPICCR.bit.SPISWRESET = 0;
SpiaRegs.SPICCR.all = 0x0009;
SpiaRegs.SPICTL.all = 0x0017;
SpiaRegs.SPISTS.all = 0x0000;
SpiaRegs.SPIBRR = 0x12;
SpiaRegs.SPIFFTX.all = 0xc065;
SpiaRegs.SPIFFRX.all = 0x6061;
SpiaRegs.SPIFFCT.all = 0x0000;
SpiaRegs.SPIPRI.all = 0x0010;
SpiaRegs.SPIFFTX.bit.TXFIFO = 1;
SpiaRegs.SPIFFRX.bit.RXFIFORESET = 1;
SpiaRegs.SPICCR.bit.SPISWRESET = 1;

Best regards

K.K

  • K.K,

    That is very interesting. It sounds like the GPIOs are configured as you are able to see the waveform. Your configuration code also appears to be fine with no outstanding issues.

    Please confirm that your SPISOMI pin is configured properly. You can also test it in GPIO mode as an input and output to ensure that the pin is functional on its own.

    -Mark
  • This is my code. May you kindly test it for me ?

    #include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
    #include "DSP2833x_Examples.h"   // DSP2833x Examples Include File
    #define  SPISTE	  GpioDataRegs.GPBDAT.bit.GPIO57
    
    interrupt void spiTxFifoIsr(void);
    interrupt void spiRxFifoIsr(void);
    void Port_init(void);
    
    Uint16 i;     // Send data buffer
    Uint16 rdata[5];     // Receive data buffer
    
    
    int sign=0;
    
    void main(void)
    {
     
       InitSysCtrl();
       DINT;
       IER = 0x0000;
       IFR = 0x0000;
       InitPieCtrl();
       InitPieVectTable();
       EALLOW;	
       PieVectTable.SPIRXINTA = &spiRxFifoIsr;
       PieVectTable.SPITXINTA = &spiTxFifoIsr;
       EDIS;   
       Port_init();	
       SPISTE = 1;
       for(i=0;i<10;i++)
       {
    	  rdata[i] = 0;
       }
       PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
       PieCtrlRegs.PIEIER6.bit.INTx1=1;     // Enable PIE Group 6, INT 1  RECEIVE
       PieCtrlRegs.PIEIER6.bit.INTx2=1;     // Enable PIE Group 6, INT 2  SEND
       IER=0x20;                            // Enable CPU INT6
       EINT;                                // Enable Global Interrupts
    	for(;;);
    	              
    }
    
    
    
    void Port_init()
    {
        EALLOW;
    
    
       GpioCtrlRegs.GPBPUD.bit.GPIO54 = 0; 
       GpioCtrlRegs.GPBPUD.bit.GPIO55 = 0; 
       GpioCtrlRegs.GPBPUD.bit.GPIO56 = 0; 
       GpioCtrlRegs.GPBPUD.bit.GPIO57 = 0; 
    
       GpioCtrlRegs.GPBQSEL2.bit.GPIO54 = 3; 
       GpioCtrlRegs.GPBQSEL2.bit.GPIO55 = 3; 
       GpioCtrlRegs.GPBQSEL2.bit.GPIO56 = 3; 
       GpioCtrlRegs.GPBQSEL2.bit.GPIO57 = 3; 
    
       GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 1; 
       GpioCtrlRegs.GPBMUX2.bit.GPIO55 = 1; 
       GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 1;   
       GpioCtrlRegs.GPBMUX2.bit.GPIO57 = 0; //SPISTE���ó���ͨIO�ڣ�Ϊ�˿���485оƬ�����ģʽ
       GpioCtrlRegs.GPBDIR.bit.GPIO57 = 1;
    
      EDIS;
      SpiaRegs.SPICCR.bit.SPISWRESET = 0;  
      SpiaRegs.SPICCR.all = 0x0009; 
      SpiaRegs.SPICTL.all = 0x0017; 
    
      SpiaRegs.SPICCR.bit.CLKPOLARITY = 1; 
      SpiaRegs.SPICTL.bit.CLK_PHASE = 1;  
    
      SpiaRegs.SPISTS.all = 0x0000; 
      SpiaRegs.SPIBRR = 0x12;  
      SpiaRegs.SPIFFTX.all = 0xc065; 
                                                                    
      SpiaRegs.SPIFFRX.all = 0x6061;  
      SpiaRegs.SPIFFCT.all = 0x0000;
      SpiaRegs.SPIPRI.all = 0x0010;
      SpiaRegs.SPIFFTX.bit.TXFIFO = 1;
      SpiaRegs.SPIFFRX.bit.RXFIFORESET = 1;
      SpiaRegs.SPICCR.bit.SPISWRESET = 1;
    
    }
    
    interrupt void spiTxFifoIsr(void)
    {
    	int i;
    	SPISTE=1;
    	SpiaRegs.SPITXBUF = 0x0700;
        	sign = 0;
    	SpiaRegs.SPITXBUF = 0;
    	SpiaRegs.SPITXBUF = 0;
    	SpiaRegs.SPITXBUF = 0;
    	SpiaRegs.SPITXBUF = 0;
    	for(i=0;i<11;)
    		i++;
    	SPISTE=~SPISTE;
            SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1; 
    	PieCtrlRegs.PIEACK.all|=0x20;  	
    	for(i=0;i<20000;i++);
    
    }
    
    interrupt void spiRxFifoIsr(void)//sign=0,1,2,3�ֱ���
    {
    	
    	rdata[sign] = SpiaRegs.SPIRXBUF;
    
    	sign++;
    	SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
    	SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1; 	// Clear Interrupt flag
    	PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
    	
     }
    
    
    //===========================================================================
    // No more.
    //===========================================================================
    
    

  • Hi,

    Please verify that your Chip select signal is behaving as it should. Every time the TXFIFO ISR is called, the Chip select signal will toggle. This needs to be held active for the duration of the transmission. 

    If using a GPIO controlled Chip select, ensure that the signal goes active before the transmission starts, then release after the full transmission is complete. 

    Please observe this on the scope. You should also compare the behavior against the C2000ware example for the SPI interrupt testcase. In the example, SPISTE is controlled by the SPI. it will be held as long as there is valid data in SPITXBUF. 

    -Mark

  • Part Number: TMS320F28335

    Dear team:

    I used the official SPI example program to do my test. When I use loopback, I can detect the waveforms by oscilloscope at send port (SPISIMO). But I can't detect the waveforms at receive prot (SPISOMI), just a direct voltage. Is that normal? Or is there a problem with the SPISOMI interface?

    Best Regards
    K.K

  • K.K,

    I merged the thread as it appears that you have not resolved the issue from this one.

    I can only offer opinions as to what the issue might be if you do not provide responses to the questions and requests I am posting.

    Please share the following:
    Is the board custom hardware or a TI EVM?
    Have you verified that the SOMI pin is configured correctly in the GPIO mux?
    Does the SOMI pin work in GPIO mode and toggle when driven?
    Please share oscilloscope captures of the failing test.
    Ensure SPISTE is driven properly.
    As you say you are now using TI provided example code, please share the path and version to the code within controlSuite/C2000ware or post your main.c file here.
  • K.K,

    It's been a few days since you last replied. I am assuming that you have been able to resolve the issue. I will close this post. Please reply if you have additional questions or feedback.

    Regards,
    Mark