<?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 32 interrupt not correctly triggering in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540195#M12014</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by otavioborges on Wed Sep 23 16:00:33 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just recently started programming NXP microcontrollers, so I'm still getting the hang of it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having trouble setting an interrupt for Timer_32_0. I have configured the registers, the code enters the interrupt handler, but I was not able to correctly set the interrupt period.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I put an watch on the TC register when the interrupt is called and I'm getting random values on the timer values. I've checked the registers for the timer and the match register seen to be correct and there's no pin capture enabled. The code I'm using is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

//#include &amp;lt;cr_section_macros.h&amp;gt;

uint32_t CPUfreq;

#if defined (__cplusplus)
extern "C" {
#endif

void TIMER32_0_IRQHandler(void){
CPUfreq = LPC_TIMER32_0-&amp;gt;TC;
Chip_GPIO_SetPinToggle(LPC_GPIO,0,8);
}

#if defined (__cplusplus)
} // extern "C"
#endif

int main(void) {
uint32_t timerFreq;

/* Timer rate is system clock rate */
timerFreq = Chip_Clock_GetSystemClockRate();

LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= 1 &amp;lt;&amp;lt; 9;
LPC_TIMER32_0-&amp;gt;MCR |= 3 &amp;lt;&amp;lt; 3; // Enables int on MR1 and Resets on match;
LPC_TIMER32_0-&amp;gt;MR[1] = timerFreq;
LPC_TIMER32_0-&amp;gt;TCR |= 1;


NVIC_ClearPendingIRQ(TIMER_32_0_IRQn);
NVIC_EnableIRQ(TIMER_32_0_IRQn);

Chip_GPIO_SetPinDIROutput(LPC_GPIO,0,8);
Chip_GPIO_SetPinState(LPC_GPIO,0,8,true);

volatile static int i = 0 ;
while(1){
__WFI();
i++;
}
}

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:39:19 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:39:19Z</dc:date>
    <item>
      <title>Timer 32 interrupt not correctly triggering</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540195#M12014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by otavioborges on Wed Sep 23 16:00:33 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just recently started programming NXP microcontrollers, so I'm still getting the hang of it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having trouble setting an interrupt for Timer_32_0. I have configured the registers, the code enters the interrupt handler, but I was not able to correctly set the interrupt period.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I put an watch on the TC register when the interrupt is called and I'm getting random values on the timer values. I've checked the registers for the timer and the match register seen to be correct and there's no pin capture enabled. The code I'm using is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

//#include &amp;lt;cr_section_macros.h&amp;gt;

uint32_t CPUfreq;

#if defined (__cplusplus)
extern "C" {
#endif

void TIMER32_0_IRQHandler(void){
CPUfreq = LPC_TIMER32_0-&amp;gt;TC;
Chip_GPIO_SetPinToggle(LPC_GPIO,0,8);
}

#if defined (__cplusplus)
} // extern "C"
#endif

int main(void) {
uint32_t timerFreq;

/* Timer rate is system clock rate */
timerFreq = Chip_Clock_GetSystemClockRate();

LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= 1 &amp;lt;&amp;lt; 9;
LPC_TIMER32_0-&amp;gt;MCR |= 3 &amp;lt;&amp;lt; 3; // Enables int on MR1 and Resets on match;
LPC_TIMER32_0-&amp;gt;MR[1] = timerFreq;
LPC_TIMER32_0-&amp;gt;TCR |= 1;


NVIC_ClearPendingIRQ(TIMER_32_0_IRQn);
NVIC_EnableIRQ(TIMER_32_0_IRQn);

Chip_GPIO_SetPinDIROutput(LPC_GPIO,0,8);
Chip_GPIO_SetPinState(LPC_GPIO,0,8,true);

volatile static int i = 0 ;
while(1){
__WFI();
i++;
}
}

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:39:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540195#M12014</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Timer 32 interrupt not correctly triggering</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540196#M12015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Wed Sep 23 16:38:15 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;There's a blinky sample, which is showing how to use timer and interrupts&amp;nbsp; &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
/**
 * @briefHandle interrupt from 32-bit timer
 * @returnNothing
 */
void TIMER32_0_IRQHandler(void)
{
// if(Chip_TIMER_MatchPending(LPC_TIMER32_0, 1))
 {
&amp;nbsp; [color=#f00]Chip_TIMER_ClearMatch(LPC_TIMER32_0, 1);[/color]
&amp;nbsp; //Board_LED_Set(0, true);
&amp;nbsp; Board_LED_Toggle(0);
 }
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your code you've obviously forgotten to reset the interrupt&amp;nbsp; &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:39:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540196#M12015</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Timer 32 interrupt not correctly triggering</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540197#M12016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by otavioborges on Wed Sep 23 20:47:01 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Worked great! 8-) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you R2D2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:39:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-32-interrupt-not-correctly-triggering/m-p/540197#M12016</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:39:21Z</dc:date>
    </item>
  </channel>
</rss>

