On the K10 or K series in general, how can i check if an IRQ is executing?
I use the following to determine if executing an IRQ handler, or if in normal thread mode but with some interrupt priorities locked out, or just running as a normal thread with all interrupt priorities enabled. Uses CMSIS functions to read IPSR and BASEPRI registers.
int thread_mode ( void )
/* Local variables */
int mode ;
/* Read IPSR to determine if an exception is active */
if ( __get_IPSR() != 0 )
/* An exception is active */
mode = THREAD_MODE_EXCEPTION ;
/* Otherwise read BASEPRI register to determine if interrupt lockout
level is raised. */
else if ( __get_BASEPRI() != 0 )
/* Some interrupts locked out */
mode = THREAD_MODE_LOCKED ;
/* Otherwise must be normal thread mode with interrupts enabled */
mode = THREAD_MODE_NORMAL ;
/* Return the current operating mode */
return ( mode ) ;
} /* end of function thread_mode */
Exactly what I needed to avoid conflict between a IRQ and a main loop / super loop.
The easiest way is set a breakpoint on your Interrupt Service Routine, then, debug your code and produce the interrupt. If the debbuger stops in the breakpoint on your ISR, it means that the interrupt is being executed.
Now, if you are not sure if your ISR is correctly configured, you can force the interrupt using the NVIC_ISPR registers. For example, if you want to force the interrupt 30, you can use the code:
NVIC_ISPR0 |= (1<<30);
This will set the pending flag on interrupt vector 30 and the ISR for that vector will be executed any time the vector has been enabled in the proper NVIC_ISER register.
My honest opinion is there are three ways in order of observability (how well you can see what's going on really)
1. If you just want to see if you are getting interrupts, you can set a break point in the ISR and if you hit it, then yes at least the ISR is being called.
2. if you have serial port you can set a flag in the ISR and clear it in the main loops and use printf to indicate the ISR happened.
3. toggle an LED on and off each time the ISR gets called. The advantage is you can see the LED flicker, and doing so usually doesn't effect the timing.
4. Same as #3 but use an oscilloscope to look at at a port pin toggled by the ISR to see the ISR timing. Since an timing is often very important when dealing with interrupts an oscilloscope is a good tool to have. Pretty much any low end two channel scope will work. You can often buy them used, cheep ~$300-$500 US. I have an older TDS220 which is "good enough" (I do this all the time)
5. You can use use a cheep USB based logic analyzer. Advantage is you can do deeper timing analysis, but takes more setup time than a scope.
Retrieving data ...