<?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>S12 / MagniV Microcontrollers中的主题 Re: CAN messages missing</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364325#M10652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to use HW semaphore in your case (where both cores write to the same variable). In multiCPU application++ and -- are not atomic operations. Even though S12X CPU can do ++ or -- using single CPU instruction, this instruction involves 1) reading variable to CPU, 2) calculating new value of variable, and 3) writing new calculated value back to vatiable. XGATE core may read or write the same variable at any stage. Without semaphore it easily may look like some ++ or -- are not executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the same reason you need to use HW semaphore even toggling bits in the same peripheral register, even if both cores are toggling different bits of the same register.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Mar 2015 07:24:56 GMT</pubDate>
    <dc:creator>kef2</dc:creator>
    <dc:date>2015-03-09T07:24:56Z</dc:date>
    <item>
      <title>CAN messages missing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364324#M10651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have seen an implementation of the CAN driver on the Xgate and the processing on the s12x using the following code. The goal of the project is to do processing on some msgs and direct to other channels some other messages.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Xgate core&lt;/P&gt;&lt;P&gt;void __interrupt XGATE_CAN_RECEIVE(XGCANstruct * channel)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; release[msg_index]=1;&lt;/P&gt;&lt;P&gt; // do some processing&lt;/P&gt;&lt;P&gt;&amp;nbsp; rxmsg[msg_index].msgID = rxid; &lt;/P&gt;&lt;P&gt;&amp;nbsp; release[msg_index] =0;&lt;/P&gt;&lt;P&gt; msg_index++;&lt;/P&gt;&lt;P&gt; if(msg_index == 10)&lt;/P&gt;&lt;P&gt;&amp;nbsp; msg_index=0;&lt;/P&gt;&lt;P&gt;-sif();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;In the s12x core&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;void __interrupt CAN1_rxnotificationisr(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; XGATE.xgif_50 = BIT9;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;while(1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;// some logic here&lt;/P&gt;&lt;P&gt; can_rx();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void can_rx(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; for(index=0; index&amp;lt;=msg_index; index++)&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; while(release[index] == 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; // do the processing some big logic here&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;msg_index=0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i had serious doubts about the above implementation and modified as shown below.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Xgate core&lt;/P&gt;&lt;P&gt;void __interrupt XGATE_CAN_RECEIVE(XGCANstruct * channel)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; // do some processing&lt;/P&gt;&lt;P&gt; rxmsg[l_canrxcounter_u8].msgID = rxid; &lt;/P&gt;&lt;P&gt;-sif();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S12x core &lt;/P&gt;&lt;P&gt;void __interrupt CAN1_rxnotificationisr(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; l_canrxcounter_u8++;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;and in the main file&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; while(1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; // some big logic here&lt;/P&gt;&lt;P&gt;&amp;nbsp; can_rx();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void can_rx(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(l_canrxcounter_u8 &amp;gt; 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do the message processing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rxmsg[l_canrxcounter_u8-1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l_canrxcounter_u8--;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do processing on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have written the variable l_canrxcounter_u8 as the shared variable between the two cores without semaphores. Please help me if it is correct and do i need to implement using semaphores. How should i ensure that i am not missing any messages, because in the first implementation i saw that a lot of messages are received but not all by passed to other channels, some messages are missing and also not immediately after the message received it is happening after some messages.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;Channel1: msg1 rxed &lt;/P&gt;&lt;P&gt;channel1:msg2 rxed&lt;/P&gt;&lt;P&gt;channel2: msg1 txed&lt;/P&gt;&lt;P&gt;channel1:msg3 rxed&lt;/P&gt;&lt;P&gt;channel1: msg4 rxed&lt;/P&gt;&lt;P&gt;channel2: msg2 txed.&lt;/P&gt;&lt;P&gt;after that the sequence is completely missing. Please help me.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 08:36:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364324#M10651</guid>
      <dc:creator>rahulkrishna</dc:creator>
      <dc:date>2015-03-06T08:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: CAN messages missing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364325#M10652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to use HW semaphore in your case (where both cores write to the same variable). In multiCPU application++ and -- are not atomic operations. Even though S12X CPU can do ++ or -- using single CPU instruction, this instruction involves 1) reading variable to CPU, 2) calculating new value of variable, and 3) writing new calculated value back to vatiable. XGATE core may read or write the same variable at any stage. Without semaphore it easily may look like some ++ or -- are not executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the same reason you need to use HW semaphore even toggling bits in the same peripheral register, even if both cores are toggling different bits of the same register.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 07:24:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364325#M10652</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2015-03-09T07:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: CAN messages missing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364326#M10653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i would like to provide you some examples I made for CAN at S12XE device. I usually do not use semaphores because of approach to example, however, if it is necessary then PIT example presents how to do it.&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Ladislav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 11:18:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364326#M10653</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2015-03-09T11:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: CAN messages missing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364327#M10654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much i will go through the code. If i have any clarifications in the code can you help me out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 12:38:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/CAN-messages-missing/m-p/364327#M10654</guid>
      <dc:creator>rahulkrishna</dc:creator>
      <dc:date>2015-03-10T12:38:33Z</dc:date>
    </item>
  </channel>
</rss>

