<?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>S12 / MagniV MicrocontrollersのトピックProblem with Timer Count</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163125#M5207</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody... I've got this strange problem. I'm working with CW4.6 and MC9S12A256.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using two timer channels &amp;nbsp;(CH0 and CH7). CH0 for output compare; and CH7 for Input Capture that only interrupts when a falling edge occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Output Compare is ALWAYS running and interupting every 1mseg, When that occurs, I toggle a pin (an output).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With an oscilloscope I view the Input Capture pin and the pin that I toggle each time an output compare ocurrs.&lt;/P&gt;&lt;P&gt;Normally, I see this on the oscilloscope.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH0 Output Compare&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH7 Input Capture&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp; &amp;nbsp;+--+ +-+ &amp;nbsp;+-+ &amp;nbsp; &amp;nbsp; +--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +----+ &amp;nbsp;+-+ +--+ +-----+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;The input capture channel is not important... The important thing is that the Output Compare has always the same high and low time, equal to 1mseg.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;The problem is that sometimes, the following happens. (only when working with input capture, if I disable it the problem doesn't show)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH0 Output Compare&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp;+--+ &amp;nbsp;+-----------------+ &amp;nbsp;+--+ &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +--+ &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;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH7 Input Capture&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp; &amp;nbsp;+--+ +-+ &amp;nbsp;+-+ &amp;nbsp; &amp;nbsp; +--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +----+ &amp;nbsp;+-+ +--+ +-----+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's difficult to me to explain what I think is happening with words, so I'll put it graphically&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+---------------------------------------&amp;gt; (1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp;+------------------------------------&amp;gt; (2)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp;|&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+------------------------&amp;gt; (3)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp;|&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;+---------------------&amp;gt; (4)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &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';"&gt;--+ &amp;nbsp;+--+ &amp;nbsp;+--|-----------|--+ &amp;nbsp;+--+ &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +--+ &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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;(1)&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;Let's assume that here the TCNT = 0x0000&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;(2) &amp;nbsp;&lt;SPAN&gt;Here the IRQ should happend but it didn't&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&lt;SPAN&gt;(3) &amp;nbsp;&lt;SPAN&gt;Here ocurrs an OVF (&lt;/SPAN&gt;&lt;SPAN&gt;TCNT from 0xFFFF to 0)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;(4) &amp;nbsp;&lt;SPAN&gt;Here the TCNT reaches the ch0_REG value&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;Why's that happening??&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;The code in the Output Compare only does this:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;TC0 += 12000;&amp;nbsp;&amp;nbsp; // IRQ every 1msegtoggled_pin = ~toggled_pin; // Toggle pinTFLG1_C0F = 1;// Clear flag&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And in the Input Capture, I only clear the IRQ flag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!!!&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: normal; font-family: ''courier new', courier';"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: normal; font-family: ''courier new', courier';"&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:09:13 GMT</pubDate>
    <dc:creator>sebasira</dc:creator>
    <dc:date>2020-10-29T09:09:13Z</dc:date>
    <item>
      <title>Problem with Timer Count</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163125#M5207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody... I've got this strange problem. I'm working with CW4.6 and MC9S12A256.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using two timer channels &amp;nbsp;(CH0 and CH7). CH0 for output compare; and CH7 for Input Capture that only interrupts when a falling edge occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Output Compare is ALWAYS running and interupting every 1mseg, When that occurs, I toggle a pin (an output).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With an oscilloscope I view the Input Capture pin and the pin that I toggle each time an output compare ocurrs.&lt;/P&gt;&lt;P&gt;Normally, I see this on the oscilloscope.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH0 Output Compare&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH7 Input Capture&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp; &amp;nbsp;+--+ +-+ &amp;nbsp;+-+ &amp;nbsp; &amp;nbsp; +--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +----+ &amp;nbsp;+-+ +--+ +-----+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;The input capture channel is not important... The important thing is that the Output Compare has always the same high and low time, equal to 1mseg.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;The problem is that sometimes, the following happens. (only when working with input capture, if I disable it the problem doesn't show)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH0 Output Compare&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp;+--+ &amp;nbsp;+-----------------+ &amp;nbsp;+--+ &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +--+ &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;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;CH7 Input Capture&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;--+ &amp;nbsp; &amp;nbsp;+--+ +-+ &amp;nbsp;+-+ &amp;nbsp; &amp;nbsp; +--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp; &amp;nbsp;| &amp;nbsp;| | | &amp;nbsp;| | &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +----+ &amp;nbsp;+-+ +--+ +-----+ &amp;nbsp;+--+ &amp;nbsp;+--+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's difficult to me to explain what I think is happening with words, so I'll put it graphically&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+---------------------------------------&amp;gt; (1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp;+------------------------------------&amp;gt; (2)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp;|&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+------------------------&amp;gt; (3)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp;|&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;+---------------------&amp;gt; (4)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &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';"&gt;--+ &amp;nbsp;+--+ &amp;nbsp;+--|-----------|--+ &amp;nbsp;+--+ &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;| &amp;nbsp;| &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; +--+ &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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;(1)&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;Let's assume that here the TCNT = 0x0000&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;(2) &amp;nbsp;&lt;SPAN&gt;Here the IRQ should happend but it didn't&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&lt;SPAN&gt;(3) &amp;nbsp;&lt;SPAN&gt;Here ocurrs an OVF (&lt;/SPAN&gt;&lt;SPAN&gt;TCNT from 0xFFFF to 0)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;(4) &amp;nbsp;&lt;SPAN&gt;Here the TCNT reaches the ch0_REG value&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;Why's that happening??&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;The code in the Output Compare only does this:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;TC0 += 12000;&amp;nbsp;&amp;nbsp; // IRQ every 1msegtoggled_pin = ~toggled_pin; // Toggle pinTFLG1_C0F = 1;// Clear flag&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And in the Input Capture, I only clear the IRQ flag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!!!&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: normal; font-family: ''courier new', courier';"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: normal; font-family: ''courier new', courier';"&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:09:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163125#M5207</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2020-10-29T09:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Timer Count</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163126#M5208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've manage to solve the problem... But maybe someone can explain me a bit more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was using BSET to clear interrupt flags. I've read that this instructions it's a read and write instruction, and clearing should be done with a write-only instruction. And that was causing the "missed" interrupt, if the two IRQ ocurrs simultaneously, then when clearing one, I was clearing both.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 23:59:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163126#M5208</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-05-14T23:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Timer Count</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163127#M5209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arghhhh. It was explained zilion of times what you can and what you can't do with flags registers, which contain more than one flag clearable writing one to flag. Using BSET , TFLG1_C0F = 1 and TFLG1 |= TFLG1_C0F_MASK will clear ALL TFLG1 flags, since bits you "are not using in expression" are PRESERVED = OVERWRITTEN with their old value. What happens when unused bit is ONE? Right, ONE is written back to flag, which is set, and you clear them ALL. You can use read modify write without problems:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BCLR TFLG1,#~TFLG1_C0F_MASK;&lt;/P&gt;&lt;P&gt;TFLG1 &amp;amp;= TFLG1_C0F_MASK; // Notice no '~' on the right side&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and of course write only&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TFLG1 = TFLG1_C0F_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can't use TFLG1_C0F = 0 or TFLG1_C0F = 1. Both are bad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 10:53:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163127#M5209</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-05-15T10:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Timer Count</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163128#M5210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks kef!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it was explained a lot, but it always confused me. The reason of my confusion is that no one ever explain it to me like you did. They always talk about read-write instructions, and write-only... What I didn't know is why a BSET was a read-write. Now I know!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 18:32:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-Timer-Count/m-p/163128#M5210</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-05-15T18:32:11Z</dc:date>
    </item>
  </channel>
</rss>

