<?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: S12G128 How to use Timer TC0 with PTT0 as GPIO</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797975#M15685</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response, for this case, I already solve the problem with disconnect the OCPD channel 0.&lt;/P&gt;&lt;P&gt;I put&amp;nbsp;&amp;nbsp;OCPD_OCPD0=1; on my Timer_Init.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; appreciate your response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lukman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Sep 2018 08:55:56 GMT</pubDate>
    <dc:creator>lukmankurniawan</dc:creator>
    <dc:date>2018-09-12T08:55:56Z</dc:date>
    <item>
      <title>S12G128 How to use Timer TC0 with PTT0 as GPIO</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797973#M15683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Currently I use S12G128 MCU 48pins and using TC0 in timer interrupt to set the period of pulse.&amp;nbsp;In the same time I also use PTT0 as GPIO pin for PUSH Button Input because I will use the other pins for another purpose . But The PTT0 GPIO pins looks got affected by the TC0, how to avoid PTT0 get affected by TC0?&lt;BR /&gt;My code is as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* common defines and macros */&lt;BR /&gt;#include "derivative.h" /* derivative-specific definitions */&lt;/P&gt;&lt;P&gt;#define PERIOD 750&lt;/P&gt;&lt;P&gt;#define UP_1&amp;nbsp; &amp;nbsp; PTT_PTT0&amp;nbsp; &amp;nbsp;//button up1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;#define DOWN_1&amp;nbsp; &amp;nbsp; PTT_PTT1&amp;nbsp; &amp;nbsp;//button down1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;long time_count;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//==============================================================================&lt;BR /&gt;//SetPEEmodeBUSCLK&lt;BR /&gt;//==============================================================================&lt;BR /&gt;void SetPEEmodeBUSCLK(byte _synr, byte _refdv, byte _postdiv)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;CPMUSYNR = _synr;&lt;BR /&gt; CPMUREFDIV = _refdv;&lt;BR /&gt; CPMUPOSTDIV = _postdiv;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; CPMUOSC_OSCE = 1; //enable external oscillator OSCE&lt;BR /&gt; &lt;BR /&gt; while(!CPMUFLG_UPOSC)&lt;BR /&gt; {// you can check for timeot here with error message report&lt;BR /&gt; }; &lt;BR /&gt; while(!CPMUFLG_LOCK)&lt;BR /&gt; {// you can check for timeot here with error message report&lt;BR /&gt; }; &lt;BR /&gt; &lt;BR /&gt; //--- select clocks --------------------&lt;BR /&gt; CPMUCLKS = 0B10000011; // bus=fPLL/2; COP is clocked from OSCCLK&lt;BR /&gt; if(CPMUCLKS != 0B10000011) // After writing CPMUCLKS register, it is strongly recommended to read &lt;BR /&gt; { // back CPMUCLKS register to make sure that write of PLLSEL,&lt;BR /&gt; asm nop; // RTIOSCSEL, COPOSCSEL0 and COPOSCSEL1 was successful.&lt;BR /&gt; }&lt;BR /&gt; //--------------------------------------&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//==============================================================================&lt;BR /&gt;//TC0_ISR&lt;BR /&gt;//==============================================================================&lt;BR /&gt;#pragma CODE_SEG NON_BANKED&lt;BR /&gt;interrupt 8 void TC0_ISR(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;PTP_PTP4 = ~PTP_PTP4; //toggle PTP4&lt;BR /&gt; PORTD_PD0 = ~PORTD_PD0; //toggle PTD0&lt;BR /&gt; time_count++;&lt;BR /&gt; TC0 = TC0 + PERIOD; &lt;BR /&gt; TFLG1=0x01;&lt;BR /&gt; &lt;BR /&gt;}&lt;BR /&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//==============================================================================&lt;BR /&gt;//Timer_Init&lt;BR /&gt;//==============================================================================&lt;BR /&gt;void Timer_Init(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIOS = 0x01; //channel 0 as output compare&lt;BR /&gt; TIE = 0x01; //interrupt enable &lt;BR /&gt; TSCR2 = 0x03; //prescaler =&amp;nbsp;8&lt;BR /&gt;TC0 = PERIOD;&lt;BR /&gt; TSCR1 = 0xA0; //timer enabled&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void main(void) {&lt;BR /&gt; /* put your own code here */&lt;BR /&gt; &lt;BR /&gt; ECLKCTL_NECLK = 1; // enable ECLK output (bus clock is visible on pin PB0 for TWR-S12G128)&lt;BR /&gt; SetPEEmodeBUSCLK(0x02, 0x80, 0x00); //24Mhz BUSCLK from 8 MHZ oscclk, PEE mode &lt;BR /&gt; DDRD = 0x0F; //LEDs output &lt;BR /&gt; DDRP = 0x0F; //LEDs output&lt;/P&gt;&lt;P&gt;DDRT=0x00; Port T as Input&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PTP_PTP1=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PTP_PTP2=0;&lt;/SPAN&gt;&lt;BR /&gt; Timer_Init();&lt;BR /&gt; &lt;BR /&gt; EnableInterrupts;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; for(;;) &lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;_FEED_COP(); &lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp;if&amp;nbsp;(&lt;SPAN&gt;UP&lt;/SPAN&gt;&lt;SPAN&gt;_1==0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;{&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;PTP_PTP1=0;&lt;/SPAN&gt;}&lt;BR /&gt; &amp;nbsp; &amp;nbsp;else {&amp;nbsp;&lt;SPAN&gt;PTP_PTP1=1;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;if&amp;nbsp;(&lt;SPAN&gt;DOWN&lt;/SPAN&gt;&lt;SPAN&gt;_1==0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;{&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;PTP_PTP2=0;&lt;/SPAN&gt;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else {&amp;nbsp;&lt;SPAN&gt;PTP_PTP2=1;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;} &lt;BR /&gt; &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lukman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2018 08:42:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797973#M15683</guid>
      <dc:creator>lukmankurniawan</dc:creator>
      <dc:date>2018-09-06T08:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: S12G128 How to use Timer TC0 with PTT0 as GPIO</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797974#M15684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;Have your tried reading PTIT (Port T Input Register) instead of PTT (Port T Data Register)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2018 14:10:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797974#M15684</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2018-09-11T14:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: S12G128 How to use Timer TC0 with PTT0 as GPIO</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797975#M15685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response, for this case, I already solve the problem with disconnect the OCPD channel 0.&lt;/P&gt;&lt;P&gt;I put&amp;nbsp;&amp;nbsp;OCPD_OCPD0=1; on my Timer_Init.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; appreciate your response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lukman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 08:55:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12G128-How-to-use-Timer-TC0-with-PTT0-as-GPIO/m-p/797975#M15685</guid>
      <dc:creator>lukmankurniawan</dc:creator>
      <dc:date>2018-09-12T08:55:56Z</dc:date>
    </item>
  </channel>
</rss>

