<?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 Re: S08 Capture Mode and Timer Queries. in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Capture-Mode-and-Timer-Queries/m-p/436700#M21540</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi pawan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would do is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first error I see is that you must write the module TPM1MOD in order TPM1MODH then TPM1MODL or load the 16-bit value and upload TPM1MOD.&lt;/P&gt;&lt;P&gt;TPM1MOD = 0x1F40;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write entire TPM1C1SC register once to avoid any error.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;TPM1C1SC = 0x44;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;To save code, removes "DisableInterrupts" and "EnableInterrupts" if the interruption of sets the I bit in the CCR and disables subsequent interruptions and enables on the exit of IRQ.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Another thing I would check is that the generating source for the rising edge, has no debounce. May not have these two very close measuring rising edges.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 19 Dec 2015 01:19:38 GMT</pubDate>
    <dc:creator>Leojunin</dc:creator>
    <dc:date>2015-12-19T01:19:38Z</dc:date>
    <item>
      <title>S08 Capture Mode and Timer Queries.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Capture-Mode-and-Timer-Queries/m-p/436699#M21539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am using the MC9S08DZ60 eval board. I would like to do the following.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Capture a Rising edge--&amp;gt;Start a Timer of 32ms--&amp;gt; On Overflow, run a couple of statements in an ISR.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is similar to the Pulse Accumulator in HC11 controllers. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Assumption : &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Timer and Capture mode are not related. Reason :&lt;/P&gt;&lt;P&gt;Wrote a program with capture mode disabled. Timer automatically starts and goes on as soon as it is initialized. Is this correct?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Query :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I decided to initialize the Timer inside the ISR of Rising Edge Capture. So, baby step,&amp;nbsp; wrote a simple program to Capture only Rising Edges, but the ISR is being called in both &lt;STRONG&gt;Rising and falling&lt;/STRONG&gt; Edges. Here's the code. (Your Advice on this approach also is required)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void inittimer(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;TPM1MODL = 0x40;&lt;/P&gt;&lt;P&gt;TPM1MODH = 0x1F;&lt;/P&gt;&lt;P&gt;TPM1C1SC = 0x40;&lt;/P&gt;&lt;P&gt;TPM1C1SC_ELS1A=1; //Rising Edge capture&lt;/P&gt;&lt;P&gt;TPM1C1SC_ELS1B=0;&lt;/P&gt;&lt;P&gt;TPM1SC=0x08;&lt;/P&gt;&lt;P&gt;TPM1SC_TOIE=0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;interrupt&amp;nbsp; VectorNumber_Vtpm1ch1 void timeredge(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; char temp1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DisableInterrupts;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sendstr("Rising Edge \r\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp; counter++;&lt;/P&gt;&lt;P&gt;&amp;nbsp; printf("%d \r\n",counter);&lt;/P&gt;&lt;P&gt;&amp;nbsp; temp1=TPM1C1SC;&lt;/P&gt;&lt;P&gt;&amp;nbsp; TPM1C1SC_CH1F=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ping4=~ping4; //Toggle a GPIO to monitor with a scope.&lt;/P&gt;&lt;P&gt;&amp;nbsp; led2=~led2; //Toggle LED&lt;/P&gt;&lt;P&gt;&amp;nbsp; EnableInterrupts;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;volatile static int counter; //Defined before main().&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure there's no debouncing. I am Observing the TPM1Channel1 Pin on scope, which I have pulled up to 5V through a 2.5K resistor. I use a wire from ground to bring the pin low when required. I get beautiful square waves with no noise.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please guide me on any of the 2 ways, so that I can Proceed further.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 06:36:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Capture-Mode-and-Timer-Queries/m-p/436699#M21539</guid>
      <dc:creator>pawankumar</dc:creator>
      <dc:date>2015-08-13T06:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Capture Mode and Timer Queries.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Capture-Mode-and-Timer-Queries/m-p/436700#M21540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi pawan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would do is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first error I see is that you must write the module TPM1MOD in order TPM1MODH then TPM1MODL or load the 16-bit value and upload TPM1MOD.&lt;/P&gt;&lt;P&gt;TPM1MOD = 0x1F40;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write entire TPM1C1SC register once to avoid any error.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;TPM1C1SC = 0x44;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;To save code, removes "DisableInterrupts" and "EnableInterrupts" if the interruption of sets the I bit in the CCR and disables subsequent interruptions and enables on the exit of IRQ.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Another thing I would check is that the generating source for the rising edge, has no debounce. May not have these two very close measuring rising edges.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Dec 2015 01:19:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Capture-Mode-and-Timer-Queries/m-p/436700#M21540</guid>
      <dc:creator>Leojunin</dc:creator>
      <dc:date>2015-12-19T01:19:38Z</dc:date>
    </item>
  </channel>
</rss>

