<?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のトピックWhy does the S12X COPCTL allow two writes?</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020498#M17028</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this simple C program; add a breakpoint when at the assignment to ARMCOP.&lt;/P&gt;&lt;PRE&gt;void @near main (void) {
    COPCTL=0x40;
    COPCTL=0x43;
    ARMCOP=6;
    while(1) { }
}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;If the software begins from an external reset COPCTL will contain the value 0x43 prior to setting ARMCOP=6.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;However, after the ARMCOP reset, COPCTL will contain the value 0x40, and the assignment to ARMCOP will no longer cause a reset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the datasheet describing the COPCTL fields&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Writing CR[2:0] to “000” has no effect, but counts for the “write once” condition.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I expect when ARMCOP=6; is reached COPCTL would always contain the value 0x40.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specifically tested on an MC9S12XS128 Mask 1M04M. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;While this is a simple example, assigning ARMCOP an invalid value is used by the full software to trigger a reset on demand. COPCTL=0 was placed in an earlier module during development and was mistakenly not removed. causing the second reset request to fail.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Mar 2020 14:40:00 GMT</pubDate>
    <dc:creator>jlever</dc:creator>
    <dc:date>2020-03-12T14:40:00Z</dc:date>
    <item>
      <title>Why does the S12X COPCTL allow two writes?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020498#M17028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this simple C program; add a breakpoint when at the assignment to ARMCOP.&lt;/P&gt;&lt;PRE&gt;void @near main (void) {
    COPCTL=0x40;
    COPCTL=0x43;
    ARMCOP=6;
    while(1) { }
}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;If the software begins from an external reset COPCTL will contain the value 0x43 prior to setting ARMCOP=6.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;However, after the ARMCOP reset, COPCTL will contain the value 0x40, and the assignment to ARMCOP will no longer cause a reset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the datasheet describing the COPCTL fields&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Writing CR[2:0] to “000” has no effect, but counts for the “write once” condition.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I expect when ARMCOP=6; is reached COPCTL would always contain the value 0x40.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specifically tested on an MC9S12XS128 Mask 1M04M. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;While this is a simple example, assigning ARMCOP an invalid value is used by the full software to trigger a reset on demand. COPCTL=0 was placed in an earlier module during development and was mistakenly not removed. causing the second reset request to fail.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2020 14:40:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020498#M17028</guid>
      <dc:creator>jlever</dc:creator>
      <dc:date>2020-03-12T14:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the S12X COPCTL allow two writes?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020499#M17029</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;if you debug the MCU it is clear you are not in normal mode but in the special mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write:&lt;/P&gt;&lt;P&gt;— Anytime in special modes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover, I suggest you to look at &lt;A href="https://community.nxp.com/docs/DOC-103737"&gt;https://community.nxp.com/docs/DOC-103737&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;plus attached example.&lt;/P&gt;&lt;P&gt;&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>Thu, 12 Mar 2020 15:45:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020499#M17029</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2020-03-12T15:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the S12X COPCTL allow two writes?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020500#M17030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, I attempted again using an oscilloscope on PORTA pin 1, and running from power up with the debugger disconnected.&lt;/P&gt;&lt;P&gt;I was able to confirm that COPCTL can only be written to once when the debugger is not connected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;void _at(near) main (void){
&amp;nbsp;&amp;nbsp; unsigned short i,j;
&amp;nbsp;&amp;nbsp; DDRA&amp;nbsp;&amp;nbsp; = 1u &amp;lt;&amp;lt; 1;
&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; /* High-&amp;gt;Low-&amp;gt;High pulse for the oscilloscope */
&amp;nbsp;&amp;nbsp; PORTA&amp;nbsp; = 0xFFu;
&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;1000;i++){ (volatile void)__asm("NOP"); }
&amp;nbsp;&amp;nbsp; PORTA^=0xFFu;
&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;4000;i++){ (volatile void)__asm("NOP"); }
&amp;nbsp;&amp;nbsp; PORTA^=0xFFu;
&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;1000;i++) { (volatile void)__asm("NOP"); }
&amp;nbsp;&amp;nbsp; PORTA^=0xFFu;
&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; COPCTL = 0x40u;
&amp;nbsp;&amp;nbsp; COPCTL = 0x43u;
&amp;nbsp;&amp;nbsp; ARMCOP = 6u;
&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; /* Create 10 edges (5 pulses) */
&amp;nbsp;&amp;nbsp; for(j = 0u; j &amp;lt; 10; j++) 
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;1000;i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (volatile void)__asm("NOP");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTA^=0xFFu;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; /* End with logic 1 */
&amp;nbsp;&amp;nbsp; PORTA=0xFFu;
&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; while(1) {}
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2020 16:49:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Why-does-the-S12X-COPCTL-allow-two-writes/m-p/1020500#M17030</guid>
      <dc:creator>jlever</dc:creator>
      <dc:date>2020-03-12T16:49:09Z</dc:date>
    </item>
  </channel>
</rss>

