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.

eCAN transmit message box sometimes does not accept data and as a result the value 0x00 is sent

Hi guys,

Sometimes my eCAN transmit message box does not accept data.

The corresponding line of code is executed, but the value in the data field of the message box does not change in almost 50 % of the cases.
Am I missing something?


Here is my code:

	ECanaShadow.CANTRS.all = ECanaRegs.CANTRS.all;
	if(!ECanaShadow.CANTRS.bit.TRS28)
	{
		/* disable mailbox 28*/
		ECanaShadow.CANME.all = ECanaRegs.CANME.all;
		ECanaShadow.CANME.bit.ME28 = 0;
		ECanaRegs.CANME.all = ECanaShadow.CANME.all;

		/* Set message ID */
		ECanaMboxes.MBOX28.MSGID.bit.IDE = 0;
		ECanaMboxes.MBOX28.MSGID.bit.STDMSGID = ID;

		/* Re-enable Mailbox 28 */
		ECanaShadow.CANME.all = ECanaRegs.CANME.all;
		ECanaShadow.CANME.bit.ME28 = 1;
		ECanaRegs.CANME.all = ECanaShadow.CANME.all;

		ECanaMboxes.MBOX28.MSGCTRL.bit.DLC = length;


		if(length == 2)
		{
			ECanaMboxes.MBOX28.MDL.byte.BYTE0  = (data>>8) & 0xFF;
			ECanaMboxes.MBOX28.MDL.byte.BYTE1  = data & 0xFF;
		}
		else if(length == 1)
		{
			ECanaMboxes.MBOX28.MDL.byte.BYTE0  = data & 0xFF;
		}

		/* Begin transmitting */
		ECanaShadow.CANTRS.all = 0;
		ECanaShadow.CANTRS.bit.TRS28 = 1;             // Set TRS for mailbox under test
		ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
	}

  • Hello,

        That is pretty unusual. Are you sure the data itself changes? Can you do the shifting and ANDing in a separate step, copy the result into a variablee and use that variable to update the mailbox? You could also observe the variable in the Watch window to ensure it really changes.