<?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 pwm generation using ic MC68HC908JK3E in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155435#M8800</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN style=": ; font-size: 4; font-family: Arial;"&gt;Hi,&lt;BR /&gt;&lt;SPAN style="font-size: 1;"&gt;&amp;nbsp;&lt;SPAN style="font-size: 4;"&gt;am sathya&lt;BR /&gt;i want to generate the pwm, using the &lt;STRONG&gt;MC68HC908JK3E&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;the problem is AS U KNOW der r one timer and two channrels&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;am using CH0 ,i.e PIN NUM 19&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; am using TIMCH0 Interrupt to generate a pwm&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i.e wen compareoccures it cals the interrupt and into the ISR&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WEN I USING EQUAL WIDTH ,I GOT THE PWM OF Equal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;width,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but wen i go for varying pule width ,not able get the varying pwm&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dat means if we give the 8 varying count in the &lt;/SPAN&gt;&lt;STRONG&gt;CH0 Interrupt&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt; corresponding to the pwm width,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;at dat time some values are skipping&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;derfore can u suggest hw to use interrupts to generate the pwm ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;and i am using &lt;/SPAN&gt;&lt;STRONG&gt;codewarrior 5.7.0&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the code is below can u reply ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 May 2008 21:09:18 GMT</pubDate>
    <dc:creator>sathya</dc:creator>
    <dc:date>2008-05-12T21:09:18Z</dc:date>
    <item>
      <title>pwm generation using ic MC68HC908JK3E</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155435#M8800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN style=": ; font-size: 4; font-family: Arial;"&gt;Hi,&lt;BR /&gt;&lt;SPAN style="font-size: 1;"&gt;&amp;nbsp;&lt;SPAN style="font-size: 4;"&gt;am sathya&lt;BR /&gt;i want to generate the pwm, using the &lt;STRONG&gt;MC68HC908JK3E&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;the problem is AS U KNOW der r one timer and two channrels&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;am using CH0 ,i.e PIN NUM 19&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; am using TIMCH0 Interrupt to generate a pwm&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i.e wen compareoccures it cals the interrupt and into the ISR&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WEN I USING EQUAL WIDTH ,I GOT THE PWM OF Equal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;width,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but wen i go for varying pule width ,not able get the varying pwm&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dat means if we give the 8 varying count in the &lt;/SPAN&gt;&lt;STRONG&gt;CH0 Interrupt&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt; corresponding to the pwm width,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;at dat time some values are skipping&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;derfore can u suggest hw to use interrupts to generate the pwm ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;and i am using &lt;/SPAN&gt;&lt;STRONG&gt;codewarrior 5.7.0&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the code is below can u reply ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2008 21:09:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155435#M8800</guid>
      <dc:creator>sathya</dc:creator>
      <dc:date>2008-05-12T21:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: pwm generation using ic MC68HC908JK3E</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155436#M8801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I suggest that you really want to use two different timer channels.&lt;BR /&gt;&lt;BR /&gt;One that is the PWM channel, and one that changes the duty cycle of the PWM channel to generate the desired wave form.&lt;BR /&gt;&lt;BR /&gt;The PWM channel does not need to be serviced by an interrupt. You need need an interrupt to generate a nice wave form, but it's job should be to vary the duty cycle of the PWM channel.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2008 22:30:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155436#M8801</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-05-12T22:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: pwm generation using ic MC68HC908JK3E</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155437#M8802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello Sathya,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Your timer setup for unbuffered PWM on channel 0 appears to be correct, and you are also correct in changing the PWM pulse width within the channel 0 interrupt handler (after the PWM output has gone low).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The issue appears to be that, since you are incrementing the width following each interrupt, there will actually be two interrupts per PWM cycle, the first time after timer overflow has occurred and the output is high (after toggle on overlow), and the second time on the increased channel value,&amp;nbsp;prior to the next timer overflow when the output is still low.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The simplest way to handle this situation would&amp;nbsp;be to test the timer overflow flag, and only if the flag is set, to update the channel value.&amp;nbsp; Perhaps your interrupt handler might be modified as follows -&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;#pragma TRAP_PROC&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;interrupt void TIMCH0_Interrupt(void)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;{&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;TSC0_CH0F = 0;&amp;nbsp; // Clear channel 0 flag&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; if (TSC_TOF) {&amp;nbsp; // Test for overflow flag set&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TSC_TOF = 0;&amp;nbsp;// Clear overflow flag&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TCH0L = sinewave[i];&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i &amp;gt; 7)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 0;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It should be unnecessary to make use of a second timer channel.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 13:22:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/pwm-generation-using-ic-MC68HC908JK3E/m-p/155437#M8802</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-05-13T13:22:25Z</dc:date>
    </item>
  </channel>
</rss>

