8 years, 8 months ago.

Match Register Interrupts on LPC1768

Hi There, I am trying to generate an interrupt when Timer2 reaches the value held in a Match Register such as MR0. I have produced code to reset Timer 2 when it reaches MR0, and to toggle an output such as MAT2.0. I can see from the datasheet how a Match Register can produce an Interrupt BUT can someone tell me how to associate an ISR with that particular Interrupt? Is there a particular naming convention?

1 Answer

8 years, 8 months ago.

There is a naming convention yes. It is somewhere in the source code, and you can also try to google it (it is fixed per MCU). Will be something like (too lazy to search exact name myself):

extern "C" TIM2_IRQHandler();

//And then you can define the handler itself somewhere in your code as just a function named TIM2_IRQHandler

However I would advice you to use the following function:

NVIC_SetVector(TIMER2_IRQn, (uint32_t)your_function);

Also then don't forget the:

NVIC_EnableIRQ(TIMER2_IRQn);

In addition to enabling it in the timer registers.

Dear Erik,

Thanks very much. MR0 Interrupts now working!

Best Regards

Winston

posted by Winston Waller 19 Aug 2015