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.

TMS320F28388D: IPC message queue and empty messages

Part Number: TMS320F28388D

Hi,

I have set up an IPC message queue between CPU1 and 2 of an F28388D. Surprisingly, I receive some empty messages.

There is a regular event (I have tried at 35kHz and 100Hz, same issue) sending between 1 and 3 messages. Each message is comprised of a data structure of a different size (3 configurations). All messages are sent in the same message queue. On the other end, a regular event (35kHz) checks whether the queue is empty or not, and if not, empties the que.

In most cases, the messages arrive as expected. However, every once in a while, the whole message is empty, ie the "receiving" data structure gets filled with 0s.

code on the receiving side :

inline void getDataCpu1ToCpu2(void)
{
	IPCM_error_t _err_ipc;
	bool _queue_has_msg = TRUE;

	while(_queue_has_msg)
	{
		_queue_has_msg = IPC_readMessageFromQueue(s_ipc_config_cpu1_cpu2.type, s_ipc_config_cpu1_cpu2.msgqueue, IPC_ADDR_CORRECTION_ENABLE, &IPCM_rx_msg, IPC_NONBLOCKING_CALL);

		if ((_queue_has_msg == TRUE) && (IPCM_rx_msg.command == IPCM_CMD_READ_MEM)	&& (IPCM_rx_msg.dataw2 == ID_MESSAGEQUEUE_1))
		{
            /* copy data in the proper "receiving" structure */
        }
		else if ((_queue_has_msg == TRUE) && (IPCM_rx_msg.command == IPCM_CMD_READ_MEM)	&& (IPCM_rx_msg.dataw2 == ID_MESSAGEQUEUE_2))
		{
            /* copy data in the proper "receiving" structure */
        }
		else if ((_queue_has_msg == TRUE) && (IPCM_rx_msg.command == IPCM_CMD_READ_MEM)	&& (IPCM_rx_msg.dataw2 == ID_MESSAGEQUEUE_3))
		{
            /* copy data in the proper "receiving" structure */
        }

	}
}

I have checked on the sending side, the messages sent are consistent.

The receiving data structure is always all-0 or all-OK.

One idea I had (although I have no idea how to check that) is : what happens when there isn't enough room in the circular buffer for the next message ?

Thanks in advance for your help,

Best regards,

Adrien

  • Adrien,

    One idea I had (although I have no idea how to check that) is : what happens when there isn't enough room in the circular buffer for the next message ?

    It should overwrite the next message in the buffer.

    I haven't seen this issue before, and I'm not 100% sure what could cause it. I'll do some digging.

    Best Regards,

    Ben Collier

  • Adrien,

    I have checked on the sending side, the messages sent are consistent.

    How have you been checking this? 

    Could you set a breakpoint on your receiving side that will only be triggered when you receive all zeroes? This way you can see what's happening with the message queue when the problem occurs.

    Best Regards,

    Ben Collier

  • Hi Ben,

    How have you been checking this? 

    I put a breakpoint just before sending the message. The data is copied from a structure in a non-shared memory into a buffer structure in the shared memory. The breakpoint is set after the copy process, just in time to send the data via IPC. I read the data in the buffer structure. On the other end, there is a breakpoint on data reception, and I can get messages filled with 0s even when the data send buffer is correct.

    Could you set a breakpoint on your receiving side that will only be triggered when you receive all zeroes? This way you can see what's happening with the message queue when the problem occurs.

    This is what I did, but I don't know what to look for in the message queue when that happens. Can you tell me what I should look for ?

    Thanks in advance,

    Best regards,

    Adrien

  • Adrien,

    Could you check these values?

    Then we want to check the addresses in the message RAM.

    Since you said that the message is being sent correctly, I think the problem is that the readMessageQueue() is checking the wrong address. Let's try to figure out how that is happening. 

    Best Regards,

    Ben Collier

  • Hi Ben,

    I put a breakpoint on CPU1 before sending a message, and in CPU2 when I receive a message filled with 0s. This way, CPU1 won't send extra messages anymore and affect the message queue when CPU2 stops at its breakpoint.

    Here is what I get when I hit a breakpoint in CPU2 :

    The GetBuffer data seems OK, I am sending 4 32bits words (dataw1 = 8), and the message ID is as expected (dataw2 = 3). I don't know about the rest though.

    That being said, I did some extra testing, and I found the issue !

    When removing the slow messages, there were no more issues with the fast ones. When moving the slow messages to the fast interrupt, same. So I figured the issue might be when the slow messages are writing in the messagequeue and are interrupted by the fast ones who do the same.

    I added a mutex around writing in the messagequeue, and the issue went away !

    Thanks for your help,

    Best regards,

    Adrien