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.

CAN Local-acceptance-mask problem

Other Parts Discussed in Thread: TMS320F28069

Hello.

I'm implementing CAN driver on TMS320f28069 and Local-acceptance-mask doesn't work as expected. In Local-Acceptance-Mask Register I specify 0x1FFC0000 and according to the reference manual it should ignore 19-28 bits and match 1-18 with MSGID but it ignore ids like 0x00020000 and 0x00010000 while MSGID  is set to 0x00020000  or 0x00010000  like:

  union CANMSGID_REG msgid;
  msgid.all = (1<< 16);
  msgid.bit.IDE = 1;
  msgid.bit.AME = 1;
  obj->canAMboxes->MBOX16.MSGID.all = msgid.all;

  union CANLAM_REG lam16;
  lam16.all = 0x1FFC0000 ;//0001 1111 1111 1100 0000 0000 0000 0000
  lam16.bit.LAMI = 1;
  obj->canALAMRegs->LAM16.all = lam16.all;

or

  union CANMSGID_REG msgid;
  msgid.all = (2<< 16);
  msgid.bit.IDE = 1;
  msgid.bit.AME = 1;
  obj->canAMboxes->MBOX16.MSGID.all = msgid.all;

  union CANLAM_REG lam16;
  lam16.all = 0x1FFC0000 ;//0001 1111 1111 1100 0000 0000 0000 0000
  lam16.bit.LAMI = 1;
  obj->canALAMRegs->LAM16.all = lam16.all;

according to the reference  manual when LAMI  is set to 1 and  acceptance mask bit is 0 it compares that bit with MSGID and accepts on match, but in my application CAN drops this messages. Any suggestions?

  • Solved it!

    The problem in 2-nd string

    msgid.all = (2<< 16);

    For some reason Code Compose Studio convert "2" in to signed integer and then perform bit shift operation. the simple fix of it is to cast unsigned integer type on number first and then perform bit shift operation like this:

    msgid.all = (((uint32_t)2) << 16);

  • Hi Harry,

    Good job on finding and fixing the problem. We like these kind of posts. I just want to highlight that this is not something that Code Composer does. The IDE only reflects the data type. It is actually the compiler that dictates what the data type would be. If the application does not explicitly specify the type, the compiler will default to an integer. An integer type is signed by default, as you know.

    For shift operations, declaring the shift value to be "unsigned int" is the right thing to do!

    Thanks again!
    Krishna
  • Hi Harry,

    Good job on finding and fixing the problem. We like these kind of posts. I just want to highlight that this is not something that Code Composer does. The IDE only reflects the data type. It is actually the compiler that dictates what the data type would be. If the application does not explicitly specify the type, the compiler will default to an integer. An integer type is signed by default, as you know.

    For shift operations, declaring the shift value to be "unsigned int" is the right thing to do!

    Thanks again!
    Krishna