<?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>Processor Expert SoftwareのトピックRe: about function EnterCritical</title>
    <link>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262121#M1633</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we confirm the problem. Unfortunately, these macros are not safe for use within the interrupt routines. We are working to fix this for the next version of CodeWarrior (10.6) and DriverSuite (10.4). A workaround is to use plain DisableInt/EnableInt CPU component methods if possible or use workaround described by Erich Styger (see previous post). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Petr Hradsky&lt;/P&gt;&lt;P&gt;Processor Expert Support Team&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jan 2014 10:11:46 GMT</pubDate>
    <dc:creator>Petr_H</dc:creator>
    <dc:date>2014-01-30T10:11:46Z</dc:date>
    <item>
      <title>about function EnterCritical</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262117#M1629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have used Processor Expert Software 10.0.0 and IAR.&lt;/P&gt;&lt;P&gt;And&amp;nbsp; Processor Expert Software generate the code:&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;/* Save status register and disable interrupts */&lt;/P&gt;&lt;P&gt;#define EnterCritical() \&lt;/P&gt;&lt;P&gt; do {\&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (++SR_lock == 1u) { \&lt;/P&gt;&lt;P&gt;&amp;nbsp; SR_reg = (uint8_t)__get_PRIMASK(); \&lt;/P&gt;&lt;P&gt;&amp;nbsp; __set_PRIMASK(0x01ul); \&lt;/P&gt;&lt;P&gt;&amp;nbsp; } \&lt;/P&gt;&lt;P&gt; } while(0)&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am afraid that it may have some leak.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;when main task run EnterCritical() to change some important thing .&lt;/P&gt;&lt;P&gt;If it run over&amp;nbsp; ++SR_lock and do not run&amp;nbsp; SR_lock == 1u,&lt;/P&gt;&lt;P&gt;then an interrupt occurs and run&amp;nbsp; EnterCritical() to change some important thing too.&lt;/P&gt;&lt;P&gt;Then the interrupt can not run&amp;nbsp; __set_PRIMASK(0x01ul) because&amp;nbsp; now SR_lock is 2.&lt;/P&gt;&lt;P&gt;When the interrupt run the important code, a high priority interrupt may occurs and&amp;nbsp; run&amp;nbsp; EnterCritical() to change some important thing too.&lt;/P&gt;&lt;P&gt;Then change of the important thing&amp;nbsp; may be conflict.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2013 05:32:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262117#M1629</guid>
      <dc:creator>hgyxbll</dc:creator>
      <dc:date>2013-04-11T05:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: about function EnterCritical</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262118#M1630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If SR_lock &amp;gt;= 1 then interrupts are disabled, so no interrupt will run.&lt;/P&gt;&lt;P&gt;It may be that you do not need to do &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; EnterCritical()&lt;/SPAN&gt; in the interrupt handler, since the interrupt can not happen while in a critical section.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2013 16:29:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262118#M1630</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2013-04-11T16:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: about function EnterCritical</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262119#M1631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;gt;If SR_lock &amp;gt;= 1 then interrupts are disabled&lt;/P&gt;&lt;P&gt;When&amp;nbsp; SR_lock =1, the interrupt may not disable.&lt;/P&gt;&lt;P&gt;Only after run "__set_PRIMASK(0x01ul)", the&amp;nbsp; interrupt are disabled.&lt;/P&gt;&lt;P&gt;so the order:&lt;/P&gt;&lt;P&gt;++SR_lock;&lt;/P&gt;&lt;P&gt;if(SR_lock == 1u)&amp;nbsp;&amp;nbsp; ---&amp;gt;&amp;nbsp; then may be broke by interrupt&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; SR_reg = (uint8_t)__get_PRIMASK();&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; __set_PRIMASK(0x01ul);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; It may be that you do not need to do EnterCritical() in the interrupt handler, since the interrupt can not happen while in a critical section.&lt;/P&gt;&lt;P&gt;Interrupt may be broke by a high priority interrupt.&lt;/P&gt;&lt;P&gt;So in the interrupt handler should&amp;nbsp; do EnterCritical() to avoid broke by&amp;nbsp; a high priority interrupt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 02:28:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262119#M1631</guid>
      <dc:creator>hgyxbll</dc:creator>
      <dc:date>2013-04-12T02:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: about function EnterCritical</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262120#M1632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem outlined by hgyxb II is real :-(&lt;/P&gt;&lt;P&gt;&lt;A href="http://mcuoneclipse.com/2014/01/26/entercritical-and-exitcritical-why-things-are-failing-badly/" title="http://mcuoneclipse.com/2014/01/26/entercritical-and-exitcritical-why-things-are-failing-badly/"&gt;EnterCritical() and ExitCritical(): Why Things are Failing Badly | MCU on Eclipse&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I was running into that problem myself. Above post has a fixed implementation of the Enter/ExitCritical() macros.&lt;/P&gt;&lt;P&gt;I'm able to get my program failing with the current macros, while at least with the new macros things are running stable.&lt;/P&gt;&lt;P&gt;Will need more testing, but I'm confident that I have found a solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Jan 2014 14:46:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262120#M1632</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-01-26T14:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: about function EnterCritical</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262121#M1633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we confirm the problem. Unfortunately, these macros are not safe for use within the interrupt routines. We are working to fix this for the next version of CodeWarrior (10.6) and DriverSuite (10.4). A workaround is to use plain DisableInt/EnableInt CPU component methods if possible or use workaround described by Erich Styger (see previous post). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Petr Hradsky&lt;/P&gt;&lt;P&gt;Processor Expert Support Team&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 10:11:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/about-function-EnterCritical/m-p/262121#M1633</guid>
      <dc:creator>Petr_H</dc:creator>
      <dc:date>2014-01-30T10:11:46Z</dc:date>
    </item>
  </channel>
</rss>

