MRT: registers IRQ_FLAG vs STAT

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by alagner on Sun Apr 27 13:18:28 MST 2014
I've managed to run MRT successfully, yet I'm still pretty much interested in one thing:

I have MRT's channel 0 configured, it counts as it is supposed to etc. My ISR looks like this:
(It's not supposed to blink LED in the real project, but I wanted to isolate the problem)

LPC_MRT->Channel[0].STAT |= 1;

and it works fine - diode blinks.

But it should also be possible to use the IRQ_STAT register, in a way like this (at least that's the way I understand the manual):

uint32_t temp = LPC_MRT->IRQ_FLAG; //read flags
LPC_MRT->IRQ_FLAG = temp & 15; //write ones to ones
led_toggle(); //blink

the funny thing is that the led never blinks, and step debugging shows the following:

uint32_t temp = LPC_MRT->IRQ_FLAG; // after single stepping through this, temp equals 0, but peripheral view shows 1 in register, how come?
LPC_MRT->IRQ_FLAG = temp & 15; //and I'm landing in defaultHandler, so sth went wrong, gotta check what fault is this
led_toggle(); //never gets here

What is even more suspicious, this

uint32_t temp = LPC_MRT->IRQ_FLAG; // temp still zero
led_toggle(); //voila, it blinks!

operates perfectly.

Ok, I can use chnnel's STAT instead of IRQ_FLAG and live with that, that's not much of a problem, but I'm just curious about the issue.

The manual states this about IRQ_FLAG:


Pending interrupt. The interrupt is pending because TIMER0
has reached the end of the time interval. If the INTEN bit in the
CONTROL0 register is also set to 1, the interrupt for timer
channel 0 and the global interrupt are raised.
Writing a 1 to this bit clears the interrupt request

Any ideas?