<?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: MPC5746C FlexCAN RXFifo Usage in S32 SDK</title>
    <link>https://community.nxp.com/t5/S32-SDK/MPC5746C-FlexCAN-RXFifo-Usage/m-p/875491#M900</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eyup,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which SDK version do you use? Generally it is not recommended to modify the driver, we cannot guaranty the functionality then.&lt;/P&gt;&lt;P&gt;For example &lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;FLEXCAN_DRV_ConfigRxFifo&lt;SPAN&gt;&amp;nbsp; in the&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;SDK RTM 1.0.0 is properly filling the ID filter element so no modification is needed.&lt;/P&gt;&lt;P&gt;I created simple demo base on&amp;nbsp;flexcan_mpc5748g example in this SDK version and it runs properly.&lt;/P&gt;&lt;P&gt;You can refer to&amp;nbsp;&lt;A href="https://community.nxp.com/docs/DOC-342882"&gt;https://community.nxp.com/docs/DOC-342882&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR, Petr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Mar 2019 12:08:48 GMT</pubDate>
    <dc:creator>PetrS</dc:creator>
    <dc:date>2019-03-26T12:08:48Z</dc:date>
    <item>
      <title>MPC5746C FlexCAN RXFifo Usage</title>
      <link>https://community.nxp.com/t5/S32-SDK/MPC5746C-FlexCAN-RXFifo-Usage/m-p/875490#M899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an interesting problem&amp;nbsp; when I try to use RXFifo ( using interrupt) feature of FLEXCAN. I hope to find a solution as soon as possible.&lt;/P&gt;&lt;P&gt;I have initialized CAN driver with below configuration,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const flexcan_user_config_t canCom1_InitConfig0 = {&lt;BR /&gt; .fd_enable = false,&lt;BR /&gt; .pe_clock = FLEXCAN_CLK_SOURCE_FXOSC,&lt;BR /&gt; .max_num_mb = 96,&lt;BR /&gt; .num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_128,&lt;BR /&gt; .is_rx_fifo_needed = true,&lt;BR /&gt; .flexcanMode = FLEXCAN_NORMAL_MODE,&lt;BR /&gt; .payload = FLEXCAN_PAYLOAD_SIZE_8,&lt;BR /&gt; .bitrate = {&lt;BR /&gt; .propSeg = 7,&lt;BR /&gt; .phaseSeg1 = 4,&lt;BR /&gt; .phaseSeg2 = 1,&lt;BR /&gt; .preDivider = 4,&lt;BR /&gt; .rJumpwidth = 1&lt;BR /&gt; },&lt;BR /&gt; .bitrate_cbt = {&lt;BR /&gt; .propSeg = 7,&lt;BR /&gt; .phaseSeg1 = 4,&lt;BR /&gt; .phaseSeg2 = 1,&lt;BR /&gt; .preDivider = 4,&lt;BR /&gt; .rJumpwidth = 1&lt;BR /&gt; },&lt;BR /&gt; .transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,&lt;BR /&gt; .rxFifoDMAChannel = 0U&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed&amp;nbsp;&lt;SPAN&gt;flexcan_id_table_t structure like that,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef struct {&lt;BR /&gt; bool isRemoteFrame; /*!&amp;lt; Remote frame*/&lt;BR /&gt; bool isExtendedFrame[128]; /*!&amp;lt; Extended frame*/&lt;BR /&gt; uint32_t idFilter[128]; /*!&amp;lt; Rx FIFO ID filter elements*/&lt;BR /&gt;} flexcan_id_table_t;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I filled id filter table,&lt;/P&gt;&lt;P&gt;rx_fifo_id_filter_table.isRemoteFrame = false;&lt;/P&gt;&lt;P&gt;for(id_counter=0;id_counter&amp;lt;128;id_counter++)&lt;BR /&gt; {&lt;BR /&gt; rx_fifo_id_filter_table.isExtendedFrame[id_counter] = (id_counter % 2);&lt;BR /&gt; rx_fifo_id_filter_table.idFilter[id_counter] = id_counter +1 ;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the Flexcan Init function,&lt;/P&gt;&lt;P&gt;&amp;nbsp; FLEXCAN_DRV_Init(INST_CANCOM1, &amp;amp;canCom1_State, &amp;amp;canCom1_InitConfig0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;I configured RX fifo and mask like that,&lt;/P&gt;&lt;P&gt;FLEXCAN_DRV_ConfigRxFifo(INST_CANCOM1, FLEXCAN_RX_FIFO_ID_FORMAT_A, &amp;amp;rx_fifo_id_filter_table);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; FLEXCAN_DRV_SetRxMaskType(INST_CANCOM1, FLEXCAN_RX_MASK_INDIVIDUAL);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for(id_counter=0;id_counter&amp;lt;32;id_counter++)&lt;BR /&gt; FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1, FLEXCAN_MSG_ID_EXT, id_counter, 0xFFFFFFFF);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FLEXCAN_DRV_SetRxFifoGlobalMask(INST_CANCOM1, FLEXCAN_MSG_ID_EXT, 0xFFFFFFFF);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I changed&amp;nbsp;FLEXCAN_SetRxFifoFilter(only updated Format A side, because I use this format) function called in&amp;nbsp;&lt;SPAN&gt;FLEXCAN_DRV_ConfigRxFifo function, because I need to filter both STD and Extended ID at the same time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is the updated function,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;void FLEXCAN_SetRxFifoFilter(&lt;BR /&gt; CAN_Type * base,&lt;BR /&gt; flexcan_rx_fifo_id_element_format_t idFormat,&lt;BR /&gt; const flexcan_id_table_t *idFilterTable)&lt;BR /&gt;{&lt;BR /&gt; DEV_ASSERT(idFilterTable != NULL);&lt;/P&gt;&lt;P&gt;/* Set RX FIFO ID filter table elements*/&lt;BR /&gt; uint32_t i, j, numOfFilters;&lt;BR /&gt; uint32_t val1 = 0, val2 = 0, val = 0U;&lt;/P&gt;&lt;P&gt;volatile uint32_t *filterTable = &amp;amp;base-&amp;gt;RAMn[RxFifoFilterTableOffset];&lt;/P&gt;&lt;P&gt;numOfFilters = (((base-&amp;gt;CTRL2) &amp;amp; CAN_CTRL2_RFFN_MASK) &amp;gt;&amp;gt; CAN_CTRL2_RFFN_SHIFT);&lt;/P&gt;&lt;P&gt;switch(idFormat)&lt;BR /&gt; {&lt;BR /&gt; case (FLEXCAN_RX_FIFO_ID_FORMAT_A):&lt;BR /&gt; /* One full ID (standard and extended) per ID Filter Table element.*/&lt;BR /&gt; (base-&amp;gt;MCR) = (((base-&amp;gt;MCR) &amp;amp; ~(CAN_MCR_IDAM_MASK)) | ( (((uint32_t)(((uint32_t)(FLEXCAN_RX_FIFO_ID_FORMAT_A))&amp;lt;&amp;lt;CAN_MCR_IDAM_SHIFT))&amp;amp;CAN_MCR_IDAM_MASK)));&lt;/P&gt;&lt;P&gt;if (idFilterTable-&amp;gt;isRemoteFrame)&lt;BR /&gt; {&lt;BR /&gt; val = FlexCanRxFifoAcceptRemoteFrame &amp;lt;&amp;lt; FLEXCAN_RX_FIFO_ID_FILTER_FORMATAB_RTR_SHIFT;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; RxFifoFilterElementNum(numOfFilters); i++)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;if (idFilterTable-&amp;gt;isExtendedFrame[i])&lt;BR /&gt; {&lt;BR /&gt; val |= FlexCanRxFifoAcceptExtFrame &amp;lt;&amp;lt; FLEXCAN_RX_FIFO_ID_FILTER_FORMATAB_IDE_SHIFT;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; val = 0U;&lt;/P&gt;&lt;P&gt;if(idFilterTable-&amp;gt;isExtendedFrame[i])&lt;BR /&gt; {&lt;BR /&gt; filterTable[i] = val + ((idFilterTable-&amp;gt;idFilter[i] &amp;lt;&amp;lt;&lt;BR /&gt; FLEXCAN_RX_FIFO_ID_FILTER_FORMATA_EXT_SHIFT) &amp;amp;&lt;BR /&gt; FLEXCAN_RX_FIFO_ID_FILTER_FORMATA_EXT_MASK);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; filterTable[i] = val + ((idFilterTable-&amp;gt;idFilter[i] &amp;lt;&amp;lt;&lt;BR /&gt; FLEXCAN_RX_FIFO_ID_FILTER_FORMATA_STD_SHIFT) &amp;amp;&lt;BR /&gt; FLEXCAN_RX_FIFO_ID_FILTER_FORMATA_STD_MASK);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Up to this side is init part of my project,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is forever part of my code,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FLEXCAN_DRV_RxFifo(INST_CANCOM1,&amp;amp;recvBuff);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;With these configuration I expected that I can receive message with id that is defined in id table. It is working by step by debug operation. I have tried to receive and interrupt service with&amp;nbsp; one by one defined ID.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After that, I have tried continues test with debug control sometimes. I have faced that a little time after, all interrupts are generated, rx warnig, rx overflow, rx frame avaliable. And CPU gets IVOR0_handler(), it is not avaliable now.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is the screen shot of my project status at that time,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64375i99B8D5F6D143B10B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also your SDK interrupt service routine is not able to reset rx warning and rx overflow interrupt flag.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I changed for this aim your sdk interrupt service function like that,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(flag_reg != 0U)&lt;BR /&gt; {&lt;BR /&gt; bool rxfifoEnabled = FLEXCAN_IsRxFifoEnabled(base);&lt;BR /&gt; if ((mb_idx == FEATURE_CAN_RXFIFO_FRAME_AVAILABLE || mb_idx ==FEATURE_CAN_RXFIFO_WARNING || mb_idx==FEATURE_CAN_RXFIFO_OVERFLOW ) &amp;amp;&amp;amp; rxfifoEnabled)&lt;BR /&gt; {&lt;BR /&gt; if (state-&amp;gt;mbs[FLEXCAN_MB_HANDLE_RXFIFO].state == FLEXCAN_MB_RX_BUSY || true)&lt;BR /&gt; {&lt;BR /&gt; /* Get RX FIFO field values */&lt;BR /&gt; FLEXCAN_ReadRxFifo(base, state-&amp;gt;mbs[FLEXCAN_MB_HANDLE_RXFIFO].mb_message);&lt;/P&gt;&lt;P&gt;/* Complete receive data */&lt;BR /&gt; FLEXCAN_CompleteRxMessageFifoData(instance);&lt;BR /&gt; FLEXCAN_ClearMsgBuffIntStatusFlag(base, mb_idx);&lt;/P&gt;&lt;P&gt;/* Invoke callback */&lt;BR /&gt; if (state-&amp;gt;callback != NULL)&lt;BR /&gt; {&lt;BR /&gt; state-&amp;gt;callback(instance, FLEXCAN_EVENT_RXFIFO_COMPLETE, state);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As a result,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- According to your experience, which operation am I doing wrong? How can I fix this problem,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- My expectatiton from RX Fifo with interrupts feature, CPU can generate interrupt and gather data related message with up to 128 ID ( both STD and EXT with suitable mask operation).(Altough on the bus with %90 load(this is only for test)) Is it correct?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My project that I am working on is attached.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am looking forward your comments,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Eyup,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2019 15:44:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/MPC5746C-FlexCAN-RXFifo-Usage/m-p/875490#M899</guid>
      <dc:creator>magazine_earaz</dc:creator>
      <dc:date>2019-03-20T15:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: MPC5746C FlexCAN RXFifo Usage</title>
      <link>https://community.nxp.com/t5/S32-SDK/MPC5746C-FlexCAN-RXFifo-Usage/m-p/875491#M900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eyup,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which SDK version do you use? Generally it is not recommended to modify the driver, we cannot guaranty the functionality then.&lt;/P&gt;&lt;P&gt;For example &lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;FLEXCAN_DRV_ConfigRxFifo&lt;SPAN&gt;&amp;nbsp; in the&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;SDK RTM 1.0.0 is properly filling the ID filter element so no modification is needed.&lt;/P&gt;&lt;P&gt;I created simple demo base on&amp;nbsp;flexcan_mpc5748g example in this SDK version and it runs properly.&lt;/P&gt;&lt;P&gt;You can refer to&amp;nbsp;&lt;A href="https://community.nxp.com/docs/DOC-342882"&gt;https://community.nxp.com/docs/DOC-342882&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR, Petr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2019 12:08:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/MPC5746C-FlexCAN-RXFifo-Usage/m-p/875491#M900</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2019-03-26T12:08:48Z</dc:date>
    </item>
  </channel>
</rss>

