<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Decode/Revert CAN Frame ID in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Decode-Revert-CAN-Frame-ID/m-p/1023172#M56307</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FLEXCAN_ID_STD(rxIdentifier)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then when I receive a CAN packet from the peripheral device, I need to check the frame id. So I use this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;printf("Message Id: 0x%.2X\r\n", rxFrame.id);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it does not give me the correct value. I get&amp;nbsp;0x10C40000 as the frame id but it should be less than 0x7FF for standard IDs. Is there any reverse implementation of&amp;nbsp;&lt;SPAN&gt;FLEXCAN_ID_STD macro to get the correct frame id?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I could have write my own macro by looking at the&amp;nbsp;FLEXCAN_ID_STD&amp;nbsp;implementation and do the reverse job but I don't understand why we can not just get the correct frame id directly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;: I think when I shift the result to &lt;STRONG&gt;right&lt;/STRONG&gt; for &lt;STRONG&gt;18 bits,&lt;/STRONG&gt; I get the correct result. Why does this happen?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Nov 2019 05:53:50 GMT</pubDate>
    <dc:creator>abdullah_cinar</dc:creator>
    <dc:date>2019-11-21T05:53:50Z</dc:date>
    <item>
      <title>Decode/Revert CAN Frame ID</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Decode-Revert-CAN-Frame-ID/m-p/1023172#M56307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FLEXCAN_ID_STD(rxIdentifier)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then when I receive a CAN packet from the peripheral device, I need to check the frame id. So I use this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;printf("Message Id: 0x%.2X\r\n", rxFrame.id);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it does not give me the correct value. I get&amp;nbsp;0x10C40000 as the frame id but it should be less than 0x7FF for standard IDs. Is there any reverse implementation of&amp;nbsp;&lt;SPAN&gt;FLEXCAN_ID_STD macro to get the correct frame id?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I could have write my own macro by looking at the&amp;nbsp;FLEXCAN_ID_STD&amp;nbsp;implementation and do the reverse job but I don't understand why we can not just get the correct frame id directly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;: I think when I shift the result to &lt;STRONG&gt;right&lt;/STRONG&gt; for &lt;STRONG&gt;18 bits,&lt;/STRONG&gt; I get the correct result. Why does this happen?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2019 05:53:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Decode-Revert-CAN-Frame-ID/m-p/1023172#M56307</guid>
      <dc:creator>abdullah_cinar</dc:creator>
      <dc:date>2019-11-21T05:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Decode/Revert CAN Frame ID</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Decode-Revert-CAN-Frame-ID/m-p/1023173#M56308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Abdullah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason you would have to do the shift to get the right id is due to the function that you are using.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sdk was designed to make it easier to create the message buffer, therefore different functions were implemented. One of them is&amp;nbsp;&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold;"&gt;FLEXCAN_ID_STD(rxIdentifier) &lt;/STRONG&gt;as you can see in its declaration it is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(((uint32_t)(((uint32_t)(id)) &amp;lt;&amp;lt; CAN_ID_STD_SHIFT)) &amp;amp; CAN_ID_STD_MASK) /*!&amp;lt; Standard Frame ID helper macro. */&lt;/P&gt;&lt;P&gt;With the shift being an 18 bit shift.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in order to recover the id you will have to shift it to the right or redesign your implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sabina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:13:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Decode-Revert-CAN-Frame-ID/m-p/1023173#M56308</guid>
      <dc:creator>Sabina_Bruce</dc:creator>
      <dc:date>2019-11-25T15:13:03Z</dc:date>
    </item>
  </channel>
</rss>

