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.

SPI Problem with 2808 with extra pulses

Hi, I've got a problem with a 2808 SPI interface being used as slave. The problem is that occasionally there are extra pulses on the SOMI line that cause erroneous data to be received by the master. The strange thing is that this situation only occurs SOMETIMES after a power on reset. On one power up the data would be good for an entire session, after another power up the data gets these erroneous pulses and continues to have these pulses during the entire session, but they don't occur in every word. There is no difference in the way the power is cycled in either case.

 My slave SPI in the 2808 is setup for rising clock edge with 1/2 cycle delay before the rising edge, 16 bit data, Tx FIFO disabled. In the attached plots there are good pulses and bad pulses (labelled) showing the data and corresponding clock edges. I have also tried the SPI GPIO pins configured as sync and async modes with no difference. Also, the changing the master clock speed makes no difference.

It's my understanding that in SPI slave mode the only way data can change is with master clock edges. That doesn't seem to be the case here and the data changes at times other than the falling clock edge.

In the plots below, trace 1 yellow is SOMI (from 2808), trace 2 green is SCLK (from master). These plots are taken very close to the DSP pins.

Here's the SPI init code:

// Initialize SPI FIFO registers
   SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI

   SpiaRegs.SPICCR.all=0;
   SpiaRegs.SPICCR.bit.CLKPOLARITY=0;  // set up for rising edge with delay
   SpiaRegs.SPICCR.bit.SPICHAR=15;       // 16 bit characters

   SpiaRegs.SPICTL.all=0;
   SpiaRegs.SPICTL.bit.CLK_PHASE=1;    //  delayed clock pulse
   SpiaRegs.SPICTL.bit.MASTER_SLAVE=0; // Slave
   SpiaRegs.SPICTL.bit.TALK=1;           // Talk enabled
   SpiaRegs.SPICTL.bit.SPIINTENA=1;       // Interrupt enabled

   SpiaRegs.SPIPRI.all=0x0000;         // Free run in emulation mode

   SpiaRegs.SPISTS.all=0x0000;


  temp = SpiaRegs.SPIRXBUF;           //clear any pending ISR    

// Enable interrupts for SPIA Rx
   PieCtrlRegs.PIEIER6.bit.INTx1=1;     //INT6 bit 0 SPIA Rx INT

   SpiaRegs.SPICCR.bit.SPISWRESET=1;  // Enable SPIA

   SpiaRegs.SPITXBUF = 0x0525;          //preload state 1

 

The way the code works is upon receipt of the SPI Rx interrupt, the ISR reads the SPIRXBUF register then loads the next word into the SPITXBUF register. The master clock is 4MHz x 16 bits =4uS per word transfer. There is a 52uS delay in the master between word requests. The 2808 has a 20MHz clock with the SYSCLK running at 100MHz.


One thing to note is that we are NOT using the SPISTE line. There are no GPIO's configured for this function.

Is not controlling SPISPTE a problem?

Could not controlling SPISPTE cause what we're seeing?

Can I just tie SPISPTE low in hardware and enable a GPIO as this function?

Thank you.

  • Hi Bob,

    I am not completely sure what the root cause is yet.

    It very well could have something to do with SPISTE.  The SPISTE is used to resynch the SPI state machine such that the first pulse coming in from the master is known to be the first pulse coming in from the master.  If you can tie an unused GPIO to the GPIO which has your SPISTE signal, you can pull SPISTE low a little prior to your master's SPI packet coming in, you may be able to experiment with this.

    Before you do this, I do notice you're running the SPI at a relatively high speed.  Does this bad behavior continue if you drop the bit rate down to maybe 500k?  I might also recommend speeding up the LSPCLK (which goes to the SPI module) by changing its prescaler from /4 to /2.

    Hopefully this gives you some ideas.


    Thank you,
    Brett

  • Hi Bret, Thank you for your prompt reply.
    I have the LSPCLK set to SYSCLK/1 ( SysCtrlRegs.LOSPCP.all = 0x0000;) which should allow a max SPICLK rate of 100/4=25MHz, no?
    We did do a test with lower clock rates and it made no difference.
    I don't have a way to "know" when the master is going to start sending clock signals since it's a remote device. Is there any harm in tying SPISTE low all the time?
    Thanks,
    Bob
  • Update: We enabled SPISTE on a GPIO and set the input low. The problem still persists.
  • Bob,

    Does this problem follow the device or the Firmware? In other words, can you try the firmware on another device? Or, can you try the SPI code examples on this device and see if the problem persists?
  • Hi Bob,

    To answer your previous question:
    It is tough to say yes or no on whether there is harm in tying SPISTE low.  It can be fine.  However, there is a possibility for a clock error to occur and the SPI slave to be misaligned with the master's clock.  A SPI SWRESET can resolve this, but it is something extra to be aware of.  The SPI STE does provide a helpful feature.

    In addition to Mark's response, could you post your GPIO settings? 

    I also notice that the glitches seem to be appearing at a specific place in the SPI transaction.  Is there any chance that your code is accidentally changing these GPIO settings?


    Thank you,
    Brett

  • One thing to keep in mind is that this problem only happens after "some" number of resets. All other times it's fine. I have similar code running on a completely different module and it runs fine. Only one board design seems to have the issue (on multiple units). I don't believe the code is changing GPIO settings, since it does run fine as I stated after some resets.

    The GPIO settings for the SPI are:
    GpioDataRegs.GPADAT.all= 0x0000;
    GpioCtrlRegs.GPACTRL.all = 0x0000;
    GpioCtrlRegs.GPAQSEL1.all = 0x0000;
    GpioCtrlRegs.GPAQSEL2.all = 0x0000;

    GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; // 0=GPIO, 1=SPISIMOA 2=CANTXB 3=TZ5
    GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; // 0=GPIO, 1=SPISOMIA 2=CANRXB 3=TZ6
    GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1; // 0=GPIO, 1=SPICLKA 2=SCITXB 3=rsvd
    GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1; // 0=GPIO, 1=SPISTEA 2=SCIRXB 3=rsvd

    GpioCtrlRegs.GPAQSEL2.bit.GPIO16 =3;
    GpioCtrlRegs.GPAQSEL2.bit.GPIO17 =3;
    GpioCtrlRegs.GPAQSEL2.bit.GPIO18 =3;
    GpioCtrlRegs.GPAQSEL2.bit.GPIO19 =3;
  • Could you define 'resets'? SPI SWRESETs? Device resets? Other resets?
  • Power cycles (power on reset)
  • Bob,

    The more information you add, the stranger this issue seems to get...

    For debug purposes, could you completely disconnect all loads from the C2000's SPISOMI line, then probe the SPISOMI line to see if the 'glitches' go away?


    Thank you,
    Brett

  • Hi Brett,

     I haven't really added any information from my first post other than to clarify the reset and the SPI register settings. I will try your suggestion. The problem is that the units are at a customer site that I don't have direct access to. The customer is performing the testing/changes for us.

    Thanks,

    Bob

  • Hi Bob,

    OK.  Then perhaps it's more correct that I better understood what you originally wrote as we further discussed the issue. 

    I have never heard of anything like this from our chip.  If the customer gets back with you and if all signs point to it being us, please let us know.


    Thank you,
    Brett


  • .Hi Brett,

    Disconnecting SOMI has no effect. I was able to get it to fail on my setup after many power cycles. Here's what I'm seeing. When the fault occurs, it appears the output register gets loaded a new data word mid-stream. This seems to be the case because the next 16 clocks output the correct sequence of 0101 x 4 even though it ends up finishing mid-word of the next word.  The two scope shots show what I mean. The first scope shot shows the fault mid-word. Then counting the next 16 clock pulse, overlapping into the next word, the patter of 0x5555 is correct. The sequence is now off by 8 clock pulses.

    How is it possible to overwrite the TxDAT register if I'm only writing to the TxBUF register? Is this a bug in the DSP?

    SPI Mid-word fault.pdf

  • Hi Bob,

    I agree that something odd is going on here.  If we can, let's take this issue offline. 


    Thank you,
    Brett

  • Bob,
    Can you have your customer get linked up to this thread and start discussions with the product experts? That would be best for fast data/waveform sharing to get to the root cause quickly.
    Regards,
    John
  • Hi John,

     As I mentioned earlier, I am now able to see this on my system as well. My customer does have the link to this thread and is watching for solutions. Brett and Mark have initiated a direct contact via email and conference call. At this point I think that's the best way to resolve this quickly. Once a solution is found, I will post it for the benefit of anyone else that comes across this issue.

    Thanks,

    Bob

  • I would like to close this thread out.

    It was discovered that the master device was occasionally transitioning the clock line before the system was fully up and running. Since the Slave (F2808) was not using the SPISTE, the spurious clock pulses corrupted the internal bit counter inside the Slave, causing it to lose synchronization.

    The recommended workaround for any application not using SPISTE (SPISTE is tied to ground, always active) is to periodically toggle the SPISWRESET bit to reset the SPI state machine, bit counter, and flags. If the SPI had lost synchronization due to spurious clock pulses, this method would provide a way to re-sync the communication.

    The resolution for this poster's startup problem was to do a SPISWRESET after the initialization of both devices, but before the master would start communicating.


    Regards,
    Mark