AnsweredAssumed Answered

Decode/Revert CAN Frame ID

Question asked by Abdullah Çınar on Nov 20, 2019
Latest reply on Nov 25, 2019 by Sabina Bruce



I am receiving hundreds of different CAN frames from a peripheral device to my MKV11Z64 MCU. When I want to send a frame, I use this macro:




Then when I receive a CAN packet from the peripheral device, I need to check the frame id. So I use this:


printf("Message Id: 0x%.2X\r\n",;


But it does not give me the correct value. I get 0x10C40000 as the frame id but it should be less than 0x7FF for standard IDs. Is there any reverse implementation of FLEXCAN_ID_STD macro to get the correct frame id?


I could have write my own macro by looking at the FLEXCAN_ID_STD implementation and do the reverse job but I don't understand why we can not just get the correct frame id directly.


Edit: I think when I shift the result to right for 18 bits, I get the correct result. Why does this happen?