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.

F28035 eCan Init, receive not working

First 4 mailboxes MB0-MB4 for receive and MB4-MB7 to transmit, remaining not used

Transmit working, receive not working, testing with IXXAT CAN-USB device. Sample code worked OK, 0-15 transmit and 16-32 receive

I have modified the sample code, is there anything missed?

//********************************************************************************************************************

ECanaRegs.CANME.all = 0; // Required before writing the MSGIDs

ECanaMboxes.MBOX0.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX0.MSGID.bit.STDMSGID = 0x400;
ECanaMboxes.MBOX1.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX1.MSGID.bit.STDMSGID = 0x400;
ECanaMboxes.MBOX2.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX2.MSGID.bit.STDMSGID = 0x400;
ECanaMboxes.MBOX3.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX3.MSGID.bit.STDMSGID = 0x400;

ECanaMboxes.MBOX4.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX4.MSGID.bit.STDMSGID = 0x210;
ECanaMboxes.MBOX5.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX5.MSGID.bit.STDMSGID = 0x210;
ECanaMboxes.MBOX6.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX6.MSGID.bit.STDMSGID = 0x210;
ECanaMboxes.MBOX7.MSGID.bit.IDE = 0;
ECanaMboxes.MBOX7.MSGID.bit.STDMSGID = 0x210;

// Configure Mailboxes 0-3 as Rx, 4-7 as Tx
// Since this write is to the entire register (instead of a bit
// field) a shadow register is not required.
ECanaRegs.CANMD.all = 0x0000000F; //0-3 receive and 4-7 TXT, remaining not used

// Enable all Mailboxes */
// Since this write is to the entire register (instead of a bit
// field) a shadow register is not required.
ECanaRegs.CANME.all = 0x000000FF;

// Specify that 8 bits will be sent/received
ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX1.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX2.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX3.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX4.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX5.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX6.MSGCTRL.bit.DLC = 8;
ECanaMboxes.MBOX7.MSGCTRL.bit.DLC = 8;


// Write to the mailbox RAM field of MBOX4 - 7
ECanaMboxes.MBOX4.MDL.all = 0x00000000;
ECanaMboxes.MBOX4.MDH.all = 0x00000000;
ECanaMboxes.MBOX5.MDL.all = 0x00000000;
ECanaMboxes.MBOX5.MDH.all = 0x00000000;
ECanaMboxes.MBOX6.MDL.all = 0x00000000;
ECanaMboxes.MBOX6.MDH.all = 0x00000000;
ECanaMboxes.MBOX7.MDL.all = 0x00000000;
ECanaMboxes.MBOX7.MDH.all = 0x00000000;

// Since this write is to the entire register (instead of a bit
// field) a shadow register is not required.
EALLOW;
ECanaRegs.CANMIM.all = 0xFFFFFFFF;
ECanaRegs.CANOPC.all = 0x0000000F;
// Configure the eCAN for self test mode
// Enable the enhanced features of the eCAN.
// EALLOW;
// ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
// ECanaShadow.CANMC.bit.STM = 0; // Configure CAN for self-test mode
// ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
EDIS;

//********************************************************************************************************************

  • Joy Philipz said:

    // Specify that 8 bits will be sent/received
    ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX1.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX2.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX3.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX4.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX5.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX6.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX7.MSGCTRL.bit.DLC = 8;

    What about the other bits of MSGCTRL?  I'd recommend:

    ECanaMboxes.MBOX0.MSGCTRL.all = 0;

    ECanaMboxes.MBOX0.MSGCTRL.bit.DLC =8;

    etc.