Is There a Programmatic Way to Discover if Code is Running In An ISR Context?

Hi! I’m running FreeRTOSv8.2.3 on a PIC32MZ. I have code that may run IN or OUTSIDE an ISR context, and I was wondering if there is a way to programmatically discover if the execution is occurring in an ISR context. Kind regards, VW

Is There a Programmatic Way to Discover if Code is Running In An ISR Context?

You can always read the info from the hardware registers, but easier: extern UBaseType_t uxInterruptNesting; if(uxInterruptNesting==0){ // in task } else { // in isr }