<?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 Configure Timer as output - s12zvl in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Configure-Timer-as-output-s12zvl/m-p/735282#M14927</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, i'm trying to use the timer0-channel3 as output in one of the supported pins PT3 (i just want to be sure that the timing configuration is correct).&amp;nbsp;&lt;BR /&gt;The port configuration seems ok but the maximum frequency that i can get from the output is 100 Hz even though the frequency of the bus is 6.25MHz (measured using the ECLK signal).&lt;BR /&gt;It looks like the issue comes from the configuration of the 16 bit counter register, my main question is how to configure the 16 bit comparator in order to achieve an output of 6.25 MHz?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code snippet:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;void TIM_Init(void)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TIOS = 0x3F; /*0B0011 1111 - Select all channels as Output Compare*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;TIM0TCTL1 = 0x05; /*0b0000 0101 - Toggle OC5/4 Output Line*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TCTL2 = 0x55; /*0b0101 0101 - Toggle OC3/2/1/0 Output Line */&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TIE = 0x08; /*0b0000 0100 - Interrupt Enabled Ch3*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TSCR2 = 0x00; /*0b0000 0000 - TimerOverflow@b7:off Prescaler=Clk/1*/ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0OCPD = 0x37; /*0b0011 1011 - Enable OutputCompare Ch3*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TC3H = 0xFF;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TC3L = 0xF0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TSCR1 = 0x80; /*0b1000 1000 - TimerEnabled with Legacy prescaler */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0CFORC = 0x08; /*0b0000 1000*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;}&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;MODRR2_T0C3RR=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Mar 2018 00:28:14 GMT</pubDate>
    <dc:creator>alexishernandez</dc:creator>
    <dc:date>2018-03-07T00:28:14Z</dc:date>
    <item>
      <title>Configure Timer as output - s12zvl</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Configure-Timer-as-output-s12zvl/m-p/735282#M14927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, i'm trying to use the timer0-channel3 as output in one of the supported pins PT3 (i just want to be sure that the timing configuration is correct).&amp;nbsp;&lt;BR /&gt;The port configuration seems ok but the maximum frequency that i can get from the output is 100 Hz even though the frequency of the bus is 6.25MHz (measured using the ECLK signal).&lt;BR /&gt;It looks like the issue comes from the configuration of the 16 bit counter register, my main question is how to configure the 16 bit comparator in order to achieve an output of 6.25 MHz?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code snippet:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;void TIM_Init(void)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TIOS = 0x3F; /*0B0011 1111 - Select all channels as Output Compare*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;TIM0TCTL1 = 0x05; /*0b0000 0101 - Toggle OC5/4 Output Line*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TCTL2 = 0x55; /*0b0101 0101 - Toggle OC3/2/1/0 Output Line */&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TIE = 0x08; /*0b0000 0100 - Interrupt Enabled Ch3*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TSCR2 = 0x00; /*0b0000 0000 - TimerOverflow@b7:off Prescaler=Clk/1*/ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0OCPD = 0x37; /*0b0011 1011 - Enable OutputCompare Ch3*/&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TC3H = 0xFF;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TC3L = 0xF0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0TSCR1 = 0x80; /*0b1000 1000 - TimerEnabled with Legacy prescaler */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TIM0CFORC = 0x08; /*0b0000 1000*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;}&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 13px;"&gt;MODRR2_T0C3RR=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2018 00:28:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Configure-Timer-as-output-s12zvl/m-p/735282#M14927</guid>
      <dc:creator>alexishernandez</dc:creator>
      <dc:date>2018-03-07T00:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Configure Timer as output - s12zvl</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Configure-Timer-as-output-s12zvl/m-p/735283#M14928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alexis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The timer counter is 16-bit. TCNT counter is free running from 0x0000 to 0xFFFF. When TCNT counter reach TCx values, the OC channels generate events. For periodic event generation, you can set the interval.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example generate output frequency. The shorter the interval, the higher the frequency.&lt;/P&gt;&lt;P&gt;See interrupt function, the value of the interval (ECT_PERIOD) is added to the counter value.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: green; background: white;"&gt;//==============================================================================&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: green; background: white;"&gt;// Input Capture Interrupt&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: green; background: white;"&gt;//==============================================================================&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: black; background: white;"&gt;interrupt VectorNumber_Vtim0ch0 &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; color: blue; background: white;"&gt;void&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; color: black; background: white;"&gt; IC0_ISR()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: black; background: white;"&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: 9.5pt; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTS_PTS0 = ~PTS_PTS0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; color: green; background: white;"&gt;//toggle PS0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TC0 = TIM0TC0+ECT_PERIOD;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; color: green; background: white;"&gt;//the next event update&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIM0TFLG1 = 0x01;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; color: green; background: white;"&gt;//clear the flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; color: black; background: white;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;In the init function is needed to enable interrupts and set the TCx value: &amp;nbsp;TIM0TC0 = ECT_PERIOD;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whole example under the name ZVML128-TIM-500usPeriod-CW105.zip and discussion on this theme you can find on this site:&amp;nbsp;&lt;A href="https://community.nxp.com/message/860977"&gt;https://community.nxp.com/message/860977&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2018 15:06:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Configure-Timer-as-output-s12zvl/m-p/735283#M14928</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2018-03-12T15:06:50Z</dc:date>
    </item>
  </channel>
</rss>

