<?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: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1850626#M34403</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;refer to SDK demo code, it shows how to config and use MB for receiving.&lt;BR /&gt;If you want to receive all IDs into single MB then clear respective mask acceptance register.&lt;/P&gt;
&lt;P&gt;below is possible code, but using FlexCAN driver&lt;/P&gt;
&lt;DIV&gt;#define RX_MAILBOX 0UL&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */&lt;/DIV&gt;
&lt;DIV&gt;FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX, &amp;amp;dataInfo, RX_MSG_ID);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;/* Start receiving data in RX_MAILBOX. */&lt;/DIV&gt;
&lt;DIV&gt;FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &amp;amp;recvBuff);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;while(1)&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLEXCAN_DRV_SendBlocking(INST_FLEXCAN_CONFIG_1, TX_MAILBOX, &amp;amp;dataInfo, TX_MSG_ID,&amp;nbsp; data, 1000 );&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX) == STATUS_SUCCESS);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// process received data&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Start receiving data in RX_MAILBOX again */&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &amp;amp;recvBuff);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;BR, Petr&lt;/DIV&gt;</description>
    <pubDate>Fri, 19 Apr 2024 10:56:38 GMT</pubDate>
    <dc:creator>PetrS</dc:creator>
    <dc:date>2024-04-19T10:56:38Z</dc:date>
    <item>
      <title>S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1847014#M34205</link>
      <description>&lt;P&gt;Good afternoon everyone, i am looking for a little help on what must be a pretty basic issue.&lt;/P&gt;&lt;P&gt;I am running the CAN PAL sample project and can send a receive messages but when i try to modify the main.c to package the data from an array using a for loop, it flashes to the device successfully but when i hit debug, i get the below in the console and the debug stops automatically.&lt;/P&gt;&lt;P&gt;UsageFault:An Unaligned access error has occurred&lt;/P&gt;&lt;P&gt;HardFault: A fault has been escalated to a hard fault&lt;/P&gt;&lt;P&gt;All i have added is a manual method for packaging data bytes into the transmit buffer but im having to do it in 8 separate commands, ive added a simple for loop but that kills the program. Im very used to using the Arduino IDE and this is my attempt to move forward with a more professional platform so any help would be great&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;Rich&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(*(uint32_t *)&amp;amp;CAN_TX_Buffer.id = 0x600);// sets the CAN ID to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unsigned char data2[8] = {7, 6, 5, 4, 3, 2, 1, 0};// Sets the data to send into a character array&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;for(int t=0; t&amp;lt;7; t++){&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[t] = data2[t]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[0] = data2[0]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[1] = data2[1]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[2] = data2[2]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[3] = data2[3]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[4] = data2[4]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[5] = data2[5]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[6] = data2[6]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;//(*(uint64_t *)&amp;amp;CAN_TX_Buffer.data[7] = data2[7]);/* increase the data, [2] is the byte of data in the 8 byte message to update */&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;CAN_Send(&amp;amp;can_pal1_instance, TX_MB, &amp;amp;CAN_TX_Buffer);// Sends the CAN message using non blocking type&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 09:40:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1847014#M34205</guid>
      <dc:creator>RML_SPARKY</dc:creator>
      <dc:date>2024-04-15T09:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1847786#M34241</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;it should be enough to use&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;unsigned char data2[8] = {7, 6, 5, 4, 3, 2, 1, 0};// Sets the data to send into a character array&lt;BR /&gt;&lt;/SPAN&gt;for(int t=0; t&amp;lt;7; t++){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;CAN_TX_Buffer.data[t] = data2[t]);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;}&lt;BR /&gt;&lt;BR /&gt;BR, Petr&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 06:46:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1847786#M34241</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2024-04-16T06:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1849142#M34320</link>
      <description>&lt;P&gt;Hi Petr, this fixed my issue, thank you very much.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 15:19:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1849142#M34320</guid>
      <dc:creator>RML_SPARKY</dc:creator>
      <dc:date>2024-04-17T15:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1849812#M34349</link>
      <description>&lt;P&gt;&lt;U&gt;Hi Petr,&amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;I have simplified my code for the CAN message send now but i am struggling to achieve a similar function with receiving CAN messages, i effectively want to receive in all messages and then check the ID and assign the data to a character array depending on the ID.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;I have tried a couple of options and looked through the different CAN examples but im not able to access the CAN ID variable. I am not using flex CAN just standard CAN 11 bit ID's .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to set up a CAN receive instance, set up the message buffer and then do something different based on the IS of the message that comes through.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a bit like&lt;/P&gt;&lt;P&gt;CAN_RECEIVE (SETUP)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;What is this command???&lt;/P&gt;&lt;P&gt;CAN_RECEIVE (MESSAGE)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;What is this command??&lt;/P&gt;&lt;P&gt;if (CAN_RECEIVE.ID == 0x800){&amp;nbsp; &amp;nbsp; &amp;nbsp;what is this command??&lt;/P&gt;&lt;P&gt;for (j=0;j,7;j++){&lt;/P&gt;&lt;P&gt;char message1[j] = CAN_RECEIVE.data[j]&amp;nbsp; &amp;nbsp;What is this command???&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else if&amp;nbsp;(CAN_RECEIVE.ID == 0x700){&lt;/P&gt;&lt;P&gt;for (j=0;j,7;j++){&lt;/P&gt;&lt;P&gt;char message2[j] = CAN_RECEIVE.data[j]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you able to point me in the right direction please?&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;Rich&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 10:04:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1849812#M34349</guid>
      <dc:creator>RML_SPARKY</dc:creator>
      <dc:date>2024-04-18T10:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1850626#M34403</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;refer to SDK demo code, it shows how to config and use MB for receiving.&lt;BR /&gt;If you want to receive all IDs into single MB then clear respective mask acceptance register.&lt;/P&gt;
&lt;P&gt;below is possible code, but using FlexCAN driver&lt;/P&gt;
&lt;DIV&gt;#define RX_MAILBOX 0UL&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */&lt;/DIV&gt;
&lt;DIV&gt;FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX, &amp;amp;dataInfo, RX_MSG_ID);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;/* Start receiving data in RX_MAILBOX. */&lt;/DIV&gt;
&lt;DIV&gt;FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &amp;amp;recvBuff);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;while(1)&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLEXCAN_DRV_SendBlocking(INST_FLEXCAN_CONFIG_1, TX_MAILBOX, &amp;amp;dataInfo, TX_MSG_ID,&amp;nbsp; data, 1000 );&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX) == STATUS_SUCCESS);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// process received data&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Start receiving data in RX_MAILBOX again */&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &amp;amp;recvBuff);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;BR, Petr&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Apr 2024 10:56:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1850626#M34403</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2024-04-19T10:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1850681#M34405</link>
      <description>&lt;P&gt;HI Petr,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you advise which SDK CAN example i should use with the code you have provided please?&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;Rich&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 12:21:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1850681#M34405</guid>
      <dc:creator>RML_SPARKY</dc:creator>
      <dc:date>2024-04-19T12:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 CAN PAL Sample Project Basic issue with a for loop to package the date into the buffer</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1853188#M34579</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can refer to flexcan_encrypted_s32k demo&lt;/P&gt;&lt;P&gt;BR, Petr&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 07:10:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-CAN-PAL-Sample-Project-Basic-issue-with-a-for-loop-to/m-p/1853188#M34579</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2024-04-24T07:10:15Z</dc:date>
    </item>
  </channel>
</rss>

