<?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: S12Z Output Compare Module Unexpected Behaviour</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561223#M12808</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Radek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried running your code and I have the same issue. I understand that you say the counter does not stop running while in debug mode but the event should still not fire. All the interrupts have been disabled, therefore there should be no overflow event, no compare interrupt or any other interrupt. I therefore do not understand why when I reach the line 22 the pin is set high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14683545258521079 jive_macro_code jive_text_macro" data-renderedposition="164_8_1155_736" jivemacro_uid="_14683545258521079"&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void main(void) {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int i;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRS=0x02;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TC1=0xFFFE;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TSCR1 |= 0x80; //Enable OC module&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TIE = 0x00;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TTOV = 0x00;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG1 = 0xFF;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG2 = 0xFF;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TIOS = 0x02; //Set channel 1 as OC&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x0C; //Set pin output on next OC event&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD &amp;amp;= ~0x02; //Enable the timer channel port for desired action&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; 3; i++){&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm NOP;&amp;nbsp; //Wait&amp;nbsp; - just for waveform alignment&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x04; //Clear pin output on next OC event&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD = 0x00; //Enable the timer channel port for desired action&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;) {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; } /* loop forever */&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; /* please make sure that you never leave main */&amp;nbsp; &lt;/P&gt;&lt;P&gt;}&amp;nbsp; &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;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have run the code with no stepping but rather using the scope as you suggest and I get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="TEK00000.PNG"&gt;&lt;IMG alt="TEK00000.PNG" src="https://community.nxp.com/t5/image/serverpage/image-id/36208iAAA27D2559E62C38/image-size/large?v=v2&amp;amp;px=999" title="TEK00000.PNG" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Whoich is the same as yours and makes sence, however when I let the program run, that is I let it carry on into the infinite for loop I get&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="TEK00003.PNG"&gt;&lt;IMG alt="TEK00003.PNG" src="https://community.nxp.com/t5/image/serverpage/image-id/36209i6634247F6485560D/image-size/large?v=v2&amp;amp;px=999" title="TEK00003.PNG" /&gt;&lt;/SPAN&gt; &lt;SPAN class="lia-inline-image-display-wrapper" image-alt="TEK00004.PNG"&gt;&lt;IMG alt="TEK00004.PNG" src="https://community.nxp.com/t5/image/serverpage/image-id/36315i0FC531FBB51F4B56/image-size/large?v=v2&amp;amp;px=999" title="TEK00004.PNG" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;which considering there are no interrupts, and no request to toggle the pin should not be happening. If you could therefore please explain why I am getting this toggling when there is no code telling the pin to do so and why when I do single stepping I get the change at line 22 when again no event has occurred. I understand that the counter keeps on running but that alone should not be a reason for the pin to change state since there has been no event to cause this change to occur (no interrupt since they are all disabled and no FORC as that line on the code has not yet been reached).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankfully&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:41:11 GMT</pubDate>
    <dc:creator>kaslewis</dc:creator>
    <dc:date>2020-11-02T13:41:11Z</dc:date>
    <item>
      <title>S12Z Output Compare Module Unexpected Behaviour</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561221#M12806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have been working with the S12ZV trying to get the OC to change the state on the output pin when the next interrupt occurs. The issue I have been facing is that instead of the next event causing the effect on the output pin the change happens IMMEDIATELY. I have included my &lt;SPAN style="text-decoration: underline;"&gt;TEST&lt;/SPAN&gt; below.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void output_compare_software_controled(int number_of_pulses, int low_duration, int high_duration){ &amp;nbsp; long i = 0; &amp;nbsp; int j = 0;&amp;nbsp;&amp;nbsp; &amp;nbsp; TIM0TSCR1 |= 0x80; //Enable OC module&amp;nbsp; &amp;nbsp; TIM0TIE = 0x00; &amp;nbsp; TIM0TTOV = 0x00; &amp;nbsp; TIM0TFLG1 = 0xFF; &amp;nbsp; TIM0TFLG2 = 0xFF;&amp;nbsp; &amp;nbsp; TIM0TIOS = 0x02; //Set channel 1 as OC &amp;nbsp; TIM0TCTL2 = 0x0C; //Set pin output on next OC event &amp;nbsp; TIM0OCPD &amp;amp;= ~0x02; //Enable the timer channel port for desired action &amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp;&amp;nbsp; &amp;nbsp; for(j = 0; j &amp;lt; number_of_pulses; j++){ &amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; high_duration; i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Wait&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//*********** &amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS2 = 0;//*********** &amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x08; //Clear pin output on next OC event &amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD = 0x00; //Enable the timer channel port for desired action &amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; PTP_PTP7 = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; low_duration; i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Wait&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//*********** &amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS2 = 1;//*********** &amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x0C; //Set pin output on next OC event &amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD = 0x00; //Enable the timer channel port for desired action &amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp; &amp;nbsp; } }&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that this is NOT interrupt driven but the behaviour is the same. When the code reaches line 14, 24 or 33 the state of the pin changes immediately. What should happen is that the state should only change when the code reaches line 16, 26 or 35 when the force register is set indicating that the change should happen. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have similar code running that initializes the code in a function and sets the compare register to a set value but again the change happens when reaching TCTL2 and not when the next interrupt occurs. Any help in resolving this issue would be very much appreciated.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2016 19:05:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561221#M12806</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2016-07-11T19:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: S12Z Output Compare Module Unexpected Behaviour</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561222#M12807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kas,&lt;/P&gt;&lt;P&gt;I am afraid that something missing there or that is a just misunderstanding.&lt;/P&gt;&lt;P&gt;I tested it on my TRK-S12ZVL board and everything works fine on my side.&lt;/P&gt;&lt;P&gt;I used a slightly simplified code with PS1 GPIO pin toggling for my reference.&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14683312642027443 jive_text_macro" data-renderedposition="138_8_1192_608" jivemacro_uid="_14683312642027443" modifiedtitle="true"&gt;&lt;P&gt;void main(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRS=0x02;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TC1=0xFFFE; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TSCR1 |= 0x80; //Enable OC module&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TIE = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TTOV = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG1 = 0xFF;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG2 = 0xFF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TIOS = 0x02; //Set channel 1 as OC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x0C; //Set pin output on next OC event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD &amp;amp;= ~0x02; //Enable the timer channel port for desired action&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; 3; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm NOP;&amp;nbsp; //Wait&amp;nbsp; - just for waveform alignment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x04; //Clear pin output on next OC event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD = 0x00; //Enable the timer channel port for desired action&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; } /* loop forever */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* please make sure that you never leave main */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;Result waveform:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="SNC01143-1.jpg"&gt;&lt;IMG alt="SNC01143-1.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/37432i176B89D807764A64/image-size/large?v=v2&amp;amp;px=999" title="SNC01143-1.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Could you please specify your MCU derivative?&lt;/P&gt;&lt;P&gt;What is your TIM0TC1 value?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How did you detect that “the output pin change happens IMMEDIATELY”?&lt;/P&gt;&lt;P&gt;I suppose that you just debugging code step by step. Please be aware that TCNT is free running counter and it is not stopped during debugging. So, when you set TIM0TCTL2, the next OC event may happen very early – depends on TIM0TC1, TIM0TCNT and prescaler values. In my case after approximately 10ms (6.25MHz, prescaler=1 =&amp;gt; OC event every 0.0104856 second).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:41:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561222#M12807</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2020-11-02T13:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: S12Z Output Compare Module Unexpected Behaviour</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561223#M12808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Radek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried running your code and I have the same issue. I understand that you say the counter does not stop running while in debug mode but the event should still not fire. All the interrupts have been disabled, therefore there should be no overflow event, no compare interrupt or any other interrupt. I therefore do not understand why when I reach the line 22 the pin is set high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14683545258521079 jive_macro_code jive_text_macro" data-renderedposition="164_8_1155_736" jivemacro_uid="_14683545258521079"&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void main(void) {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int i;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRS=0x02;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TC1=0xFFFE;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TSCR1 |= 0x80; //Enable OC module&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TIE = 0x00;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TTOV = 0x00;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG1 = 0xFF;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG2 = 0xFF;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TIOS = 0x02; //Set channel 1 as OC&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x0C; //Set pin output on next OC event&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD &amp;amp;= ~0x02; //Enable the timer channel port for desired action&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; 3; i++){&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm NOP;&amp;nbsp; //Wait&amp;nbsp; - just for waveform alignment&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TCTL2 = 0x04; //Clear pin output on next OC event&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0OCPD = 0x00; //Enable the timer channel port for desired action&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 0;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0CFORC = 0x02; //Force OC action on specified channel&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS1 = 1;//***********&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;) {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; } /* loop forever */&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; /* please make sure that you never leave main */&amp;nbsp; &lt;/P&gt;&lt;P&gt;}&amp;nbsp; &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;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have run the code with no stepping but rather using the scope as you suggest and I get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="TEK00000.PNG"&gt;&lt;IMG alt="TEK00000.PNG" src="https://community.nxp.com/t5/image/serverpage/image-id/36208iAAA27D2559E62C38/image-size/large?v=v2&amp;amp;px=999" title="TEK00000.PNG" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Whoich is the same as yours and makes sence, however when I let the program run, that is I let it carry on into the infinite for loop I get&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="TEK00003.PNG"&gt;&lt;IMG alt="TEK00003.PNG" src="https://community.nxp.com/t5/image/serverpage/image-id/36209i6634247F6485560D/image-size/large?v=v2&amp;amp;px=999" title="TEK00003.PNG" /&gt;&lt;/SPAN&gt; &lt;SPAN class="lia-inline-image-display-wrapper" image-alt="TEK00004.PNG"&gt;&lt;IMG alt="TEK00004.PNG" src="https://community.nxp.com/t5/image/serverpage/image-id/36315i0FC531FBB51F4B56/image-size/large?v=v2&amp;amp;px=999" title="TEK00004.PNG" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;which considering there are no interrupts, and no request to toggle the pin should not be happening. If you could therefore please explain why I am getting this toggling when there is no code telling the pin to do so and why when I do single stepping I get the change at line 22 when again no event has occurred. I understand that the counter keeps on running but that alone should not be a reason for the pin to change state since there has been no event to cause this change to occur (no interrupt since they are all disabled and no FORC as that line on the code has not yet been reached).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankfully&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:41:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561223#M12808</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2020-11-02T13:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: S12Z Output Compare Module Unexpected Behaviour</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561224#M12809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact, the PT1 is set to high at line 26.&lt;/P&gt;&lt;P&gt;The first widest low pulse refers to TIM0TC1, TIM0TSCR1, TIM0TIE, TIM0TTOV, TIM0TFLG1 and TIM0TFLG2 registers settings.&lt;/P&gt;&lt;P&gt;The second low pulse refers to TIM0TCTL2 = 0x0C; command.&lt;/P&gt;&lt;P&gt;The third low pulse refers to TIM0CFORC = 0x02;.&lt;/P&gt;&lt;P&gt;After that, there is the wide high pulse which refers to for loop.&lt;/P&gt;&lt;P&gt;The fourth low pulse refers to TIM0TCTL2 = 0x04; command.&lt;/P&gt;&lt;P&gt;The fifth low pulse refers to TIM0CFORC = 0x02;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am really sorry. I made a mistake and I copy here code with additional change. I just tested my period calculation and I forget to change the code back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please look at line 32. The command “TIM0TCTL2 = 0x04;” configured TIM channel 1 to toggling mode – but I didn’t change the comment.&lt;/P&gt;&lt;P&gt;So, timer toggle with PT1 during every positive comparing TIM0TCNT counter value with TIM0TC1 register = every 65535 bus clock cycles.&lt;/P&gt;&lt;P&gt;You used command TIM0TCTL2 = 0x08; in your original code for to “Clear pin output on next OC event”.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached are three simple S12Z TIM example codes for your reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2016 13:19:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561224#M12809</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2016-07-13T13:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: S12Z Output Compare Module Unexpected Behaviour</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561225#M12810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Radek, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After going over the code again I know understand the confusion. I did not realize that TIM0CTL2 = 0x04; (that it should toggle) and therefore on every compare match with the timer the pin would continue to toggle. I was looking to have it set to 0x08 or 0x0C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also now understand that the timer does not stop during debug mode which added a bit of confusion during debugging. Thank you for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely &lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2016 14:55:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-Output-Compare-Module-Unexpected-Behaviour/m-p/561225#M12810</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2016-07-13T14:55:50Z</dc:date>
    </item>
  </channel>
</rss>

