<?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 Re: KW36 FLEXCAN - GET ALL IDs (no filter) in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KW36-FLEXCAN-GET-ALL-IDs-no-filter/m-p/1200492#M59124</link>
    <description>&lt;P&gt;I think I found a good solution. When implement a (no)filter CAN Rx (mask 0x000), the CAN0_MB_IRQHandler will be called on all Tx and Rx messages because if it is listen all the identifiers, it should also stop with the ones we sends.&lt;/P&gt;&lt;P&gt;The easiest way to fix this is to set the interrupt in this way:&lt;/P&gt;&lt;PRE&gt;void CAN0_MB_IRQHandler( void ){&lt;BR /&gt;if(FLEXCAN_GetMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; rxBuffer) &amp;amp;&amp;amp; (FLEXCAN_GetStatusFlags(CAN0) &amp;amp; kFLEXCAN_ReceivingFlag)){&lt;BR /&gt;FLEXCAN_ReadRxMb(CAN0, rxBuffer, &amp;amp;rxFrame);&lt;BR /&gt;CAN0_Rx(); //function to do something with rxFrame&lt;BR /&gt;FLEXCAN_ClearStatusFlags(CAN0, kFLEXCAN_ReceivingFlag); &lt;BR /&gt;}&lt;BR /&gt;FLEXCAN_ClearMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; rxBuffer);&lt;BR /&gt;FLEXCAN_ClearMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; txBuffer);&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;This solution has solved my main problem (the main loop stopped executing any line because the interrupt consumes all the time and the INTR FLAG was always 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Dec 2020 16:05:00 GMT</pubDate>
    <dc:creator>acarles</dc:creator>
    <dc:date>2020-12-16T16:05:00Z</dc:date>
    <item>
      <title>KW36 FLEXCAN - GET ALL IDs (no filter)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KW36-FLEXCAN-GET-ALL-IDs-no-filter/m-p/1199817#M59120</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have some problems trying to configure the CAN to recieve all the possible identifiers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that I have to set a 0x0 mask to (no)filter the messages. This is my &lt;EM&gt;canInit&lt;/EM&gt; function:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  FLEXCAN_Init(CAN0, &amp;amp;CAN0_config, CAN0_ENGINE_CLOCK_SOURCE);
  FLEXCAN_Enable(CAN0, true);
  flexcan_rx_mb_config_t mb_config = {
    .id = FLEXCAN_ID_STD(0x0),
    .format = kFLEXCAN_FrameFormatStandard,
    .type = kFLEXCAN_FrameTypeData
  };
  FLEXCAN_SetRxMbConfig(CAN0, rxBuffer, &amp;amp;mb_config, true);
  FLEXCAN_SetRxIndividualMask(CAN0, rxBuffer, FLEXCAN_RX_MB_STD_MASK(0x0,0,0)); //In config, individual mask is enabled
  FLEXCAN_SetTxMbConfig(CAN0, txBuffer, true);
  FLEXCAN_EnableMbInterrupts(CAN0, 1 &amp;lt;&amp;lt; rxBuffer);&lt;/LI-CODE&gt;&lt;P&gt;I can send messages (every 9ms for example) and recieve messages (all the possible IDs) but the main problem is that function &lt;EM&gt;CAN0_MB_IRQHandler&lt;/EM&gt; is called all the time. Inside the interruption, I used&amp;nbsp;&lt;EM&gt;FLEXCAN_GetMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; rxBuffer)&amp;nbsp;&lt;/EM&gt;to check if there is any message in rxBuffer.&lt;/P&gt;&lt;P&gt;Because it is&amp;nbsp;stopping each cycle in the interruption, the main while don't run. If I comments the lines that involve the Tx message there is no problem because&amp;nbsp;&lt;EM&gt;CAN0_MB_IRQHandler&lt;/EM&gt;&amp;nbsp;is not called at every moment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, what I do not understand is why the &lt;EM&gt;CAN0_MB_IRQHandler&lt;/EM&gt;&amp;nbsp;handler is called every millisecond and not every 9ms (if Tx is the main problem).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;uint8_t CAN0_SEND_8 (uint16_t ID,uint8_t DATA1, uint8_t DATA2, uint8_t DATA3, uint8_t DATA4, uint8_t DATA5, uint8_t DATA6, uint8_t DATA7, uint8_t DATA8, uint8_t LONG)
{
  flexcan_frame_t txFrame;
  if (!FLEXCAN_GetMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; txBuffer)){    
    txFrame.format = kFLEXCAN_FrameFormatStandard;
    txFrame.type   = kFLEXCAN_FrameTypeData;
    txFrame.id     = FLEXCAN_ID_STD(ID);
    txFrame.length = LONG;
    txFrame.dataWord0 = CAN_WORD0_DATA_BYTE_0(DATA1) |
      CAN_WORD0_DATA_BYTE_1(DATA2) |
        CAN_WORD0_DATA_BYTE_2(DATA3) |
          CAN_WORD0_DATA_BYTE_3(DATA4);
    txFrame.dataWord1 = CAN_WORD1_DATA_BYTE_4(DATA5) |
      CAN_WORD1_DATA_BYTE_5(DATA6) |
        CAN_WORD1_DATA_BYTE_6(DATA7) |
          CAN_WORD1_DATA_BYTE_7(DATA8);
    FLEXCAN_WriteTxMb(CAN0, txBuffer, &amp;amp;txFrame);    
    return TRUE;
  }
  return FALSE; 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have configured a PIT callback (1ms).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void PIT_IRQHandler(){
  m_tick++;
  if(FLEXCAN_GetMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; txBuffer)){
    FLEXCAN_ClearMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; txBuffer);
  }
  CAN_Update(); //Here a switch call every 9 cycles CAN_SEND_8
   PIT_ClearStatusFlags(PIT_PERIPHERAL, PIT_CHANNEL_0, 1); 
  #if defined __CORTEX_M &amp;amp;&amp;amp; (__CORTEX_M == 4U)
    __DSB();
  #endif

}&lt;/LI-CODE&gt;&lt;P&gt;If I use flexcan examples with blocking (while) flag cleaning, it happens the same. Is the 0x000 mask the main problem?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/3665"&gt;@santiago_lopez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 18:07:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KW36-FLEXCAN-GET-ALL-IDs-no-filter/m-p/1199817#M59120</guid>
      <dc:creator>acarles</dc:creator>
      <dc:date>2020-12-15T18:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: KW36 FLEXCAN - GET ALL IDs (no filter)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KW36-FLEXCAN-GET-ALL-IDs-no-filter/m-p/1200492#M59124</link>
      <description>&lt;P&gt;I think I found a good solution. When implement a (no)filter CAN Rx (mask 0x000), the CAN0_MB_IRQHandler will be called on all Tx and Rx messages because if it is listen all the identifiers, it should also stop with the ones we sends.&lt;/P&gt;&lt;P&gt;The easiest way to fix this is to set the interrupt in this way:&lt;/P&gt;&lt;PRE&gt;void CAN0_MB_IRQHandler( void ){&lt;BR /&gt;if(FLEXCAN_GetMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; rxBuffer) &amp;amp;&amp;amp; (FLEXCAN_GetStatusFlags(CAN0) &amp;amp; kFLEXCAN_ReceivingFlag)){&lt;BR /&gt;FLEXCAN_ReadRxMb(CAN0, rxBuffer, &amp;amp;rxFrame);&lt;BR /&gt;CAN0_Rx(); //function to do something with rxFrame&lt;BR /&gt;FLEXCAN_ClearStatusFlags(CAN0, kFLEXCAN_ReceivingFlag); &lt;BR /&gt;}&lt;BR /&gt;FLEXCAN_ClearMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; rxBuffer);&lt;BR /&gt;FLEXCAN_ClearMbStatusFlags(CAN0, 1 &amp;lt;&amp;lt; txBuffer);&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;This solution has solved my main problem (the main loop stopped executing any line because the interrupt consumes all the time and the INTR FLAG was always 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 16:05:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KW36-FLEXCAN-GET-ALL-IDs-no-filter/m-p/1200492#M59124</guid>
      <dc:creator>acarles</dc:creator>
      <dc:date>2020-12-16T16:05:00Z</dc:date>
    </item>
  </channel>
</rss>

