<?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 Timer interrupt never hits TIMER0_IRQHandler in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-interrupt-never-hits-TIMER0-IRQHandler/m-p/868775#M34612</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have &lt;STRONG&gt;LPCXpresso 1769&lt;/STRONG&gt; and &lt;STRONG&gt;LPC-Link 2&lt;/STRONG&gt; for debugging. My development environment is &lt;STRONG&gt;IAR&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I wanted to experience a simple LED blinking using &lt;EM&gt;Timer.&lt;/EM&gt; There are many sample codes about it and I picked one I presume it is a working sample. I have also read some here and there how timer works with LPC's, etc...&lt;/P&gt;&lt;P&gt;The code compiles and I downloaded the program to the device.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is how to debug and find the reason why &lt;STRONG&gt;&lt;EM&gt;TIMER0_IRQHandler&lt;/EM&gt; &lt;/STRONG&gt;doesn't get hit at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the complete code in my &lt;STRONG&gt;main.c&lt;/STRONG&gt; file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;lpc17xx.h&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void TIMER0_IRQHandler(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void) &lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; // (1) Timer 0 configuration (see page 490 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1; // Power up Timer 0 (see page 63 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_SC-&amp;gt;PCLKSEL0 |= 1 &amp;lt;&amp;lt; 2; // Clock for timer = CCLK, i.e., CPU Clock (page 56 user manual)&lt;BR /&gt;&amp;nbsp; // MR0 is "Match Register 0". MR0 can be enabled through the MCR to reset&lt;BR /&gt;&amp;nbsp; // the Timer/Counter (TC), stop both the TC and PC, and/or generate an interrupt&lt;BR /&gt;&amp;nbsp; // every time MR0 matches the TC. (see page 492 and 496 of user manual)&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;MR0 = 500; //Toggle Time in mS&lt;BR /&gt;&amp;nbsp; //LPC_TIM0-&amp;gt;MR0 = 1 &amp;lt;&amp;lt; 23; // Give a value suitable for the LED blinking&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; // frequency based on the clock frequency&lt;BR /&gt;&amp;nbsp; // MCR is "Match Control Register". The MCR is used to control if an&lt;BR /&gt;&amp;nbsp; // interrupt is generated and if the TC is reset when a Match occurs.&lt;BR /&gt;&amp;nbsp; // (see page 492 and 496 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;MCR |= 1 &amp;lt;&amp;lt; 0; // Interrupt on Match 0 compare&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;MCR |= 1 &amp;lt;&amp;lt; 1; // Reset timer on Match 0&lt;BR /&gt;&amp;nbsp; // TCR is "Timer Control Register". The TCR is used to control the Timer&lt;BR /&gt;&amp;nbsp; // Counter functions. The Timer Counter can be disabled or reset&lt;BR /&gt;&amp;nbsp; // through the TCR. (see page 492 and 494 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 1; // Manually Reset Timer 0 (forced);&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;TCR &amp;amp;= ~(1 &amp;lt;&amp;lt; 1); // Stop resetting the timer&lt;BR /&gt;&amp;nbsp; // (2) Enable timer interrupt;&lt;BR /&gt;&amp;nbsp; // TIMER0_IRQn is 1, see lpc17xx.h and page 73 of user manual&lt;BR /&gt;&amp;nbsp; NVIC_EnableIRQ(TIMER0_IRQn); // see core_cm3.h header file&lt;BR /&gt;&amp;nbsp; // (3) Some more one-time set-up's;&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0; // Start timer (see page 492 and 494 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_SC-&amp;gt;PCONP |= ( 1 &amp;lt;&amp;lt; 15 ); // Power up GPIO (see lab1)&lt;BR /&gt;&amp;nbsp; LPC_GPIO1-&amp;gt;FIODIR |= 1 &amp;lt;&amp;lt; 29; // Put P1.29 into output mode. LED is connected to P1.29&lt;BR /&gt;&amp;nbsp; // (4) infinite loop;&lt;BR /&gt;&amp;nbsp; while (1) // Why do we need this?&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //LPC_GPIO1-&amp;gt;FIOPIN ^= 1 &amp;lt;&amp;lt; 29; // Toggle the LED (see lab1)&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Here, we describe what should be done when the interrupt on Timer 0 is handled;&lt;BR /&gt;// We do that by writing this function, whose address is “recorded” in the vector table&lt;BR /&gt;// from file startup_LPC17xx.s under the name TIMER0_IRQHandler;&lt;BR /&gt;void TIMER0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; // IR is "Interrupt Register". The IR can be written to clear interrupts. The IR&lt;BR /&gt;&amp;nbsp; // can be read to identify which of eight possible interrupt sources are&lt;BR /&gt;&amp;nbsp; // pending. (see page 492 and 493 of user manual)&lt;BR /&gt;&amp;nbsp; if ( (LPC_TIM0-&amp;gt;IR &amp;amp; 0x01) == 0x01 ) // if MR0 interrupt (this is a sanity check);&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;IR |= 1 &amp;lt;&amp;lt; 0; // Clear MR0 interrupt flag (see page 492 and 493 of user manual)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_GPIO1-&amp;gt;FIOPIN ^= 1 &amp;lt;&amp;lt; 29; // Toggle the LED (see lab1)&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note that:&lt;/STRONG&gt; Sorry for the code part. "Source Code &amp;lt;&amp;gt;" option didn't work for some reason.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Mar 2019 12:48:47 GMT</pubDate>
    <dc:creator>senersoft</dc:creator>
    <dc:date>2019-03-05T12:48:47Z</dc:date>
    <item>
      <title>Timer interrupt never hits TIMER0_IRQHandler</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-interrupt-never-hits-TIMER0-IRQHandler/m-p/868775#M34612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have &lt;STRONG&gt;LPCXpresso 1769&lt;/STRONG&gt; and &lt;STRONG&gt;LPC-Link 2&lt;/STRONG&gt; for debugging. My development environment is &lt;STRONG&gt;IAR&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I wanted to experience a simple LED blinking using &lt;EM&gt;Timer.&lt;/EM&gt; There are many sample codes about it and I picked one I presume it is a working sample. I have also read some here and there how timer works with LPC's, etc...&lt;/P&gt;&lt;P&gt;The code compiles and I downloaded the program to the device.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is how to debug and find the reason why &lt;STRONG&gt;&lt;EM&gt;TIMER0_IRQHandler&lt;/EM&gt; &lt;/STRONG&gt;doesn't get hit at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the complete code in my &lt;STRONG&gt;main.c&lt;/STRONG&gt; file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;lpc17xx.h&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void TIMER0_IRQHandler(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void) &lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; // (1) Timer 0 configuration (see page 490 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1; // Power up Timer 0 (see page 63 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_SC-&amp;gt;PCLKSEL0 |= 1 &amp;lt;&amp;lt; 2; // Clock for timer = CCLK, i.e., CPU Clock (page 56 user manual)&lt;BR /&gt;&amp;nbsp; // MR0 is "Match Register 0". MR0 can be enabled through the MCR to reset&lt;BR /&gt;&amp;nbsp; // the Timer/Counter (TC), stop both the TC and PC, and/or generate an interrupt&lt;BR /&gt;&amp;nbsp; // every time MR0 matches the TC. (see page 492 and 496 of user manual)&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;MR0 = 500; //Toggle Time in mS&lt;BR /&gt;&amp;nbsp; //LPC_TIM0-&amp;gt;MR0 = 1 &amp;lt;&amp;lt; 23; // Give a value suitable for the LED blinking&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; // frequency based on the clock frequency&lt;BR /&gt;&amp;nbsp; // MCR is "Match Control Register". The MCR is used to control if an&lt;BR /&gt;&amp;nbsp; // interrupt is generated and if the TC is reset when a Match occurs.&lt;BR /&gt;&amp;nbsp; // (see page 492 and 496 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;MCR |= 1 &amp;lt;&amp;lt; 0; // Interrupt on Match 0 compare&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;MCR |= 1 &amp;lt;&amp;lt; 1; // Reset timer on Match 0&lt;BR /&gt;&amp;nbsp; // TCR is "Timer Control Register". The TCR is used to control the Timer&lt;BR /&gt;&amp;nbsp; // Counter functions. The Timer Counter can be disabled or reset&lt;BR /&gt;&amp;nbsp; // through the TCR. (see page 492 and 494 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 1; // Manually Reset Timer 0 (forced);&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;TCR &amp;amp;= ~(1 &amp;lt;&amp;lt; 1); // Stop resetting the timer&lt;BR /&gt;&amp;nbsp; // (2) Enable timer interrupt;&lt;BR /&gt;&amp;nbsp; // TIMER0_IRQn is 1, see lpc17xx.h and page 73 of user manual&lt;BR /&gt;&amp;nbsp; NVIC_EnableIRQ(TIMER0_IRQn); // see core_cm3.h header file&lt;BR /&gt;&amp;nbsp; // (3) Some more one-time set-up's;&lt;BR /&gt;&amp;nbsp; LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0; // Start timer (see page 492 and 494 of user manual)&lt;BR /&gt;&amp;nbsp; LPC_SC-&amp;gt;PCONP |= ( 1 &amp;lt;&amp;lt; 15 ); // Power up GPIO (see lab1)&lt;BR /&gt;&amp;nbsp; LPC_GPIO1-&amp;gt;FIODIR |= 1 &amp;lt;&amp;lt; 29; // Put P1.29 into output mode. LED is connected to P1.29&lt;BR /&gt;&amp;nbsp; // (4) infinite loop;&lt;BR /&gt;&amp;nbsp; while (1) // Why do we need this?&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //LPC_GPIO1-&amp;gt;FIOPIN ^= 1 &amp;lt;&amp;lt; 29; // Toggle the LED (see lab1)&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Here, we describe what should be done when the interrupt on Timer 0 is handled;&lt;BR /&gt;// We do that by writing this function, whose address is “recorded” in the vector table&lt;BR /&gt;// from file startup_LPC17xx.s under the name TIMER0_IRQHandler;&lt;BR /&gt;void TIMER0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; // IR is "Interrupt Register". The IR can be written to clear interrupts. The IR&lt;BR /&gt;&amp;nbsp; // can be read to identify which of eight possible interrupt sources are&lt;BR /&gt;&amp;nbsp; // pending. (see page 492 and 493 of user manual)&lt;BR /&gt;&amp;nbsp; if ( (LPC_TIM0-&amp;gt;IR &amp;amp; 0x01) == 0x01 ) // if MR0 interrupt (this is a sanity check);&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;IR |= 1 &amp;lt;&amp;lt; 0; // Clear MR0 interrupt flag (see page 492 and 493 of user manual)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_GPIO1-&amp;gt;FIOPIN ^= 1 &amp;lt;&amp;lt; 29; // Toggle the LED (see lab1)&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note that:&lt;/STRONG&gt; Sorry for the code part. "Source Code &amp;lt;&amp;gt;" option didn't work for some reason.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:48:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-interrupt-never-hits-TIMER0-IRQHandler/m-p/868775#M34612</guid>
      <dc:creator>senersoft</dc:creator>
      <dc:date>2019-03-05T12:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Timer interrupt never hits TIMER0_IRQHandler</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-interrupt-never-hits-TIMER0-IRQHandler/m-p/868776#M34613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the following link,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/423278"&gt;https://community.nxp.com/thread/423278&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Soledad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2019 03:13:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-interrupt-never-hits-TIMER0-IRQHandler/m-p/868776#M34613</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2019-03-12T03:13:07Z</dc:date>
    </item>
  </channel>
</rss>

