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.

TMS320F280049: Tuning CAN based on can_ex3_external_transmit project

Part Number: TMS320F280049

Hi team, 

I am working with my customer trying to tuning his CAN communication.

I used two F280049 launchpads to test the can_ex3_external_transmit example.

In F280049(TX), CANA OBJ1 is set as tx as below:

CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x95555555,
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);

In F280049(RX), CANA OBJ1 is set as RX as below:

CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x95555555
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0,
CAN_MSG_OBJ_RX_INT_ENABLE, MSG_DATA_LENGTH);

With the above configuration, the code works fine adn RX and receive the right data. However, if I change the MSG ID of F280049(RX) to 0x95555554. The RX cannot receive any data or run into the RX interrupt.

According to the code, the MASK is not set. Why changing the MSG ID will cause the RX not to receive anything?

Regards,

Brian

 

  • Besides, I have also tried to add the identifier mask for RX :

    CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x95555554
    CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0xFFFFFFF0,
    CAN_MSG_OBJ_RX_INT_ENABLE, MSG_DATA_LENGTH);

    Since the RX ID =0x95555554, TX ID =0x95555555, and ID MASK = 0xFFFFFFF0, I believe the the RX should be able to receive the data. However, nothing can be received. Only when RX ID = TX ID, the communication works.

    Besides, when I observe the CAN regs after CAN_setupMessageObject() function, the Msk region is still all 0:


    Could you kindly help to check this question?

  • Brian

    With no masking/filtering, only matching message IDs are received.
    Your concept of the masking is correct but you aren't passing in the flag to the CAN_setupMessageObject() to enable the filtering. You should also include the flag parameter "CAN_MSG_OBJ_USE_EXT_FILTER" to enable the filtering.

    Best regards
    Chris
  • Hi Chris,
    Following your advice, I did the following modification to CAN_setupMessageObject():

    Receiver:

    CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x95555554,
    CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0xFFFFFFFF,
    CAN_MSG_OBJ_RX_INT_ENABLE||CAN_MSG_OBJ_USE_EXT_FILTER , MSG_DATA_LENGTH);

    Transmitter:
    CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x95555554,
    CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0,
    CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);

    As you can see, the receiver ID is 0x95555554(same as transmitter). The ID mask is all FF and filter is enabled by CAN_MSG_OBJ_USE_EXT_FILTER.
    After doing this, nothing can be received at all. Even if I try to change the ID mask to 0xFFFFFFF0, I cannot receive anything from the receiver side.

    Besides, if I replace the || with |, like this:

    CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x95555554,
    CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0xFFFFFFFF,
    CAN_MSG_OBJ_RX_INT_ENABLE|CAN_MSG_OBJ_USE_EXT_FILTER , MSG_DATA_LENGTH);

    Than the filter does not work any more. Whatever the ID of RX is, the message obj can receive the correct message.



    Thanks,
    Chris

  • Brian

    My apologizes, you also need the flag: CAN_MSG_OBJ_USE_ID_FILTER (this enables use of mask filtering and the other enables filtering on the full EXT ID)
    Make sure to use the "|" and not "||". "||" isn't a bitwise OR.

    So for RX flags, it will look like (CAN_MSG_OBJ_RX_INT_ENABLE | CAN_MSG_OBJ_USE_ID_FILTER | CAN_MSG_OBJ_USE_EXT_FILTER)

    Best regards
    Chris
  • Hi Chris,
    Thanks for the instruction.
    I am using CAN_MSG_OBJ_USE_ID_FILTER | CAN_MSG_OBJ_USE_EXT_FILTER and every works as expected.
    This is a good takeaway for the new CAN architecutre.


    Thanks,
    Brian
  • Brian

    Good to hear! I'll file a bug to have the FILTER flag usage clarified with a bit more detail.

    Thanks
    Chris
  • Sorry Chris,

    One more question:

    Does F280049 CAN module only support 32-bit operation? I have a few cases that experienced C2000 engineer tried to code F28004x using bit structure they are used to. However, there is a possibility that the CAN will not work. After I suggest them to change to 32-bit operation, everything works well. So it seems the F28004x devices only support 32-bit write/read as noted in the TRM. Is that correct?
  • Using only 32-bit write is recommended and best procedure to follow.

    Best regards
    Chris
  • Chris,
    Thanks! Solid support!