Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed the week of November 23.

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.

data lost at SPI receiver side with "polling" mechanism

Hi All:

I am coding the communication between 2 DSPs through SPI. The start code is quite simple, DSP-1 is sending and DSP-2 is receiving (Of course, DSP-1 also receives but I don't care so far, vice versa for DSP-2)

That works fine. One thousand 16bit data were sent and received correctly.

However, when I add an random delay in DSP-1(master) side, I found DSP-2 begin to lost some data. It is confusing me that I didn't change anything at DSP-2 side for receiving and I am polling quite often.

So anyidea why the delay on sender's side might affect the receiver? (I double checked the DSP1 did send correct sequence.)

And I am thinking to convert to interrupt mechanism, will that solve this kind of issue for all?

my DSP2's polling code is:

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

for(;;)  //my main program for receving
{
  spi_xmit(data);  //For sending, not care so far
  
  while(SpiaRegs.SPIFFRX.bit.RXFFST == 0) {} //polling

  while(SpiaRegs.SPIFFRX.bit.RXFFST != 0) 
  {
    rdata[seq] = SpiaRegs.SPIRXBUF;
    seq++;
  } 
  
  if(seq>1000) break;
}

Other configuration for SPI is:
void spi_init()
{    
	SpiaRegs.SPICCR.all =0x000F;	             // Reset on, rising edge, 16-bit char bits  
	SpiaRegs.SPICTL.all =0x0002;    		     // Enable slave mode, normal phase,
                                                 // enable talk, and SPI int disabled.
	SpiaRegs.SPIBRR =0x0003;									
    SpiaRegs.SPICCR.all =0x008F;		         // Relinquish SPI from Reset   
    SpiaRegs.SPIPRI.bit.FREE = 1;                // Set so breakpoints don't disturb xmission
}

void spi_xmit(Uint16 a)
{
    SpiaRegs.SPITXBUF=a;
}    

void spi_fifo_init()										
{
// Initialize SPI FIFO registers
    SpiaRegs.SPIFFTX.all=0xE040;
    SpiaRegs.SPIFFRX.all=0x2044;
    SpiaRegs.SPIFFCT.all=0x0;
}  

  • Lebing,

    I have run your code on the bench. I am unfortunately unable to replicate your results. Interrupts may be something to try. If anything it may just mask the issue, and we will never know what the root cause is.

    What do you mean when you say the data is not received correctly?

    Are you missing data (i.e. expected: 0x1234, 0xFEDC, 0x5678, 0xBA98, actual: 0x1234, 0x5678, 0xBA98)?

    Is the data jumbled and not received properly (i.e. expected: 0x1234, actual: 0x087B)?

    Can you tell me what frequencies of SYSCLK and LSPCLK on the slave side. What about the master's frequency? what is the device you are receiving data from?

    I hope we are able to find the cause,

    Mark

     

  • Hi Mark,

    Thank you for your reply. I'm sorry for a late reply. I solved this question by increasing the transmission speed.