9 years, 11 months ago.

Is a function called from an ISR in user or ISR context?

Hi all,

I'm working on a data logger that uses several interrupts. The code in the ISR should of course be short, certainly no length prints, etc. I've seen examples where the ISR is simply used to set a flag and the flag is polled from the main while(1) loop and acted on there.

My question is, if i call a function from my ISR, is that function is ISR or User context? Is it doing me any good to call a length function from an ISR? My assumption was that the function would be in user space, but maybe that's not right. If my assumption is correct, then why bother with flags and polling?


1 Answer

9 years, 11 months ago.

Your assumption is incorrect: functions called by an ISR are still inside the ISR. Only when it returns to the main loop (or in case of RTOS a thread) is it in user context again.

Accepted Answer

Great, that explains what I'm seeing. Thanks!

posted by Dan D. 02 Jun 2014