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.

TM4C123GH6PM: Help needed in CAN programming

Part Number: TM4C123GH6PM

Hello all, 

I am trying to understand the CAN module in TM4C123 device in details to build AUTOSAR CAN driver (this is related to my graduation project).

I am wondering how can i configure all of hardware msg objects before leaving the init state of the CAN controller. for example, if i need 16 object for RX and the other 16 objects for TX. 

i can't understand that since i have only 2 MNUM fields (in the 2 command req. registers). how can i use unique msg. object number for each hardware msg object.

Regards, 

Sarea

  • Hi Sarea,

     You are not using the TivaWare driver library for CAN and instead creating your own AUTOSAR CAN driver?

     The CAN module can support up to 32 message objects.You can use the MNUM field to specify up to 32 message objects. Each message object can be configured to send/receive different message IDs by using the mask. Refer to the CANIFxMSK registers. 

  • That's a most illustrative response - directly aids the poster.

    One comment - the use of SIX Bits (usually enabling "64" choices) - yet "restricted here" to "32" - is (almost guaranteed) to yield more than a few unsuspecting, "cliff jumpers..."     (indeed such is "covered" w/in the "mice-type" - yet color & bold are FREE - and proper "High-Light" beats "squinting" and better insures, "recognition of the unexpected!")

  • Thanks Charles,

    of course, i may use some TivaWare APIs if there is no conflicts with AUTOSAR specifications.

    ----------------------------------------------------------------------------------------------------------------------------

    Did you mean that after doing all configurations in other registers such as ID, masking, TX or RX... etc.

    I should write the MNUM value so this will assign all the setting to the message object i specified and i can repeat the process for another object.

    Is that right ? 

    Regards, 

    Sarea

  • Sarea,

     Your understanding is correct.  Refer to the TivaWare  CAN examples and get a feel on how this is done. Below is a code snippet for setting up two message objects. You can find this example in <TivaWare_Installation>\examples\peripherals\can\multi_tx.c

    //
        // Initialize message object 1 to be able to send CAN message 1.  This
        // message object is not shared so it only needs to be initialized one
        // time, and can be used for repeatedly sending the same message ID.
        //
        g_sCANMsgObject1.ui32MsgID = 0x1001;
        g_sCANMsgObject1.ui32MsgIDMask = 0;
        g_sCANMsgObject1.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
        g_sCANMsgObject1.ui32MsgLen = sizeof(g_pui8Msg1);
        g_sCANMsgObject1.pui8MsgData = g_pui8Msg1;
    
        //
        // Initialize message object 2 to be able to send CAN message 2.  This
        // message object is not shared so it only needs to be initialized one
        // time, and can be used for repeatedly sending the same message ID.
        //
        g_sCANMsgObject2.ui32MsgID = 0x2001;
        g_sCANMsgObject2.ui32MsgIDMask = 0;
        g_sCANMsgObject2.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
        g_sCANMsgObject2.ui32MsgLen = sizeof(g_pui8Msg2);
        g_sCANMsgObject2.pui8MsgData = g_pui8Msg2;