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.

TMDXRM57LHDK: Serial interrupt buffer gets corrupted?

Part Number: TMDXRM57LHDK

Hi there guys,

I am having trouble understanding a crash of my device. I'll try to explain it in detail.

What my program does:

  • It reads sensor data over serial in asynchronous mode every 67 ms.
  • When the whole serial package has arrived it processes it in the main loop and checks for errors in the data itself
  • It sends the raw data and the error status to a PC via TCP (I am using LwIP 1.4.1). The board is the server and the PC is the client.
  • The client is just a GUI to visualize the sensor data and the status error.

Note: the serial interface receives data in asynchronous mode. This means that while the main loop is processing and sending via TCP the last received data it is also receiving new data over serial.

Problem:

  • When only the serial interface is active (no sending data over TCP), everything runs perfectly. The status error of the data processing is NO_ERROR.
  • If both the EMAC and serial interfaces are active, the image on the GUI starts to "jump". The error status is all over the place. The jumps occur once every 2 seconds or less. Sometimes there are none for a few minutes but they always come back.

Thoughts:

  • At first I thought that I was doing something wrong with the TCP settings that were somehow corrupting some tcp frames or even missing them, but then I noticed the error status and realized the data being received "was wrong/corrupted".
  • Then I thought that the EMAC TX interrupt was interrupting my serial routine and by the time the program comes back to the serial routine the data buffer has "newer/corrupted" data. But according to this thread, even if a higher priority IRQ occurs, it cannot interrupt the current IRQ. So this could not be the case.
  • My theory now is that the serial interrupt is triggered when the EMAC routine is being serviced, so it has to wait. While it is waiting, new data is arriving and either the buffer gets overwritten or that new data is lost. Does this make sense to you guys?

From the Reference Manual, I know there are two receive buffers: the SCIRXSHF and the SCIRD. The frist one gets all incomming data and when a frame has been completely received, the data is transfered to the second one.What is a frame here? As this transfer occurs, the RXRDY flag is set and a receive interrupt is generated.

If the serial interrupt is generated while the program is in the tcp interrupt, what happens with new data at SCIRXSHF? I would think, the SCIRXSHF keeps getting data to avoid losing some, right? Does this new data gets copied to SCIRD (because a complete frame was received) even though the last interrupt hasn't been serviced yet? 

I wanted to see how ti behaves if I set the multi buffer mode (MBUF_MODE -> setting bit 10 of the global control register). But I am not setting it right. I don't see it in the register window of code composer studio. I am using this in the SCI_init function:

// attempt 1
sciREG3->GCR1 |= 0x400U;

// attempt 2
sciREG3->GCR1 |= (uint32)((uint32)1U << 10U)

I'm stuck here guys. I could use some help. 

Thanks and best regards,

Julio

  • Hi Julio,

    What is the frame length (SCIFORMAT, 1~8 bytes) used in your multi-buffer mode SCI configuration? Did you try DMA mode for SCI data transfer?

    Regards,
    QJ
  • Hi QJ,

    Thanks for helping.

    The frame length is 8 bytes in my SCI configuration. Is the SCI configuration buffer-mode dependant? Is there another configuration to take care if using multi-buffer mode? More important, would this help in my case to avoid losing data? I am not even sure if my theory is right, I just wanted to test the program's behavior in multi-buffer mode. What do you think the problem is?

    No, I haven't tried DMA mode for SCI data transfer. Would DMA help in my case to avoid losing data?