LPC1114 interrupt issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC1114 interrupt issue

757 次查看
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 项奖励
3 回复数

574 次查看
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 项奖励

574 次查看
keny
Contributor I

I try 

void TIMER32_0_IRQHandler(void) {

but it doesn't work too

0 项奖励

574 次查看
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 项奖励