Hello,
I have configured a mailbox as transmit in F28035 eCAN, and I am receiving the data through an Arduino shield. The problem is that when I am not updating the data dynamically, i.e. when I am sending the same data over and over again, it works fine, but when I am trying to change the data, the TAn bit does not set (there is no transmission acknowledgement).
Here is my code:
EALLOW;
ECanaRegs.CANTRR.bit.TRR0 = 1;
while(ECanaRegs.CANTRS.bit.TRS0 != 0);
ECanaRegs.CANME.bit.ME0 = 0;
ECanaMboxes.MBOX0.MSGID.all = 0x80000548;
ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
ECanaRegs.CANMD.bit.MD0 = 0; //transmit mailbox
ECanaRegs.CANME.bit.ME0 = 1; //enable mailbox
while(1)
{
// ECanaRegs.CANTRR.bit.TRR0 = 1;
// while(ECanaRegs.CANTRS.bit.TRS0 != 0);
ECanaRegs.CANMC.bit.MBNR = 0;
ECanaRegs.CANMC.bit.CDR = 1;
//load data
ECanaMboxes.MBOX0.MDH.all = i;
ECanaMboxes.MBOX0.MDL.all = j;
ECanaRegs.CANMC.bit.CDR = 0;
ECanaRegs.CANTRS.bit.TRS0 = 1;
while(ECanaRegs.CANTA.bit.TA0 != 1)
{
// clear error flags (if any)
// if(ECanaRegs.CANES.all & (0x1FF0000) != 0){
// ECanaRegs.CANES.all = 0x1FF0000;
// break;
// }
}
ECanaRegs.CANTA.bit.TA0 = 1;
delay(10, MILLI); //wait for 10 milli seconds before next transmission
}
On checking the register values, I see that the TRSn bit is still set (the previous transmission is not yet complete). It seems to me that there is some mistake in loading fresh data into the buffer. What is the correct procedure?
Thanks
Yash