LPC1114 interrupt issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1114 interrupt issue

738 Views
keny
Contributor I

I made a simple code to test the interrupt on LPC1114 but it doesn't enter the routine. 

the code:

#include "LPC11xx.h"

volatile int count=0;

void TIMER_32_0_IRQHandler(void) {
   LPC_TMR32B0->IR = 1; //reset flag
   count++;
   if (count == 44000) {
      count = 0;
   LPC_GPIO1->DATA ^= (1<<6);
   }
}

int main(void) {
   LPC_SYSCON->SYSAHBCLKCTRL |= (1<<9);//enable clock on TC32B0
   LPC_TMR32B0->MCR = 3; //enable interrupt + interrupt when TC = MR0
   LPC_TMR32B0->MR0 = 1091; //match register
   LPC_TMR32B0->IR = 1; //interrupt on MR0
   NVIC_EnableIRQ(TIMER_32_0_IRQn);//enable interrupt
   LPC_TMR32B0->TCR = 1; //enable timer
   LPC_GPIO1->DIR |= (1<<6);
   while(1) {
   }
}

I don't understand where i am wrong.

0 Kudos
3 Replies

555 Views
Badman
Contributor I

Check this code:

#include "LPC11xx.h"

volatile int count=0;

void TIMER32_0_IRQHandler(void)
{
     if ( LPC_TMR32B0->IR & 0x01 )     // check interrrupt from MR0
     {
       LPC_TMR32B0->IR = 1; //reset flag
       count++; 
     }
}

int main(void) {
   LPC_SYSCON->SYSAHBCLKCTRL |= (1<<9);     //enable clock on TC32B0

   LPC_GPIO1->DIR |= (1<<6);     // P1.6 as output
   
   LPC_TMR32B0->MCR = 3; //enable interrupt + interrupt when TC = MR0
   LPC_TMR32B0->MR0 = 1091; //match register
   NVIC_EnableIRQ(TIMER_32_0_IRQn);//enable interrupt
   LPC_TMR32B0->TCR = 1; //enable timer

   while(1) {
        if (count >= 44000)
       {
            count = 0;
            LPC_GPIO1->DATA ^= (1<<6);
       }
   }
}
0 Kudos

555 Views
keny
Contributor I

I try 

void TIMER32_0_IRQHandler(void) {

but it doesn't work too

0 Kudos

555 Views
jeremyzhou
NXP Employee
NXP Employee
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
I'd highly recommend you to refer to these periph_blinky demo which are involved in the LPCOpen library.
LPCOpen library:
Have a great day,

Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos