<?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: Re: QE8 TPMxMOD update in TOF ISR?</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248566#M19782</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ian, are you actually waiting enough clock counts? Remember you have a preescaler of 8, with a modulo of 3332 you basically have to wait up to 3332 * 8 = 26656 bus clock cycles for the value to be latched. It might actually be easier if you write a while loop with an if inside that compares the new and old Modulo value and enter once it's different, put a breakpoint inside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lastly, notice that the BDM driver does not necessarily update variables and register. Make sure that either you've configured it for automatic periodic updates or click on refresh once you've stopped the code running.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Sep 2013 17:24:38 GMT</pubDate>
    <dc:creator>eduardo_viramon</dc:creator>
    <dc:date>2013-09-25T17:24:38Z</dc:date>
    <item>
      <title>QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248561#M19777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am refering to design reference DRM093.PDF which uses an AW60 and have shown only the code of interest below:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;void TIMER1_TOF_ISR(void) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte dummy_read;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ModifyFreq){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TPM1MOD = ColorTMOD[Freq];&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;---------------- defined as a word array&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; dummy_read = TPM1SC;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; TPM1SC_TOF =0; // clear TOF flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created the same interrupt with the following init code for an QE8:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;TPM1C2V = 0x0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;TPM1MOD = 33333 - 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;TPM1C2SC = 0x3C; // edge PWM&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;TPM1SC = 0x4B; // Prescaler 8, bus clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if with ModifyFreq set and ColorTMOD[Freq] containing a 16 bit value, say 5000 decimal, TPM1MOD doesn't update with the new value. I have tried writing it as two 8 bit values, high then low but TPM1MOD still doesn't update.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any ideas please?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much in advance,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 13:40:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248561#M19777</guid>
      <dc:creator>iansmusical</dc:creator>
      <dc:date>2013-09-24T13:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248562#M19778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QE8 has TPMv3 (as opposed to TPMv2 in AW60) a critical difference in these two versions is a latching mechanism added to the modulo and channel value registers. When they are written, the value is actually latched in a buffer and later updated to the actual register when the timer counter reaches the last count. This mechanism is there to prevent glitches in PWM duty cycle or frequency updates, in other words, the value will in fact become updated, on the next period. More info in the reference manual:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture.PNG.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/40822i5429B543EF89566C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG.png" alt="Capture.PNG.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also notice that you can override this latching mechanism by temporarily turning off the timer clock CLKSB and A = 0, updating and turning them back on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 15:24:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248562#M19778</guid>
      <dc:creator>eduardo_viramon</dc:creator>
      <dc:date>2013-09-24T15:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248563#M19779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eduardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your answer. I had noticed about v2 and v3 but didn't realise the differences were the latching mechanism. I had also read section 16.3.3 a few times and felt that as I'm using the bus clock, CLKSB (0) and CLKSA (1) would therefore be not cleared and thus the update would naturally occur via the latching mechanism when the counter changes from max - 1 to max. This I haven't seen occur or is it additionally necessary to write to TPMxSC or temporarily turn off the timer clock, as you suggested to defeat the latching mechanism?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 19:58:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248563#M19779</guid>
      <dc:creator>iansmusical</dc:creator>
      <dc:date>2013-09-24T19:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248564#M19780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you verifying that the module value is written? Are you reading back the register or through a measurement of the output frequency?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are reading, are you reading with the BDM active (in other words, are you debugging at the same time?), the parargraph just below the screenshot I posted before explains that in BDM active mode, the latch is frozen, so if you are reading with BDM, you would read back the first value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also noticed that your initialization includes writing a zero to the channel value, this would mean that your output stays on all the time (as you have low-true pulses), you would have no way of determining frequency through&amp;nbsp; the oscilloscope. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 22:04:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248564#M19780</guid>
      <dc:creator>eduardo_viramon</dc:creator>
      <dc:date>2013-09-24T22:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Re: QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248565#M19781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eduardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly let me add some detail. I'm using the DEMOQE board and although the channel value is initially zero it actually is set in the TOF interrupt via a 12 bit ADC value. I realise the ADC value doesn't span the full 16 bit timer range but I'm just experimenting at the moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am verifying that the TPMxMOD value is written via the BDM and understand that the latch is frozen while the BDM is active. However, having let the code run for a few periods after and having paused execution to look at the TPMxMOD register, it still shows the old value and therefore isn't automatically updating. I of course could apply the procedures that you mentioned in the last reply for testing purposes but the automatic update should occur according to 16.3.3?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached my experimental project for your reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your continued help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 11:53:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248565#M19781</guid>
      <dc:creator>iansmusical</dc:creator>
      <dc:date>2013-09-25T11:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Re: QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248566#M19782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ian, are you actually waiting enough clock counts? Remember you have a preescaler of 8, with a modulo of 3332 you basically have to wait up to 3332 * 8 = 26656 bus clock cycles for the value to be latched. It might actually be easier if you write a while loop with an if inside that compares the new and old Modulo value and enter once it's different, put a breakpoint inside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lastly, notice that the BDM driver does not necessarily update variables and register. Make sure that either you've configured it for automatic periodic updates or click on refresh once you've stopped the code running.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 17:24:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248566#M19782</guid>
      <dc:creator>eduardo_viramon</dc:creator>
      <dc:date>2013-09-25T17:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: QE8 TPMxMOD update in TOF ISR?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248567#M19783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eduardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies for my delay in replying to you. I believe I was waiting enough bus clock cycles based on letting the code run for several seconds before breaking and viewing the registers. I will try as you suggest of using a while loop etc and making sure I force an update of the registers. At the moment though the method of stopping the bus clock to the TPM module that you suggested, changing the MOD value and then re-enabling the bus clock has sufficed for my testing needs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all your support,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2013 14:04:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/QE8-TPMxMOD-update-in-TOF-ISR/m-p/248567#M19783</guid>
      <dc:creator>iansmusical</dc:creator>
      <dc:date>2013-10-08T14:04:14Z</dc:date>
    </item>
  </channel>
</rss>

