<?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>8-bit MicrocontrollersのトピックRe: CCR Interrupt Mask Bit in C?</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209627#M17909</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;As the CCR is stacked you could use a method similar to that proposed &lt;A href="http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;message.id=10101" target="_blank"&gt;here.&lt;/A&gt;&lt;BR /&gt;Or you could add a little assembly like this:&lt;BR /&gt;&lt;BR /&gt;PSHA&lt;BR /&gt;TPA&lt;BR /&gt;STA variable&lt;BR /&gt;PULA&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Apr 2008 17:56:09 GMT</pubDate>
    <dc:creator>peg</dc:creator>
    <dc:date>2008-04-04T17:56:09Z</dc:date>
    <item>
      <title>CCR Interrupt Mask Bit in C?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209626#M17908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;How can I move CCR to my local variable in C?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have to test I bit:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;void foo()&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; unsigned char before = CCR_I &amp;lt;---&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; DisableInterrupts;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; ....&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; ....&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; if(before) EnableInterrupts;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;10x&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by BasePointer on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-04-04&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:39 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Apr 2008 16:39:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209626#M17908</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2008-04-04T16:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: CCR Interrupt Mask Bit in C?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209627#M17909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;As the CCR is stacked you could use a method similar to that proposed &lt;A href="http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;message.id=10101" target="_blank"&gt;here.&lt;/A&gt;&lt;BR /&gt;Or you could add a little assembly like this:&lt;BR /&gt;&lt;BR /&gt;PSHA&lt;BR /&gt;TPA&lt;BR /&gt;STA variable&lt;BR /&gt;PULA&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Apr 2008 17:56:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209627#M17909</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2008-04-04T17:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: CCR Interrupt Mask Bit in C?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209628#M17910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;Hi BP,&lt;BR /&gt;&lt;BR /&gt;Try the __isflag_int_enabled() function. It returns true if I = 0.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;void foo()&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; unsigned char before;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; before = __isflag_int_enabled();&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; DisableInterrupts;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; ....&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; ....&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; if(before) EnableInterrupts;&lt;/DIV&gt;&lt;DIV&gt;}&lt;BR /&gt;&lt;BR /&gt;Ps.: this is in my new book &lt;SPAN&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;/DIV&gt;&lt;SPAN class="time_text"&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by fabio on &lt;SPAN class="date_text"&gt;2008-04-04&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;12:03 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Apr 2008 17:59:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209628#M17910</guid>
      <dc:creator>fabio</dc:creator>
      <dc:date>2008-04-04T17:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: CCR Interrupt Mask Bit in C?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209629#M17911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi fabio,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The code below works for me.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include "&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;intrinsics_hc08.h&lt;/FONT&gt;&lt;/STRONG&gt;"void foo(void){  unsigned char before = &lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;__isflag_int_enabled&lt;/FONT&gt;&lt;/STRONG&gt;();    DisableInterrupts; /* disable interrupts */  ..  ...  if(before) EnableInterrupts; /* enable interrupts */  }&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Thank you so much.&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Apr 2008 18:39:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209629#M17911</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2008-04-04T18:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: CCR Interrupt Mask Bit in C?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209630#M17912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a query regarding Z bit in CCR. When the following is performed,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a= 10&lt;/P&gt;&lt;P&gt;b=10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (a==b), then Z flag should be set to TRUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However as soon as the instruction is executed the Z flag is cleared, when any other statements in the code is executed. There are no decision statements which is executed after this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I am from a testing background, I expect Z flag to be set to TRUE, until next comparison is performed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me out on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dharani &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2012 10:03:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209630#M17912</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2012-12-19T10:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: CCR Interrupt Mask Bit in C?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209631#M17913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello Dharani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you examine the reference manual for the device you are using, you should observe that a large proportion of the assembly instructions will affect the status of the Z-flag, not just the compare instructions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would seem to have two choices within your C code -&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Do the comparison each time a branch decision is required.&lt;/LI&gt;&lt;LI&gt;Assign the comparison result to a variable, and then test the value within the variable for each decision.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the latter method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;byte a, b, c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;c = (a == b);&amp;nbsp; // Result is true or false&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if (c)&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; // Do something&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2012 12:05:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/CCR-Interrupt-Mask-Bit-in-C/m-p/209631#M17913</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-12-19T12:05:56Z</dc:date>
    </item>
  </channel>
</rss>

