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.

TMS320F280025C: SPIA working perfectly fine but SPIB giving lot of errors in data.

Part Number: TMS320F280025C

I have a requirement to interface TMS320F280025C with another controller over SPI interface. 280025C is configured as SPI slave. I have used SPI example 4 that uses DMA controller with SPI TX and RX buffers. The DMA is set for burst size of 8 and transfer size of 4. So 32 words make one complete transaction. I have disabled the internal loop back so that SPI receives data externally.  Initially I tested by sending stream of data (32 16-bit words) using SPIA interface. The controller receives and prints data without any errors. As a next step I modified the same code for SPIB interface. Keeping the rest of the code same only the pinMux settings were updated for SPIB and DMA channels were assigned to SPIB instead of SPIA. However the SPIB interface is giving a lot of errors in the receive data. For e.g. if I am sending a constant value of 2 repeatedly 32 times then the data received in the SPIB buffer is as below:


DMA:2 2 2 258 2 1 2 2 2 0 2
2 2 2 0 2 258 2 2 2 2
2 258 1 7 2 2 2 0 2 2
2



DMA:2 2 2 2 0 2 2 2 0 2 2
2 1 2 2 2 2 2 0 2 2
58 2 0 2 2 2 3 2 2 2 2
2



DMA:2 2 6 2 2 2 2 0 0 2 2
6 1 2 2 2 0 2 2 2 2
0 2 2 2 6 2 2 2 2 0
2

The red values are in error. I don't suspect any issue with the transmission controller as SPIA interface reads data correctly. I have tested SPIB interface without DMA using FIFO interrupt but the results are same. I have spent more than 2 days to figure this issue but all in vain. I suspect there could be any silicon issue in SPIB?. Please check and let me know if I need to correct something.


  • Asad,

    SPIB is validated as much as SPIA. There is a very remote chance that this could be a silicon issue. From your description, all I see is you incorrectly get  SPIB RX data sporadically. I would difficult for me to guess what could be the problem. Will you be able to share your code both master and slave? What is your SPI Master?

    Regards,

    Manoj

  • Dear Manoj,

         Thank you very much for initial thought sharing. To add more information, I am using TMS320F280025C launch pad as SPI slave. For the master side, I am using Arduino Due. The arduino code is very simple and is working fine with SPIA. It is given as below:

    #include <Arduino.h>
    #include <SPI.h>

    uint16_t RX_Data = 0;
    void setup()
    {
      // put your setup code here, to run once:
      Serial.begin(9600);
      SPI.begin();
      SPI.setDataMode(SPI_MODE0);
      SPI.setBitOrder(MSBFIRST);
      SPI.setClockDivider(168);//setting clock to 84MHz/210= 500 KHz
      pinMode(14OUTPUT);//Connected to TMS320F280025C STE pin.
        
    }

    void loop()
    {
      // put your main code here, to run repeatedly:
      delay(1000);
      while(1)
      {
        digitalWrite(14,LOW);//asserting STE low
        RX_Data = SPI.transfer16(2);//transfers 16 bit value
        digitalWrite(14,HIGH);//asserting STE high
        Serial.print("SPI RX: ");
        Serial.println(RX_Data);
        delayMicroseconds(5000);
      }
    }
    The TMS320F280025C launchpad  code for SPIB is as below:
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //#############################################################################
    //
    // FILE: spi_ex4_loopback_dma.c
    //
    // TITLE: SPI Digital Loopback with DMA
    //
    //! \addtogroup driver_example_list
    //! <h1>SPI Digital Loopback with DMA</h1>
    //!
    //! This program uses the internal loopback test mode of the SPI module. Both
    //! DMA interrupts and the SPI FIFOs are used. When the SPI transmit FIFO has
    //! enough space (as indicated by its FIFO level interrupt signal), the DMA
    //! will transfer data from global variable sData into the FIFO. This will be
    //! transmitted to the receive FIFO via the internal loopback.
    //!
    //! When enough data has been placed in the receive FIFO (as indicated by its
    //! FIFO level interrupt signal), the DMA will transfer the data from the FIFO
    //! into global variable rData.
    //!
    //! When all data has been placed into rData, a check of the validity of the
    //! data will be performed in one of the DMA channels' ISRs.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    I am also attaching code for SPIA that works without any communication errors.
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //#############################################################################
    //
    // FILE: spi_ex4_loopback_dma.c
    //
    // TITLE: SPI Digital Loopback with DMA
    //
    //! \addtogroup driver_example_list
    //! <h1>SPI Digital Loopback with DMA</h1>
    //!
    //! This program uses the internal loopback test mode of the SPI module. Both
    //! DMA interrupts and the SPI FIFOs are used. When the SPI transmit FIFO has
    //! enough space (as indicated by its FIFO level interrupt signal), the DMA
    //! will transfer data from global variable sData into the FIFO. This will be
    //! transmitted to the receive FIFO via the internal loopback.
    //!
    //! When enough data has been placed in the receive FIFO (as indicated by its
    //! FIFO level interrupt signal), the DMA will transfer the data from the FIFO
    //! into global variable rData.
    //!
    //! When all data has been placed into rData, a check of the validity of the
    //! data will be performed in one of the DMA channels' ISRs.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Looking forward to hear from you.
  • Just to add a small correction to the Arduino code. The SPI clock divider was set to 84 so that its clock operates at 1 MHz same as configured for the TMS320F280025C. I was later testing with slower clock rates to check if there is any improvement. I did not find any improvement with reduced clock rates.

  • Have you already tried probing the SPI bus with logic analyzer to check the bus activity? Can you share the SPI logic analyzer snapshots.Have you tried making just one transfer and see whether you see the same problem.

    I'm in middle of a important project. I can take deeper look into this only next week

  • Dear Manoj,

         I tried probing through logic analyzer and verified the data integrity. I will make a setup again to capture for you. I hardly doubt at the transmission side as SPIA on the same controller is able to receive all data correctly. However I will try single transfer as proposed by you. I would request you to take an early look into provided codes once you get free from your ongoing project. We have already sent PCBs for production and I am afraid if we might need to hold and do a revision by replacing SPIB with SPIA.

  • Asad,

    I briefly looked into your code and couldn't figure out anything which caused concern. I need to try running your code and check whether I see the same behavior.

    Regards,

    Manoj

  • Dear Manoj

          I did a detailed testing over the weekend with logic analyzer. I used another TMS320F280025C launchpad as a master in place of Arduino. I had one finding that I want to share. I have been connecting both the master as slave to the USB ports of the laptop. I have noticed that when my laptop is connected with power charger then SPI slave as well as the logic analyzer receives lot of error transmissions. However when I disconnect the power charger the logic analyzer sniffs all the data correctly. Next I tested SPIA and SPIB on slave side controller. The test was done with external power charger disconnected. SPIA receives all data correctly. SPIB has some spurious readings. Please find below some readings from SPIB:

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 4102 15 8 9 10 11 12 13 14 79 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 16399 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    SPIB:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    The frequency of error value is reduced a lot with external power charger disconnected. I am looking into it from noise perspective. Please test at your end on TMS320F280025C Launchpad to see if you find any difference between SPIA and SPIB reception.

  • Asad,

    Based on your description, it looks like SPI signals are getting affected by EMI noise in your setup (power charger). Did you observe the incorrect data on both SPIA / SPIB when using power charger? Also, when both the master and slave boards are connected? Are you making sure to connect GND pins of both master and slave setup?

    Since we are dealing with EMI noise, it would be better to use oscilloscope instead of logic analyzer. Please share your analyzer snapshots, oscilloscope snapshots and photograph of your setup. I shall get started looking into your code.

    Regards,

    Manoj

  • Dear Manoj, 

    We are off from work and will resume on Friday. I will try to capture oscilloscope results and test setup with you then. It is our observation that SPIA is much less prone to noise. It is getting data correctly more than 95% in all cases. However SPIB appears to be more sensitive and is getting high percentage error in noise case. We have replaced SPIB with SPIA in our design to reduce chances of bad communication in production. Thanks alot for continued support.

  • Asad,

    We want to understand this problem and see whether we have a genuine issue. This could be board issue, setup issue (or) remotely device issue. Please do share your oscilloscope snapshots and test setup photos to help us get to the bottom of this problem.

    As of now, there are no known issues with SPIA / SPIB.

    Regards,

    Manoj

  • Any update? Did you get a chance to get oscilloscope snapshots.

  • Dear Manoj,

         Sorry for the late reply. I got infected with CoVid and there was 3 week absence from office. We don't have any conclusive finding yet. It could be due to our jumper wires or the external noise. It will take me some time to get back to the SPI task. We can close this ticket. If there is any new findings then I will share with you.

  • Sorry to hear that. Wishing you a speed recovery.

    I shall close this ticket for now.