I have done a code to comunicate the Ecana with Ecanb of the same F28335 by connecting externally Tx and Rx. The transmit and receive codes are bellow, and must be sent a message from MBOX 25 in the Ecana to MBOX 26 in the Ecanb.
The transmition bit (ECanaShadow.CANTA.bit.TA25) is set by ecan module. However the message does not arrive at Ecanb. i.e, the receive bit (ECanaRegs.CANRMP.bit.RMP26) is not set by the ecan modulo.
void main(){
struct ECAN_REGS ECanaShadow; struct ECAN_REGS ECanbShadow;
InitSysCtrl();
InitECanGpio();
DINT;
InitPieCtrl();
IER = 0x0000; IFR = 0x0000;
InitPieVectTable();
InitECan();
/* Write to the MSGID field */
ECanaMboxes.MBOX25.MSGID.all = 0x95555555; // Extended Identifier
/* Configure Mailbox under test as a Transmit mailbox */
ECanaShadow.CANMD.all = ECanaRegs.CANMD.all; ECanaShadow.CANMD.bit.MD25 = 0; ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
/* Enable Mailbox under test */
ECanaShadow.CANME.all = ECanaRegs.CANME.all; ECanaShadow.CANME.bit.ME25 = 1; ECanaRegs.CANME.all = ECanaShadow.CANME.all;
ECanaMboxes.MBOX25.MSGCTRL.bit.DLC = 8;
/* Write to the mailbox RAM field */
ECanaMboxes.MBOX25.MDL.all = 0x55555555; ECanaMboxes.MBOX25.MDH.all = 0x55555555;
//---------Initialize eCANB for read--------------
ECanbShadow.CANME.all = ECanbRegs.CANME.all; ECanbShadow.CANME.bit.ME25 = 0; ECanbRegs.CANME.all = ECanbShadow.CANME.all;
ECanbMboxes.MBOX25.MSGID.all = 0x95555555; // Extended Identifier
ECanbShadow.CANMD.all = ECanbRegs.CANMD.all; ECanbShadow.CANMD.bit.MD25 = 1; ECanbRegs.CANMD.all = ECanbShadow.CANMD.all;
ECanbMboxes.MBOX25.MSGCTRL.bit.DLC = 8;//-------------------------------------------------------------
/* Begin transmitting */
ECanaShadow.CANTRS.all = 0; ECanaShadow.CANTRS.bit.TRS25 = 1; // Set TRS for mailbox under test ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all; do { ECanaShadow.CANTA.all = ECanaRegs.CANTA.all; } while(ECanaShadow.CANTA.bit.TA25 == 0 ); // Wait for TA5 bit to be set..
ECanaShadow.CANTA.all = 0; ECanaShadow.CANTA.bit.TA25 = 1; // Clear TA5 ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
// receive the msg for(;;) { if (ECanbRegs.CANRMP.bit.RMP25 > 0) { raw_datal=ECanbMboxes.MBOX25.MDL.all; raw_datah=ECanbMboxes.MBOX25.MDH.all; }
}
Felipe,
This is not how CAN was designed to operate. I suspect the CAN controllers are getting confused and not seeing the ACK bit. Connect transceivers to both ecan ports and tie CAN H and CAN L together. This should allow your test case to work assuming your code is correct.
Trey
Trey German
C2000 Applications
I found the error! It was missing to set the bit (ECanb Shadow.CANME.bit.ME3 = 1) after the configuration of the ecanb. Thanks!