<?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>MQX Software SolutionsのトピックFLEXCAN Bug found</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/FLEXCAN-Bug-found/m-p/420755#M13979</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying the FLEXCAN driver in MQX latest release 4.2.0.1. &lt;/P&gt;&lt;P&gt;What I wanted to do is to capture all the CAN bus traffics.&lt;/P&gt;&lt;P&gt;To simplify the development, need to set the filter to enable the single MB to receive both standard message and extended frame message.&lt;/P&gt;&lt;P&gt;During the test, I found that there are 2 functions have bugs and 1 function needs to be improved. I put the detail here and see if it can be accepted by MQX team.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bugs.&lt;/P&gt;&lt;P&gt;The 2 functions - FLEXCAN_Write and FLEXCAN_Read are used to read and write 32bit registers of FLEXCAN module. But the source code of the functions return portion is like this.&lt;/P&gt;&lt;P&gt; FLEXCAN_Read : *data_ptr = (uint32_t) *(unsigned char *)read_ptr;&lt;/P&gt;&lt;P&gt; FLEXCAN_Write:&amp;nbsp; *(unsigned char *)write_ptr = (unsigned char)value;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the write and read operation is just 8bit. I revised it to &lt;/P&gt;&lt;P&gt; FLEXCAN_Read: *data_ptr = *(uint32_t *)read_ptr;&lt;/P&gt;&lt;P&gt; FLEXCAN_Write: *(uint32_t *)write_ptr = value;&lt;/P&gt;&lt;P&gt; Now it can operator 32bit registers correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need to improve.&lt;/P&gt;&lt;P&gt;I found the function FLEXCAN_Rx_Message needs to be improve to match the CAN bus definition correctly. &lt;/P&gt;&lt;P&gt;Definition of the function:&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t FLEXCAN_Rx_message(&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint8_t dev_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t mailbox_number,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *identifier,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&lt;SPAN style="color: #e23d39;"&gt;uint32_t format&lt;/SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *data_len_code,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;void *data,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t int_enabled)&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P&gt;According to CAN bus protocol, the format &lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;should be reflected by the IDE field of the message buffer, so it should be and out type instead of in type.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;During my test of using 1 MB to receive both standard and extended format messages. I met the issue - if the received message is standard and the format is set to FLEXCAN_EXTENDED, the return ID is incorrect, and vise vesa.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;I think it should be defined like this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t FLEXCAN_Rx_message(&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint8_t dev_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t mailbox_number,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *identifier,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&lt;SPAN style="color: #e23d39;"&gt;uint32_t *format&lt;/SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *data_len_code,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;void *data,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t int_enabled)&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;I revised the code to reflect the definition change &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* store data len */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *format = can_reg_ptr-&amp;gt;MB[mailbox_number].CS &amp;amp; CAN_CS_IDE_MASK?FLEXCAN_EXTENDED:FLEXCAN_STANDARD;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dlen = can_reg_ptr-&amp;gt;MB[mailbox_number].CS &amp;amp; CAN_CS_DLC_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DLC = dlen &amp;gt;&amp;gt; CAN_CS_DLC_SHIFT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Reassemble the message ID */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (*format)&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;Now the format output will be the current Message format and ID will be returned correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Oct 2015 23:16:35 GMT</pubDate>
    <dc:creator>shulongli</dc:creator>
    <dc:date>2015-10-22T23:16:35Z</dc:date>
    <item>
      <title>FLEXCAN Bug found</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/FLEXCAN-Bug-found/m-p/420755#M13979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying the FLEXCAN driver in MQX latest release 4.2.0.1. &lt;/P&gt;&lt;P&gt;What I wanted to do is to capture all the CAN bus traffics.&lt;/P&gt;&lt;P&gt;To simplify the development, need to set the filter to enable the single MB to receive both standard message and extended frame message.&lt;/P&gt;&lt;P&gt;During the test, I found that there are 2 functions have bugs and 1 function needs to be improved. I put the detail here and see if it can be accepted by MQX team.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bugs.&lt;/P&gt;&lt;P&gt;The 2 functions - FLEXCAN_Write and FLEXCAN_Read are used to read and write 32bit registers of FLEXCAN module. But the source code of the functions return portion is like this.&lt;/P&gt;&lt;P&gt; FLEXCAN_Read : *data_ptr = (uint32_t) *(unsigned char *)read_ptr;&lt;/P&gt;&lt;P&gt; FLEXCAN_Write:&amp;nbsp; *(unsigned char *)write_ptr = (unsigned char)value;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the write and read operation is just 8bit. I revised it to &lt;/P&gt;&lt;P&gt; FLEXCAN_Read: *data_ptr = *(uint32_t *)read_ptr;&lt;/P&gt;&lt;P&gt; FLEXCAN_Write: *(uint32_t *)write_ptr = value;&lt;/P&gt;&lt;P&gt; Now it can operator 32bit registers correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need to improve.&lt;/P&gt;&lt;P&gt;I found the function FLEXCAN_Rx_Message needs to be improve to match the CAN bus definition correctly. &lt;/P&gt;&lt;P&gt;Definition of the function:&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t FLEXCAN_Rx_message(&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint8_t dev_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t mailbox_number,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *identifier,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&lt;SPAN style="color: #e23d39;"&gt;uint32_t format&lt;/SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *data_len_code,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;void *data,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t int_enabled)&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P&gt;According to CAN bus protocol, the format &lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;should be reflected by the IDE field of the message buffer, so it should be and out type instead of in type.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;During my test of using 1 MB to receive both standard and extended format messages. I met the issue - if the received message is standard and the format is set to FLEXCAN_EXTENDED, the return ID is incorrect, and vise vesa.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;I think it should be defined like this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t FLEXCAN_Rx_message(&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint8_t dev_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t mailbox_number,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *identifier,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&lt;SPAN style="color: #e23d39;"&gt;uint32_t *format&lt;/SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t *data_len_code,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;void *data,&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;uint32_t int_enabled)&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;I revised the code to reflect the definition change &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* store data len */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *format = can_reg_ptr-&amp;gt;MB[mailbox_number].CS &amp;amp; CAN_CS_IDE_MASK?FLEXCAN_EXTENDED:FLEXCAN_STANDARD;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dlen = can_reg_ptr-&amp;gt;MB[mailbox_number].CS &amp;amp; CAN_CS_DLC_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DLC = dlen &amp;gt;&amp;gt; CAN_CS_DLC_SHIFT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Reassemble the message ID */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (*format)&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;Now the format output will be the current Message format and ID will be returned correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 23:16:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/FLEXCAN-Bug-found/m-p/420755#M13979</guid>
      <dc:creator>shulongli</dc:creator>
      <dc:date>2015-10-22T23:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: FLEXCAN Bug found</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/FLEXCAN-Bug-found/m-p/420756#M13980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shulong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your bug report about the flexcan demo and offered solutions.&amp;nbsp; I will verify this issue and&amp;nbsp; report it to the relative developers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2015 11:41:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/FLEXCAN-Bug-found/m-p/420756#M13980</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2015-10-29T11:41:06Z</dc:date>
    </item>
  </channel>
</rss>

