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.

CCS/TMS320F28069M: CAN module not receiving data in SCC mode or eCAN mode.

Part Number: TMS320F28069M

Tool/software: Code Composer Studio

Hello,

I have been trying to receive data through can communiaction in f28069. The sender is a CAN module for Raspberry pi based on MC2515 transmitting 500kbps with 75% sample point. f28069 can transmit data without issues to the Raspberry pi. 

following is initialization code:

void can_init_scc_recv_mode(void)
{
    /* Create a shadow register structure for the CAN control registers. This is
     needed, since only 32-bit access is allowed to these registers. 16-bit access
     to these registers could potentially corrupt the register contents or return
     false data. */

    struct ECAN_REGS ECanaShadow;

        EALLOW;     /*EALLOW enables access to protected bits*/

    /* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/

        ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
        ECanaShadow.CANTIOC.bit.TXFUNC = 1;
        ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;

        ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
        ECanaShadow.CANRIOC.bit.RXFUNC = 1;
        ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;

    /* Configure eCAN for HECC mode - (reqd to access mailboxes 16 thru 31) */
    /* HECC mode also enables time-stamping feature*/

        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.SCB = 0;
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

       /* TAn, RMPn, GIFn bits are all zero upon reset and are cleared again
       as a matter of precaution.*/

        ECanaRegs.CANTA.all = 0xFFFFFFFF;   /* Clear all TAn bits */

        ECanaRegs.CANRMP.all = 0xFFFFFFFF;  /* Clear all RMPn bits */

        ECanaRegs.CANGIF0.all = 0xFFFFFFFF; /* Clear all interrupt flag bits */
        ECanaRegs.CANGIF1.all = 0xFFFFFFFF;

    /* Configure bit timing parameters for eCANA*/

        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.CCR = 1 ;            /*Set CCR = 1*/
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

        /* Wait until the CPU has been granted permission to change the
         * configuration registers*/
        do
        {
          ECanaShadow.CANES.all = ECanaRegs.CANES.all;
        } while(ECanaShadow.CANES.bit.CCE != 1 );      /*Wait for CCE bit to be set..*/

        ECanaShadow.CANBTC.all=0x00040053;   //500kbps 75% sample point
        ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;

        /* The previous block is for 80 MHz SYSCLKOUT. (40 MHz CAN module clock Bit rate = 0.5 Mbps
           See Note at end of file. */

        /*CAN GAM settings allowed only in initialization mode*/
        ECanaShadow.CANGAM.all=0x8FFFFFFF;
        ECanaShadow.CANGAM.bit.AMI=1;
        ECanaRegs.CANGAM.all= ECanaShadow.CANGAM.all;
        /**********************************************/

        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.CCR = 0 ;            /*Set CCR = 0*/
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

        /*Wait until the CPU no longer has permission to change the configuration registers*/
        do
        {
          ECanaShadow.CANES.all = ECanaRegs.CANES.all;
        } while(ECanaShadow.CANES.bit.CCE != 0 );       /* Wait for CCE bit to be  cleared..*/

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

        EDIS;
}

For configuring mailboxes i have seperate code:

void InitCANMailbox(uint16_t mailboxIndex, uint32_t filterMaskID,
                      uint16_t mailboxDirection, uint16_t mailBoxDLC)
{
    Uint32 mask;
    Uint32 CAN_MD_REG;
    Uint32 CAN_ME_REG;

    ECanaMboxes.MBOX[mailboxIndex].MSGID.all = filterMaskID;
    ECanaMboxes.MBOX[mailboxIndex].MSGCTRL.bit.DLC = mailBoxDLC;

    mask = 0u;
    mask = (Uint32)(0x00000001u) << mailboxIndex;

    CAN_MD_REG = ECanaRegs.CANMD.all;
    CAN_MD_REG &= ~(mask);   /*first clear the corresponding bit to modify it*/
    /*after the bit is cleared then modify it 0=out 1=in */
    CAN_MD_REG |= ((uint32_t)mailboxDirection << (uint32_t)mailboxIndex);
    ECanaRegs.CANMD.all = CAN_MD_REG;

    CAN_ME_REG = ECanaRegs.CANME.all;
    CAN_ME_REG |= mask;
    ECanaRegs.CANME.all = CAN_ME_REG;    /*enable = 1*/
}

And finally in main i also change the AME bit for each mailbox in following manner:

    ECanaMboxes.MBOX[0].MSGID.bit.AME=1; //repeat for mailboxes 0-15

Change Local Acceptance mask for LAM0 and LAM3 as following:

    ECanaLAMRegs.LAM0.all=0x8FFFFFFF;
    ECanaLAMRegs.LAM3.all=0x8FFFFFFF;
    ECanaLAMRegs.LAM0.bit.LAMI=1;
    ECanaLAMRegs.LAM3.bit.LAMI=1;

I Have tried the same in eCAN mode by changing the SCB bit to 1 but it didnt help i still cant receive data.

I have changed mailbox definitions in ECAN.h to the following:

struct ECAN_MBOXES {
    struct MBOX MBOX[32];
};

I can only receive can messages of message ID with all bits '0'. I cannot receive any message with any other msg id apart from 0. I can receive this message in mailbox 15 because it has the highest receive priority and any other message is not receievd.

Thanks,

Shadab

  • Shadab,

                Have you reviewed the Debug tips in my app note SPRA876 (http://www.ti.com/lit/an/spra876b/spra876b.pdf )? If not, please review it carefully.

    The TRM for 28069 (http://www.ti.com/lit/ug/spruh18h/spruh18h.pdf )was revised recently. Some corrections were made to the eCAN filtering section. Please review that.

    SPRA876 contains several tested examples, one of which is CAN_LAM. Please try it out.

  • Hareesh Sir,

    Thanks for prompt reply, I have gone through TRM throughly, I will check out the APP note and get back to you.  

  • I tried the examples in the zip attached with the application note SPRA876. I can confirm that i can receive messages in both SCC mode and eCAN mode. And LAM example also works along with Raspberry PI. However I have one doubt regarding the functionality of the CAN module present in TMS320 controllers.

    How do we receive the incoming CAN Arbitration ID as well? I can receive messages which have Arbitration ID matching with MSGID of the receiving mailbox. But if I am receiving multiple messages in the same mailbox I also want to know what the incoming Arbitration ID was. This is important for CAN protocols such as CANOPEN where CAN messages have different IDs. Receiving data part is on its own not sufficient in such case.

    Is there a way to configure CAN module in SCC or eCAN mode where the incoming Arbitration ID is also stored in case the mailbox is configured to receive multiple messages.

  • Hareesh, 

    Everything works well now i can receive multiple messages in the same mailbox and the incoming arbitrating ID is written to the MSGID field of the corresponding mailbox.

    Thank you for the help and happy holidays in US.

    Shadab.