<?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 Simple timer problem in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Simple-timer-problem/m-p/157399#M4718</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This one is so easy that no one has ever asked it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to setup a timer that I can use to find the time elapsed in my code. I want to call a method to start the timer and then call a method to stop and return elapsed time. I have this to work except I can't get the timer to interrupt on overflow. This limits my timing ability.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using M5211DEMO board. Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;__interrupt__ void TimerOVF(void) { // Clear timer interrupt flag MCF_GPT_GPTFLG2 = 0&amp;nbsp; | MCF_GPT_GPTFLG2_TOF;&amp;nbsp; // Increase overflow count overflow_count++; }&amp;nbsp; /******************************************************* StartTimerStarts a GPT running with an interrupt for overflow.*******************************************************/void StartTimer() { overflow_count = 0;&amp;nbsp; // Set GPT0 to output compare MCF_GPT_GPTIOS = 0&amp;nbsp; | MCF_GPT_GPTIOS_IOS0;&amp;nbsp;&amp;nbsp; // Output compare on GPT0 pin MCF_GPT_GPTOC3M = 0x01; MCF_GPT_GPTOC3D = 0x01;&amp;nbsp;&amp;nbsp; // Disable toggle-on-overflow (all channels) MCF_GPT_GPTTOV = 0x0f;&amp;nbsp; // No pin output on output compare MCF_GPT_GPTCTL1 = 0;&amp;nbsp; // Disable input capture (all channels) MCF_GPT_GPTCTL2 = 0;&amp;nbsp; // Install ISR in the exception table mcf5xxx_set_handler(64 + 41, TimerOVF);&amp;nbsp;&amp;nbsp; // Enable interrupt MCF_GPT_GPTIE = 0&amp;nbsp; | MCF_GPT_GPTIE_CI0; // GPT0&amp;nbsp;&amp;nbsp; // Enable timer overflow interrupts MCF_GPT_GPTSCR2 = 0&amp;nbsp; | MCF_GPT_GPTSCR2_TOI // interrupt on overflow&amp;nbsp; | MCF_GPT_GPTSCR2_PR_1; // prescaler = 1&amp;nbsp;&amp;nbsp; // Clear timer interrupt flag MCF_GPT_GPTFLG2 = 0&amp;nbsp; | MCF_GPT_GPTFLG2_TOF;&amp;nbsp;&amp;nbsp; // Enable the GPT MCF_GPT_GPTSCR1 = 0&amp;nbsp; | MCF_GPT_GPTSCR1_GPTEN&amp;nbsp; | MCF_GPT_GPTSCR1_GPTEN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable interrupts in the interrupt controller MCF_INTC_IMRH &amp;amp;= ~(0&amp;nbsp; | MCF_INTC_IMRH_MASK41);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the CPU to allow interrupts mcf5xxx_irq_enable();}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;Any help would be greatly appreciated&lt;BR /&gt;Thanks all&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:01:55 GMT</pubDate>
    <dc:creator>kylestew</dc:creator>
    <dc:date>2020-10-29T09:01:55Z</dc:date>
    <item>
      <title>Simple timer problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Simple-timer-problem/m-p/157399#M4718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This one is so easy that no one has ever asked it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to setup a timer that I can use to find the time elapsed in my code. I want to call a method to start the timer and then call a method to stop and return elapsed time. I have this to work except I can't get the timer to interrupt on overflow. This limits my timing ability.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using M5211DEMO board. Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;__interrupt__ void TimerOVF(void) { // Clear timer interrupt flag MCF_GPT_GPTFLG2 = 0&amp;nbsp; | MCF_GPT_GPTFLG2_TOF;&amp;nbsp; // Increase overflow count overflow_count++; }&amp;nbsp; /******************************************************* StartTimerStarts a GPT running with an interrupt for overflow.*******************************************************/void StartTimer() { overflow_count = 0;&amp;nbsp; // Set GPT0 to output compare MCF_GPT_GPTIOS = 0&amp;nbsp; | MCF_GPT_GPTIOS_IOS0;&amp;nbsp;&amp;nbsp; // Output compare on GPT0 pin MCF_GPT_GPTOC3M = 0x01; MCF_GPT_GPTOC3D = 0x01;&amp;nbsp;&amp;nbsp; // Disable toggle-on-overflow (all channels) MCF_GPT_GPTTOV = 0x0f;&amp;nbsp; // No pin output on output compare MCF_GPT_GPTCTL1 = 0;&amp;nbsp; // Disable input capture (all channels) MCF_GPT_GPTCTL2 = 0;&amp;nbsp; // Install ISR in the exception table mcf5xxx_set_handler(64 + 41, TimerOVF);&amp;nbsp;&amp;nbsp; // Enable interrupt MCF_GPT_GPTIE = 0&amp;nbsp; | MCF_GPT_GPTIE_CI0; // GPT0&amp;nbsp;&amp;nbsp; // Enable timer overflow interrupts MCF_GPT_GPTSCR2 = 0&amp;nbsp; | MCF_GPT_GPTSCR2_TOI // interrupt on overflow&amp;nbsp; | MCF_GPT_GPTSCR2_PR_1; // prescaler = 1&amp;nbsp;&amp;nbsp; // Clear timer interrupt flag MCF_GPT_GPTFLG2 = 0&amp;nbsp; | MCF_GPT_GPTFLG2_TOF;&amp;nbsp;&amp;nbsp; // Enable the GPT MCF_GPT_GPTSCR1 = 0&amp;nbsp; | MCF_GPT_GPTSCR1_GPTEN&amp;nbsp; | MCF_GPT_GPTSCR1_GPTEN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable interrupts in the interrupt controller MCF_INTC_IMRH &amp;amp;= ~(0&amp;nbsp; | MCF_INTC_IMRH_MASK41);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the CPU to allow interrupts mcf5xxx_irq_enable();}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;Any help would be greatly appreciated&lt;BR /&gt;Thanks all&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:01:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Simple-timer-problem/m-p/157399#M4718</guid>
      <dc:creator>kylestew</dc:creator>
      <dc:date>2020-10-29T09:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simple timer problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Simple-timer-problem/m-p/157400#M4719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Looks like it is working now. I added a small slice of code to get it rolling.&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt; // Set the interrupt priority and level MCF_INTC_ICR(41) = 0  | MCF_INTC_ICR_IL(3)  | MCF_INTC_ICR_IP(3);     // Enable interrupts in the interrupt controller MCF_INTC_IMRL &amp;amp;= ~(0  | MCF_INTC_IMRL_MASKALL); MCF_INTC_IMRH &amp;amp;= ~(0  | MCF_INTC_IMRH_MASK41);&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:01:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Simple-timer-problem/m-p/157400#M4719</guid>
      <dc:creator>kylestew</dc:creator>
      <dc:date>2020-10-29T09:01:57Z</dc:date>
    </item>
  </channel>
</rss>

