<?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: Can't write to PWM Registers (MC9S08QG8)</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124953#M466</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Peg,&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 realise that the PWM&amp;nbsp;output will not be updated until timer overflow.&amp;nbsp; However, it is less clear to me, should there be more than one write to the register before the output is updated, whether the first word value is latched, or whether the last word value written prior to the overflow will prevail.&amp;nbsp; The "pacing"&amp;nbsp;referred to the update of the register, rather than the update of the output.&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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 04 Mar 2007 14:12:39 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2007-03-04T14:12:39Z</dc:date>
    <item>
      <title>Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124947#M460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi eveyone.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This problem is pretty simple to explain. When I write to either PWM register on the MC9S08QG8 nothing happens the first several times I try. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while (counter less than 100){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TPMC0V++;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;counter++;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the end of 100 loops TPMC0V would be about 10 and my counter would be 100. I can watch this behaviour when I step through the code and it's severely affecting my robot's control system. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;THANKS!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2007 10:50:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124947#M460</guid>
      <dc:creator>Ryanst</dc:creator>
      <dc:date>2007-03-03T10:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124948#M461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Ryanst,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The following quote from the manual may explain your problem:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Times-Roman"&gt;&lt;/FONT&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&lt;EM&gt;Because the HCS08 is a family of 8-bit MCUs, the settings in the timer channel registers are buffered to&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&lt;EM&gt;ensure coherent 16-bit updates and to avoid unexpected PWM pulse widths. Writes to either register,&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&lt;EM&gt;TPMCnVH or TPMCnVL, write to buffer registers. In edge-PWM mode, values are transferred to the&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&lt;EM&gt;corresponding timer channel registers only after both 8-bit bytes of a 16-bit register have been written and&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&lt;EM&gt;the value in the TPMCNTH:TPMCNTL counter is 0x0000. (The new duty cycle does not take effect until&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&lt;EM&gt;the next full period.)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;especially the last sentence "AND the value in the counter is 0"&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times-Roman"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2007 12:02:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124948#M461</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-03-03T12:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124949#M462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;So I should be looking at the counter variable and waiting for it to be zero before I continue my loop then? Right now I'm losing lots of information by writing and having nothing happen.&lt;BR /&gt;&lt;BR /&gt;I'm actually wondering about Codewarrior in general. It seems to blantantly ignore lines of code for no apparent reason. For example:&lt;BR /&gt;&lt;BR /&gt;i = i+1000;&lt;BR /&gt;&lt;BR /&gt;gives me i. I'm not sure why... but i is an integer and equal to zero to start with. Feels like similar behaviour to the PWM registers.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2007 12:30:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124949#M462</guid>
      <dc:creator>Ryanst</dc:creator>
      <dc:date>2007-03-03T12:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124950#M463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Personally, I would wait for the register you just wrote to (through the buffer) was equal to the last value written. This should make it more bullet-proof.&lt;/DIV&gt;&lt;DIV&gt;I don't use CodeWarrior so can't really comment on the second part of your question.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2007 12:44:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124950#M463</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-03-03T12:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124951#M464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&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;There would seem little point in attempting to increment the PWM value before the previous value has taken effect.&amp;nbsp; If you are trying to achieve a ramp output, you would need to pace the PWM&amp;nbsp;increment with the PWM period, i.e.&amp;nbsp;the timer overflow rate.&amp;nbsp; The most efficient way of doing this is to update the next PWM value within the timer overflow ISR (but this would not actually take effect until the next overflow occurred).&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 would suggest not directly incrementing the timer register, but writing the incremented value to the register.&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;e.g. within the timer overflow 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 face="Courier New" size="2"&gt;if&amp;nbsp;(counter &amp;lt; 100) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;counter++;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;TPMC0V = counter;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size="2"&gt;}&lt;BR /&gt;&lt;/FONT&gt;&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>Sun, 04 Mar 2007 13:10:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124951#M464</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-03-04T13:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124952#M465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Mac,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you check the piece I quoted from the manual you will see that the updating is indeed "paced" with the PWM.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2007 13:23:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124952#M465</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-03-04T13:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can't write to PWM Registers (MC9S08QG8)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124953#M466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Peg,&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 realise that the PWM&amp;nbsp;output will not be updated until timer overflow.&amp;nbsp; However, it is less clear to me, should there be more than one write to the register before the output is updated, whether the first word value is latched, or whether the last word value written prior to the overflow will prevail.&amp;nbsp; The "pacing"&amp;nbsp;referred to the update of the register, rather than the update of the output.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2007 14:12:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Can-t-write-to-PWM-Registers-MC9S08QG8/m-p/124953#M466</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-03-04T14:12:39Z</dc:date>
    </item>
  </channel>
</rss>

