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.
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);
}
}
}
I try
void TIMER32_0_IRQHandler(void) {
but it doesn't work too
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------