<?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のトピックRe: TIM based PWM on HC08GR8</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128378#M1652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Avery:&lt;BR /&gt;&lt;BR /&gt;I did an almost identical project in the mid '80s with the MC68HC05, except I used three 300 watt halogen bulbs and dichroic filters for color. I also had to bit-bang the three PWMs.&lt;BR /&gt;&lt;BR /&gt;I assume you are having problems with the three PWMs? It is tricky with the GR8, since you need to use unbuffered-PWM to get three channels. Are you using a crystal or the PLL? &lt;BR /&gt;&lt;BR /&gt;Here is a rough outline. Much of it will be obvious. Note the difference between the two TIMERS, and the three CHANNELS.&lt;BR /&gt;&lt;BR /&gt;You set the two timers to use the same clock-divider. Enable them at the same time, to have them in sync (they will be at least 3 cycles off, nonetheless). You can use the overflow from one of them to keep track of your milliseconds for the fade-rate.&lt;BR /&gt;&lt;BR /&gt;Set all three channels to unbuffered PWM. You would then update them every cycle. I would do the calculation for the next cycle in the background.&lt;BR /&gt;&lt;BR /&gt;The tricky part is deciding whether to update them on the timer-overflow interrupt, or on the channel interrupt. They both have subtle timing issues, which may not be visible when fading an LED.&lt;BR /&gt;&lt;BR /&gt;Hope that gets you started. Sorry if you were already past this part.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 27 Aug 2006 04:25:42 GMT</pubDate>
    <dc:creator>rocco</dc:creator>
    <dc:date>2006-08-27T04:25:42Z</dc:date>
    <item>
      <title>TIM based PWM on HC08GR8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128377#M1651</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;What I am trying to do is build an LED light fader using the TIM channels for PWM generation. The tricky part is that I want to control the fades/brightens by sending little control packets to the MCU from a PC via SCI (this data communication is not tricky, its the variable nature of the fader).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A sample packet would look like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;L (char, lets the proccesor know i am sending a Lighting instruction)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;255 (desired R level)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;255 (desired G level)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;255 (desired B level)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;011 (Timing High Byte)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;184 (Timing Low Byte) --&amp;gt; Timing together in decimal = 3000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;E (char, ends packet)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So with this packet I am requesting that the MCU raise the levels of 3 LEDs from whatever level they are at (lets say 0 for the example) to 255 (full), and to do it over the course of 3000ms (3s).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having an extraordinary amount of trouble with this, can anyone offer some suggestions? I am coding in C.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Avery&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Aug 2006 15:16:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128377#M1651</guid>
      <dc:creator>AveryZ</dc:creator>
      <dc:date>2006-08-26T15:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: TIM based PWM on HC08GR8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128378#M1652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Avery:&lt;BR /&gt;&lt;BR /&gt;I did an almost identical project in the mid '80s with the MC68HC05, except I used three 300 watt halogen bulbs and dichroic filters for color. I also had to bit-bang the three PWMs.&lt;BR /&gt;&lt;BR /&gt;I assume you are having problems with the three PWMs? It is tricky with the GR8, since you need to use unbuffered-PWM to get three channels. Are you using a crystal or the PLL? &lt;BR /&gt;&lt;BR /&gt;Here is a rough outline. Much of it will be obvious. Note the difference between the two TIMERS, and the three CHANNELS.&lt;BR /&gt;&lt;BR /&gt;You set the two timers to use the same clock-divider. Enable them at the same time, to have them in sync (they will be at least 3 cycles off, nonetheless). You can use the overflow from one of them to keep track of your milliseconds for the fade-rate.&lt;BR /&gt;&lt;BR /&gt;Set all three channels to unbuffered PWM. You would then update them every cycle. I would do the calculation for the next cycle in the background.&lt;BR /&gt;&lt;BR /&gt;The tricky part is deciding whether to update them on the timer-overflow interrupt, or on the channel interrupt. They both have subtle timing issues, which may not be visible when fading an LED.&lt;BR /&gt;&lt;BR /&gt;Hope that gets you started. Sorry if you were already past this part.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Aug 2006 04:25:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128378#M1652</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-08-27T04:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: TIM based PWM on HC08GR8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128379#M1653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Avery,&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 elaborate on Rocco's response, for unbuffered PWM the output frequency would be determined by the setting of the TMOD registers, with a trade-off between resolution and maximum frequency.&amp;nbsp; For your case, the TMOD setting would probably be 0x00FF, assuming a linear relationship between the pulse period and the input level value.&amp;nbsp; The update rate for the colour levels will be determined by the timer overflow 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;To set up the TIM channels, each would need to have its "toggle on overflow" bit set, and would&amp;nbsp;&lt;U&gt;clear&lt;/U&gt; the output on the occurrence of each output compare.&amp;nbsp;&amp;nbsp;You would need to update the output compare value&amp;nbsp;within&amp;nbsp;the TIM&amp;nbsp;channel ISR, ready for the next output compare event in the next PWM cycle.&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;Note that if you require output values of zero and 256 (100 percent duty cycle), these conditions will require special handling within the ISR.&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;A general comment - if you need to control more than one lighting device from the PC, you would need to also allow for a "device address" value in the communications protocol.&amp;nbsp; In this case you might consider a multi-drop RS485 interface for the SCI.&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;BR /&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>Sun, 27 Aug 2006 11:30:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128379#M1653</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-08-27T11:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: TIM based PWM on HC08GR8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128380#M1654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Rocco &amp;amp; Mac,&lt;BR /&gt;&lt;BR /&gt;Thanks for your responses! I am going to integrate your suggestions into my existing code and see whats what! I'll update this post with the progress in a few days (I have to go back up to school now so I won't be able to work on it for 48 hours :-/ )&lt;BR /&gt;&lt;BR /&gt;*I am using a 9.8304mhz crystal&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Avery&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 00:56:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/TIM-based-PWM-on-HC08GR8/m-p/128380#M1654</guid>
      <dc:creator>AveryZ</dc:creator>
      <dc:date>2006-08-28T00:56:04Z</dc:date>
    </item>
  </channel>
</rss>

