<?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: CAN Receive with FreeRTOS in S32K</title>
    <link>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366703#M12652</link>
    <description>&lt;P&gt;Hi Robin!&lt;/P&gt;&lt;P&gt;I ported the sample code to my freeRTOS project and it works fine.&lt;/P&gt;&lt;P&gt;The key is to only call the&amp;nbsp;&lt;STRONG&gt;CAN_Receive&amp;nbsp;&lt;/STRONG&gt;only once and wait until all data are there.&lt;/P&gt;&lt;P&gt;Thx for the support.&lt;/P&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Christof&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 13:31:12 GMT</pubDate>
    <dc:creator>christofhaiding</dc:creator>
    <dc:date>2021-11-04T13:31:12Z</dc:date>
    <item>
      <title>CAN Receive with FreeRTOS</title>
      <link>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1363923#M12619</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;I am currently transporting the can_pal_S32K148 example to an FreeRTOS based project.&lt;/P&gt;&lt;P&gt;I created two different tasks, one for sending the other one for receiving&lt;/P&gt;&lt;P&gt;Sending in a separate Task is no problem.&lt;/P&gt;&lt;P&gt;But now i want to do some receiving.&lt;/P&gt;&lt;P&gt;Everything is fine as long as i use the Lines from the example project in my receive task:&lt;/P&gt;&lt;P&gt;/* Define receive buffer */&lt;BR /&gt;can_message_t recvMsg;&lt;/P&gt;&lt;P&gt;/* Start receiving data in RX_MAILBOX. */&lt;BR /&gt;CAN_Receive(&amp;amp;can_pal1_instance, RX_MAILBOX, &amp;amp;recvMsg);&lt;/P&gt;&lt;P&gt;/* Wait until the previous FlexCAN receive is completed */&lt;BR /&gt;&lt;STRONG&gt;while(CAN_GetTransferStatus(&amp;amp;can_pal1_instance, RX_MAILBOX) == STATUS_BUSY);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* Check the received message ID and payload */&lt;BR /&gt;if((recvMsg.data[0] == LED0_CHANGE_REQUESTED) &amp;amp;&amp;amp;&lt;BR /&gt;recvMsg.id == RX_MSG_ID)&lt;BR /&gt;{&lt;BR /&gt;/* Toggle output value LED0 */&lt;BR /&gt;PINS_DRV_TogglePins(GPIO_PORT, (1 &amp;lt;&amp;lt; LED0));&lt;BR /&gt;}&lt;BR /&gt;else if((recvMsg.data[0] == LED1_CHANGE_REQUESTED) &amp;amp;&amp;amp;&lt;BR /&gt;recvMsg.id == RX_MSG_ID)&lt;BR /&gt;{&lt;BR /&gt;/* Toggle output value LED1 */&lt;BR /&gt;PINS_DRV_TogglePins(GPIO_PORT, (1 &amp;lt;&amp;lt; LED1));&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;If i send a data everything works without a problem.&lt;/P&gt;&lt;P&gt;But with this option I have the whole Idle time inside the while loop waiting for the state to get "unbusy", which I don't want to have.&lt;/P&gt;&lt;P&gt;So i tried to change it to something like this:&lt;/P&gt;&lt;P&gt;/* Start receiving data in RX_MAILBOX. */&lt;BR /&gt;CAN_Receive(&amp;amp;can_pal1_instance, RX_MAILBOX, &amp;amp;recvMsg);&lt;/P&gt;&lt;P&gt;/* Wait until the previous FlexCAN receive is completed */&lt;BR /&gt;&lt;STRONG&gt;if(CAN_GetTransferStatus(&amp;amp;can_pal1_instance, RX_MAILBOX) == STATUS_BUSY)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; return;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Because if i call this cyclic it should be the same like with the while, right?&lt;/P&gt;&lt;P&gt;Which works fine, if i send CAN Message with the wrong IDs.&lt;BR /&gt;But as soon as I send the CAN Message with the wright ID, for example 2 as done in the can_pal_S32K148 example, the whole system stops and I end up being stuck in the FreeRtos Watchdog.&lt;/P&gt;&lt;P&gt;I decreased the calling cycle to 1ms, which is the fastes cycle I can adjust at the FreeRTOS.&lt;/P&gt;&lt;P&gt;Is there any way to avoid this kind of error?&lt;/P&gt;&lt;P&gt;Or do I have to extract the&amp;nbsp;&lt;STRONG&gt;CAN_GetTransferStatus&amp;nbsp;&lt;/STRONG&gt;function to some kind of IRQ and communicate with a flag that the can is not longer busy?&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Christof&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 12:29:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1363923#M12619</guid>
      <dc:creator>christofhaiding</dc:creator>
      <dc:date>2021-10-29T12:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: CAN Receive with FreeRTOS</title>
      <link>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366254#M12644</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Christof,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I didn't see where you defined &lt;STRONG&gt;callback&lt;/STRONG&gt; function for &lt;STRONG&gt;CAN_Receive&lt;/STRONG&gt; by using &lt;STRONG&gt;CAN_InstallEventCallback&lt;/STRONG&gt;.&amp;nbsp;Would you please refer the&amp;nbsp;&lt;STRONG&gt;S32K144_CAN_PAL_SamplePrj_Basic_TxRx_ID_FiltersConfig_SDKRTM3P0&lt;/STRONG&gt; example in&amp;nbsp;&lt;A href="https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-SDK-FlexCAN-sample-projects-to-demonstrate-its-basic-and/ta-p/1172891" target="_self"&gt;S32K1xx SDK FlexCAN sample projects to demonstrate its basic and advanced features&lt;/A&gt;?&lt;BR /&gt;It will show you how to use &lt;STRONG&gt;callback&lt;/STRONG&gt; instead of use &lt;STRONG&gt;CAN_GetTransferStatus&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;BR /&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 03:09:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366254#M12644</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2021-11-04T03:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: CAN Receive with FreeRTOS</title>
      <link>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366469#M12648</link>
      <description>&lt;P&gt;Hi Robin,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't know that i have to use the function&amp;nbsp;&lt;STRONG&gt;CAN_InstallEventCallback&amp;nbsp;&lt;/STRONG&gt;because it was not used at the sample project.&lt;/P&gt;&lt;P&gt;Thx for the tip, i will look into it.&lt;/P&gt;&lt;P&gt;Will come back to you when i have results.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Christof&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 07:17:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366469#M12648</guid>
      <dc:creator>christofhaiding</dc:creator>
      <dc:date>2021-11-04T07:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: CAN Receive with FreeRTOS</title>
      <link>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366703#M12652</link>
      <description>&lt;P&gt;Hi Robin!&lt;/P&gt;&lt;P&gt;I ported the sample code to my freeRTOS project and it works fine.&lt;/P&gt;&lt;P&gt;The key is to only call the&amp;nbsp;&lt;STRONG&gt;CAN_Receive&amp;nbsp;&lt;/STRONG&gt;only once and wait until all data are there.&lt;/P&gt;&lt;P&gt;Thx for the support.&lt;/P&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Christof&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 13:31:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CAN-Receive-with-FreeRTOS/m-p/1366703#M12652</guid>
      <dc:creator>christofhaiding</dc:creator>
      <dc:date>2021-11-04T13:31:12Z</dc:date>
    </item>
  </channel>
</rss>

