<?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>topic Re: Input Capture and Output Compare By using S12ZVML31 in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818243#M15875</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,lama&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; I understand the method.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Aug 2018 01:26:32 GMT</pubDate>
    <dc:creator>frankkong</dc:creator>
    <dc:date>2018-08-14T01:26:32Z</dc:date>
    <item>
      <title>Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818238#M15870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@&lt;A _jive_internal="true" data-content-finding="Community" data-userid="227361" data-username="Alice_Yang" href="https://community.nxp.com/people/Alice_Yang" style="color: #3d9ce7; background-color: #ffffff; border: 0px; font-weight: 200; text-decoration: none; font-size: 1.286rem;"&gt;Alice_Yang&lt;/A&gt;&lt;SPAN style="color: #3d9ce7; background-color: #ffffff; font-weight: 500;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I,m using s12zvml31 for capture square wave's frequency and duty。Simultaneously, &lt;SPAN style="background-color: #f5f5f5; color: #222222;"&gt;output square wave with the same frequency and specific duty(5% for example). The input frequency is between 10Hz and 1000Hz.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f5f5f5; color: #222222;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S12zvml31 only have a Timer0 and my main interrupt cycle is 100us, what can I do to solve this problem?&amp;nbsp; The main iterrupt cycle has the highest priority.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f5f5f5; color: #222222;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;My timer's frequency is 625K now.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2018 02:30:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818238#M15870</guid>
      <dc:creator>frankkong</dc:creator>
      <dc:date>2018-08-03T02:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818239#M15871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Fast thinking for left aligned incoming pulses…using my old code (for another MCU) for frequency measurement adding additional code. Timer channel 1 is set for both edges interrupt and main timer is set for overflows. The code is just presenting approach. Probably it is correct, I am sorry topically can't see mistake....it requires some time for thinking....I know.....&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|___________|^^^^^^^^^^^^^^^^^ &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; incomming signal&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Irising edge&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |falling edge&amp;nbsp;&amp;nbsp; |rising edge&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;|&amp;lt;---------period or duty or Globalperiod_1---------------&amp;gt;|&amp;lt;----period---&amp;gt;|&amp;lt;----period-----&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;|&amp;lt;-----------------------------------------Globalperiod-----------&amp;gt;|&amp;lt;---------------------Globalperiod-----&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;// Count overflows&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;//*********************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;#pragma CODE_SEG NON_BANKED&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;interrupt XX void ECT_OvfIsr(void)&amp;nbsp; // count overflows &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; ch1ovfCnt++;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // count overflows&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; if(ch1ovfCnt&amp;gt;MAX_OVERFLOWS) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; { &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ch1ovfCnt = 0; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FREQUENCY_TOO_LOW = TRUE; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCI0_SendValue();&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; // send message to the PC&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; else&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; { FREQUENCY_TOO_LOW = FALSE; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; ECT_TFLG2 = 0B10000000;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear interrupt flag of main timer&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;#pragma CODE_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;//*********************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;//Service interrupt for rising and falling edge&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;// calculate topical length of the finished level and length/globalperiod of invcoming signal:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;//*********************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;#pragma CODE_SEG NON_BANKED&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;interrupt XX void ECT_Ch1Isr(void)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; unsigned int ovfs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;//------&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; timerNewValue = ECT_TC1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // read new captured value and clear flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; ovfs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ch1ovfCnt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // save amount of ovfs to temporary variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; ch1ovfCnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear number of overflows&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; ECT_TFLG1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0B00000010;&amp;nbsp;&amp;nbsp; // clear interrupt flag from PT1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&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;&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;&amp;nbsp; //-----&amp;nbsp; Ch1 period calculation, calculate lengt of currently finished level of incoming signal --------- &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; if(!ovfs)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Did edges appear within one timer period?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; period = (ULONG)(timerNewValue - timerOldValue); // per. of given level&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; else&amp;nbsp; // some number of overflows has appeared between two edges&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // time given by overflows period=....&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; period = (ULONG)( ~timerOldValue+1 ); // time in the first period&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; period+= (ULONG)(&amp;nbsp; timerNewValue);&amp;nbsp;&amp;nbsp;&amp;nbsp; // time in the last&amp;nbsp; period&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; period+= (ULONG)((ULONG)((ovfs-1)) * (ULONG)(65536)); &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; timerOldValue = timerNewValue; // prepare new old value&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;//-------------&amp;nbsp; calculate period and duty of incomming signal&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; if(rising edge)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Globalperiod = Globalperiod_1 + period;&amp;nbsp; // period of incoming signal&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data_prepared = TRUE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // now you have entire period and duty cycle of the Globalperiod which&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // has now gone. This value you can use for PWM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp; else&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Globalperiod_1 = period; // also it is duty of a new Globalperiod&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;#pragma CODE_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Note; if you set prescaler of main timer to be sure there is only one overflow between rising and falling edge then formulas and code could be simplified. This is general approach for pulse of long&amp;nbsp; length with maximum lengt of MAX_OVERFLOWS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Ladislav&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2018 12:36:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818239#M15871</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2018-08-07T12:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818240#M15872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, lama.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;It does't work. Because the max frequency of Timer1 is 50M, the overflow time is 65535/50M = 1.31ms .It's too long for checking&amp;nbsp; square wave with 1K Hz frequency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;any other ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2018 02:51:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818240#M15872</guid>
      <dc:creator>frankkong</dc:creator>
      <dc:date>2018-08-08T02:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818241#M15873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;entire code is attached, minimum measured frequency is defined only maximum number of overflows.&lt;/P&gt;&lt;P&gt;It worked, however, I have not seen it for, really will not lie, for years.&lt;/P&gt;&lt;P&gt;Yes, it is for different MCU but principle....&lt;/P&gt;&lt;P&gt;The code only measures frequency without measuring duty cycle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;a) The first idea of measuring both pulse parts was described previously.&lt;/LI&gt;&lt;LI&gt;b) Probably I can add that the type of edge can be also investigated by interrupt flag, without enabling interrupt, at two independent pins connected also to input signal.&lt;/LI&gt;&lt;LI&gt;c) The issue you have is to make a compromise for maximum precision of the 1000Hz frequency and amount of overflows for 10Hz frequency from timer prescaler point of view.&lt;/LI&gt;&lt;LI&gt;d) You should perform your own analysis a decide for timer setup as presented in the example, file main.c:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Detailed Description:&lt;/P&gt;&lt;P&gt;*&amp;nbsp;&amp;nbsp; - It mesure frequency at PT1 by means of ECT module.&lt;BR /&gt; *&amp;nbsp;&amp;nbsp; - The measaurement is sensitive on rising edges so duty cycle has no affect&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to the measurement&lt;BR /&gt; *&amp;nbsp;&amp;nbsp; - Constants:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BUSCLOCK&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAX_OVERFLOWS&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIMER_PRESCALLER&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; must be defined&lt;BR /&gt; *&amp;nbsp;&amp;nbsp; - MAX_OVERFLOWS determines minimum mesurable frequency.&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It is max. allowed number of overflows. When overflows counter reaches &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this value it the flag FREQUENCY_TOO_LOW is set. The message &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PERIOD BETWEEN TWO EDGES IS TO WIDE is then sent sent to the PC through &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCI0. This value gives time interval:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T = TIMER_PRESCALER * MAX_OVERFLOWS * 65536 / BUSCLOCK&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For example:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - TIMER_PRESCALER = 1&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - MAX_OVERFLOWS&amp;nbsp;&amp;nbsp; = 1000&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - BUSCLOCK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 8000000Hz&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T = 1 * 1000 * 65536 / 8000000 = 8,192s&amp;nbsp; =&amp;gt; f=0.122Hz&lt;BR /&gt; *&amp;nbsp;&amp;nbsp; - TIMER_PRESCALER = { 1,2,4,8,16,32,64,128} - smaller values give more&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; precise values but it generates timer overflow more frequently&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... for example....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/47527i17ABFFEAEBD640D0/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) The issue I see is duty cycle measurement for small a large duty cycles in the first method. Because of this I would try to solve second method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) Another possibility and approach is to connect input signal to two different timer inputs and calculate period from rising edges from one channel including duty provided by interrupt on different channel for falling edge. However, it also requires study and tests.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; margin-bottom: .0001pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;incomming signal&amp;nbsp; &amp;nbsp;&amp;nbsp; |^^^^^^^^^^^^^^^|_____________________________________________|^^^^^^^^^^^^^^^|____ &lt;BR /&gt; ICx (rising edges) &amp;nbsp; &amp;nbsp; |&amp;lt;----period measured by ICx, P= f(TCx_old, TCx_new,ovfs)-------------&amp;gt;|&amp;lt;----period-----&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;ICy (falling edges)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |- event which stores TCy and num. of ovfs to be able to calc. duty&amp;nbsp;&amp;nbsp;&amp;nbsp; |- again&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;4) Your task is really not simple and will require a lot of test and modifications. Probably there is also much simpler solution but not going to my mind now.&lt;/P&gt;&lt;P&gt;Best regrads,&lt;/P&gt;&lt;P&gt;Ladislav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 07:55:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818241#M15873</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2018-08-09T07:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818242#M15874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also not absolutely sure what is the status of the code, I have really forgotten. It is longer time I was working on it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 08:10:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818242#M15874</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2018-08-09T08:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818243#M15875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,lama&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; I understand the method.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2018 01:26:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818243#M15875</guid>
      <dc:creator>frankkong</dc:creator>
      <dc:date>2018-08-14T01:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818244#M15876</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 was thinking about your task and I am not sure whether you need the value of the incoming signal. If yes then OK but if you do not need it then I think easier solution is monostable flip flop circuit to generate the same frequency with the given constant duty. It looks to be easier and faster solution. Moreover it removes issues with higher range of measured frequencies considering timer prescaler setup and SW (calculation) issues...and it removes issues with creating outgoing signal.&lt;/P&gt;&lt;P&gt;For this purpose, if I decide to use MCU for solution, I would use S12XE MCU with integrated XGATE and use the XGATE (Risc core integrated on the chip and connected also to a CPU)&amp;nbsp; as a parallel processor (interrupt driven) for processes which I do not want to influence CPU. Wery good especially in the case of processing signals and fast direct responses while CPU calculates more complicated tasks.&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>Wed, 15 Aug 2018 05:37:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818244#M15876</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2018-08-15T05:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818245#M15877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, lama&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I use the LIN as the input signal and I can't change the MCU.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2018 01:59:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818245#M15877</guid>
      <dc:creator>frankkong</dc:creator>
      <dc:date>2018-08-20T01:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Input Capture and Output Compare By using S12ZVML31</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818246#M15878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,lama&lt;/P&gt;&lt;P&gt;I have a idea for this problem. I use the interrupt of Timer0 IOC0 and IOC3. IOC3 is for input capture and IOC0 for output compare. The timer base frequency is 200K. If I add the compare value at IOC0 interrupt , then I can generate a 10us interrupt. I will deal with the output compare using the period interrupt(10us)&amp;nbsp; for 10hz~1000Hz. The problem is when I set the different priority it will meet some problem. If I set the same priority it works well. You can see the problem below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/63233i7F057952ED7911C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_4.png" alt="pastedImage_4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/63214iF9A9D6FB4E57B436/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I want to set the priority of IOC0 is higher than IOC3, what can I do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2018 10:00:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Input-Capture-and-Output-Compare-By-using-S12ZVML31/m-p/818246#M15878</guid>
      <dc:creator>frankkong</dc:creator>
      <dc:date>2018-08-20T10:00:11Z</dc:date>
    </item>
  </channel>
</rss>

