<?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>8-bit Microcontrollers中的主题 HC908QY4A PWM initialization with low-level on output</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126037#M888</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I initialized my HC908QY4A with a PWM to let an LED go on and off. That's working fine from 0 to 100%. After a reset the system starts with a dutycycle of 0%. My problem is that during the initialization of the PWM the LED flashes for a short moment. I realized that the PWM-output is set to a high level after the initialization. I think I reach the 0%-duty-cycle after starting the timer and reaching the first Toggle-On-Overflow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So my question is: Is it possible to initialize a PWM whithout getting this short high level out of the port during the initialization?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Soror&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TCH1H = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TCH1L = 0;/* Store values to the duty-compare register */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TSC, 0x10); /* Stop and reset counter */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//Set PWM-Mode with 0% DutyCycle&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;clrReg8Bits(TSC1, 0x03); /* Set conditions of 0 percent duty-cycle */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TSC1, 0x58); /* Set up PWM mode =&amp;gt; SETS OUTPUT TO HIGH LEVEL*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clrReg8Bits(TSC, 0x80); /* Reset request flag and */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8Bits(TSC, 0x40); /* enable interrupt */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TMODH, 0x3F); /* and to the period-modulo register */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TMODL, 0xFF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TSC_PS = 0x00;//Val; /* Store given value to the prescaler */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TSC_TRST = 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clrReg8Bits(TSC, 0x20); /* Timer Start */&lt;/SPAN&gt;&lt;P&gt;Message Edited by Soror on &lt;SPAN class="date_text"&gt;2007-03-13&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;03:12 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Mar 2007 21:11:05 GMT</pubDate>
    <dc:creator>Soror</dc:creator>
    <dc:date>2007-03-13T21:11:05Z</dc:date>
    <item>
      <title>HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126037#M888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I initialized my HC908QY4A with a PWM to let an LED go on and off. That's working fine from 0 to 100%. After a reset the system starts with a dutycycle of 0%. My problem is that during the initialization of the PWM the LED flashes for a short moment. I realized that the PWM-output is set to a high level after the initialization. I think I reach the 0%-duty-cycle after starting the timer and reaching the first Toggle-On-Overflow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So my question is: Is it possible to initialize a PWM whithout getting this short high level out of the port during the initialization?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Soror&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TCH1H = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TCH1L = 0;/* Store values to the duty-compare register */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TSC, 0x10); /* Stop and reset counter */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//Set PWM-Mode with 0% DutyCycle&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;clrReg8Bits(TSC1, 0x03); /* Set conditions of 0 percent duty-cycle */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TSC1, 0x58); /* Set up PWM mode =&amp;gt; SETS OUTPUT TO HIGH LEVEL*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clrReg8Bits(TSC, 0x80); /* Reset request flag and */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8Bits(TSC, 0x40); /* enable interrupt */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TMODH, 0x3F); /* and to the period-modulo register */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setReg8(TMODL, 0xFF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TSC_PS = 0x00;//Val; /* Store given value to the prescaler */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TSC_TRST = 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clrReg8Bits(TSC, 0x20); /* Timer Start */&lt;/SPAN&gt;&lt;P&gt;Message Edited by Soror on &lt;SPAN class="date_text"&gt;2007-03-13&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;03:12 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2007 21:11:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126037#M888</guid>
      <dc:creator>Soror</dc:creator>
      <dc:date>2007-03-13T21:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126038#M889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;To actually&amp;nbsp;achieve a zero percent duty cycle, the toggle-on-overflow bit should remain clear after initialisation of the unbuffered PWM.&amp;nbsp; Only when a non-zero duty cycle is required should this bit be set, and this should occur within&amp;nbsp;output compare ISR code, along with setting the new channel register value.&amp;nbsp; For the HC908 timer, this value should actually be one less than the duty cycle would suggest - for a value of zero, the pulse width would be one timer clock period.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Unless the PWM value is about to change, output compare interrupts should otherwise&amp;nbsp;remain disabled for the channel used.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2007 21:33:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126038#M889</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-03-13T21:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126039#M890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Mac,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for your answer.&lt;BR /&gt;&lt;BR /&gt;In case of a 0% duty-cycle I set the TOV bit to 0 in the ISR and thats working fine. Only during the initialisation of the MCU I get a short flash with a high level.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;clrReg8Bits(TSC1, 0x03); /* Set conditions of 0 percent duty-cycle */&lt;BR /&gt;==&amp;gt; Disable TOV and MAX&lt;BR /&gt;&lt;BR /&gt;setReg8(TSC1, 0x58); /* Set up PWM mode =&amp;gt; SETS OUTPUT TO HIGH LEVEL*/&lt;BR /&gt;==&amp;gt; Setting PWM mode results in a high level on the output althought the TOV bit is disabled. Visible as a short flas.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Soror&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2007 22:04:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126039#M890</guid>
      <dc:creator>Soror</dc:creator>
      <dc:date>2007-03-13T22:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126040#M891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;You mentioned that&lt;BR /&gt;"...only during the initialisation of the MCU I get a short flash with a high level".&lt;BR /&gt;&lt;BR /&gt;If you have enabled the pullup resistor on the PTA1/TCH1 pin previous to the PWM setup routine, then there will be a momentary "high" on that pin until it becomes configured as an output channel.&lt;BR /&gt;&lt;BR /&gt;Frank&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 21:34:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126040#M891</guid>
      <dc:creator>thisobj</dc:creator>
      <dc:date>2007-03-14T21:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126041#M892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Frank,&lt;BR /&gt;&lt;BR /&gt;thanks a lot for your answer. I don't set the pull-ups on the ports. I only activate KBI on ports A2 to A5. But this doesn't set the output A0 and A1 on a high level. Setting the registers TSC0 and TSC1 to 0x58 brings a high level out of the ports A0 and A1.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Soror&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 00:53:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126041#M892</guid>
      <dc:creator>Soror</dc:creator>
      <dc:date>2007-03-15T00:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126042#M893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Soror,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I wonder if your problem might be a question of correct sequencing of the setup of the bits in the TSC1 register.&amp;nbsp; Have a look at AN2701, and see if it might shed some light on the issue.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2007-03-15&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:56 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/app_note/AN2701.pdf" rel="nofollow" target="_self"&gt;AN2701.pdf&lt;/A&gt;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-09-16&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;10:13 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 08:32:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126042#M893</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-03-15T08:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126043#M894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Soror:&lt;BR /&gt;&lt;BR /&gt;Could the "short flash" be occurring before you initialize the PWM?&lt;BR /&gt;&lt;BR /&gt;Before the timer is enabled, the pin is under control of the GPIO port. If the port's data register is set to one, and the port's data-direction register is also set to one, the port pin will drive high until the PWM is enabled and takes control of the pin.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 08:44:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126043#M894</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-03-15T08:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126044#M895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi all,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It seems to me the problem is that the OP is trying to start PWM at a very low % and when it is enabled the pin is starting out high and so stays high until the intended pulse comes along and turns it off. Where in the documentation does it say what the intial output level is?&lt;/DIV&gt;&lt;DIV&gt;I seem to remember having a similar issue myself but can't exactly remember the solution.&lt;/DIV&gt;&lt;DIV&gt;I would try using the Output preset mode (ELSxB:ELSxA = 00) in order to preset the appropriate level before enabling the PWM.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 09:28:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126044#M895</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-03-15T09:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: HC908QY4A PWM initialization with low-level on output</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126045#M896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;hi mac,&lt;BR /&gt;hi rocco,&lt;BR /&gt;hi peg,&lt;BR /&gt;&lt;BR /&gt;thanks a lot for your answers.&lt;BR /&gt;&lt;BR /&gt;@rocco&lt;BR /&gt;I don't set the output or direction registers of the port so I think it should be configured as an input after reset.&lt;BR /&gt;&lt;BR /&gt;@Mac&lt;BR /&gt;I'll also check the AN27012.pdf. I didn't check this paper yet, perhaps this will include the reason for my problem.&lt;BR /&gt;&lt;BR /&gt;@peg&lt;BR /&gt;I tried all configurations of the PWM. Everyone starts with a short flash.&lt;BR /&gt;&lt;BR /&gt;@all&lt;BR /&gt;Unfortunately I am in holidays for a few days. I'll try your solutions after my holidays next week. I'll report my experience shortly. Thanks a lot.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Soror&lt;P&gt;Message Edited by Soror on &lt;SPAN class="date_text"&gt;2007-03-15&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;03:23 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 21:17:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4A-PWM-initialization-with-low-level-on-output/m-p/126045#M896</guid>
      <dc:creator>Soror</dc:creator>
      <dc:date>2007-03-15T21:17:56Z</dc:date>
    </item>
  </channel>
</rss>

