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.

TMS570LC4357: Timing issues with MibSPI #1 interface

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

We are trying to use the MibSPI interface (specifically SPI #1) to communicate with an ADC device. The functionality is simple, we want to send and receive 27 packets of data, when the last packet is received a DMA channel is triggered to copy data from RXRAM to a local buffer.

Current configuration:

- Multibuffer mode.

- IO DMA.

- SCS1, SPICLK, SIMO0 and SOMI0 set as functional (rest of pins default setting as non-functional).

- Data format 0:

                         No gap delay, Polarity even, Parity check disable, shift dir MSB, Full duplex enable, CS delays disabled, CLK polarity high, phase delay enable, prescale = 4, data length = 16, 1 line mode.

- Transfer Groups:

                        TG0, TG disable (it will be triggered when required), one shot enable, PRST ignore, trigger always, Trigger source disable, start index = 0.

                        TG1 (dummy, only to limit size of TG0), TG disable (always), start index = 27.

- SPI DMA:

                       one shot disable, Trigger buffer 26, rx dma line 2, rx dma enable, tx dma disable, no brk interleaved.

The configuration for the TXRAM packets is:

                       Suspend overwrite protect, CS hold for two packets and release for third one (repeating this pattern along the 27 packets), TG lock (only the 27th packet is unlock), using data format 0.

We have used other of the available buses and had no problem sending the data packets, but when using SPI #1 the following happens:

- When TG0 is enabled, the transmission starts and only 5 packets are sent one after the other with no problems, then each packet is sent with a gap of ~14ms between them, so transmitting the 27 packets is taking a lot.

- Another test was to create 8 TGs (0 to 7) and allocate 3 packets per TG (24 packets total), we try to enable all TG, 1 by 1, and TGs 1 to 7 send the 3 packets as expected but TG0 sends only 2 packets and then waits few ms before sending the last one, a transmission that could take ~500us ends up taking several ms.

Do you know if there is any difference we should consider when using SPI #1? 

If you need any other information to better describe what could be happening, let me know.

Regards,

  • Hi Carlos,

    I started to be working on your issue and i will provide an update very soon.

    --

    Thanks & Regards,
    Jagadish.

  • Hi Jagadish, thank you for looking at this issue.

    We have run more test and we found the following (in case it helps you to understand better what's going on):

    We have a scheduler which contains one function to trigger the transmission (enable TG) and another that is called later to read the received data. Apparently, the gap between each sent data packet is the duration of the scheduler frame. For some reason when the TG is enabled it sends only one data packet.

    if we add a loop to wait for the TG transfer complete flag all the data is sent as expected, the thing is that the functionality we are looking for is to get the TG enabled, let the CPU to take care of other tasks and then try to read when the data is supposed to be available. 

    Regards,

    -Carlos.

  • Hi Carlos,

    We have used other of the available buses and had no problem sending the data packets, but when using SPI #1 the following happens

    I don't get this point, are you tested with any other SPI's? is it working properly with other SPI's and having problem with only SPI #1 instance?

    ~14ms between them, so transmitting the 27 packets is taking a lot.

    This much of delay should not happen with SPI, how can you make sure that it is not slave delay? And controller is acting like SPI master right?

  • I don't get this point, are you tested with any other SPI's? is it working properly with other SPI's and having problem with only SPI #1 in

    Correct, we have developed other drivers using SPI#5, SPI#2, SPI#3 and we are having issues only with SPI#1.

    This much of delay should not happen with SPI, how can you make sure that it is not slave delay? And controller is acting like SPI mast

    Yes, controller is the master and acts like it. But in latest test we found that this delay is dependent on how often we enable the TG, the problem we are facing is that every time we enable the TG (trigger transmission) the bus doesn't send all the packets that are part of it (27 in this case), it only sends one. So, since we are calling the trigger function every 14 ms we are seeing one packet transmitted at that rate. However, the expected behavior is to get all the packets transmitted every time the TG is enabled, right?

  • Hi Carlos,

    Can i get a minimal version of your code with only SPI functionality? So i can easily test and debug your issue at my end.

    --

    Thanks & Regards,
    Jagadish.

  • Hi Jagadish, 

    We created a small application using Halcogen to get a program that only runs the SPI for our application, we found the SPI was working fine there. 

    That's why I didn't send you the minimal version you requested.

    However, in our final application we found out why the SPI #1 was having issues. For safety/certification we are explicitly disabling all modules that we are not using and apparently when we disable I2C the SPI starts having some timing issues.

    #define SYS_I2C1_BIT_POSITION_DISABLE 8
    #define SYS_I2C2_BIT_POSITION_DISABLE 9
    /* Disable I2Cx module */
    pcrREG3->PSPWRDWNSET0 |= 1U<< (uint32)SYS_I2C1_BIT_POSITION_DISABLE;
    pcrREG3->PSPWRDWNSET0 |= 1U<< (uint32)SYS_I2C2_BIT_POSITION_DISABLE;
    After commenting these two lines above, we get the SPI #1 to work as expected.
    We still want to disable I2C since we are not using it, do you know why this affects SPI interface?
    Regards,
    -Carlos.
  • Hi Carlos,

    There should not be any dependency for SPI with I2C bits,

    Did you check that whether any other part of the programming also using the macros you mentioned?

    --

    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Turns out our logic to disable the modules was incorrect and we were actually disabling the MIBSPI1 module instead of the I2C1 module.

    Knowing that, however, we wonder how we were still able to interact with the module while it should have been disabled...

    The MIBSPI1 was disabled by mistake, setting bits 8 and 9 (Peripheral select 2, quadrants 0 and 1) in PSPWRDNSET0 register for PCR3 to disable it. While the MIBSPI1 peripheral didn't work as expected, it did work partially where we were able to transmit data, which is surprising considering it should be disabled... At this point, we're wondering what using these PSPWRDNSET registers is doing. Is there anything else required to disable the module?

    Best regards,

  • actually disabling the MIBSPI1 module instead of the I2C1 module.

    If we did that means, MIBSPI1 should not work anymore right?

    Knowing that, however, we wonder how we were still able to interact with the module while it should have been disabled.

    Can you please verify exactly which bits of the registers are affecting with the commented lines. I mean verify exactly which bits states are changing when we uncomment and comment the lines. Better to do this in debug mode, is that possible?

    Then we will see the definition those bits.

    --

    Thanks & regards,
    Jagadish.

  • Hi,

    Closing the thread because of not hearing back from so long.

    --

    Thanks & regards,
    Jagadish.