Failure to Receive CAN Message in 16FX C_CAN Sample Code – KBA221416

Version: **

 

Question:

 

In the 16FX (MB96600 series) C_CAN sample project, CAN messages were not received on some RX channels when MessageObjects larger than 16 were used. How can I solve this issue?

 

Answer:

In the MB96600 series C-CAN sample code, there is a bug in the c_can.c file, which does not allow any MessageObject number larger than 16 to be passed to the message buffer. This resulted in the failure. The following code is an example to fix the issue:

//MB96620 sample project, c_can.c

Line 137: void TxRx_Judge_0(void)

              {

               unsigned short MsgNbr = 0x00;

              unsigned long MsgBuffer;

 

              MsgNbr = IO_CAN2.INTR2;                //stor MsgNbr

 

if( (MsgNbr>=1) && (MsgNbr<=0x20) ) // valid buffer number

              {

                 // MsgBuffer = 0x01 << (MsgNbr-1);    //Original code in sample project.

                  MsgBuffer = ((unsigned long)0x01) << (MsgNbr-1);    //Modified new code.

              …

              }

    }

You can download the MB96600 series sample code from 16FX product webpage.