Is there some way to be notified in general whenever an interrupt fires? Basically whenever the cpu is forced to push the current registers on the stack and continue with the interrupt routine
I'm looking for a generic way to log interrupts (not logging to uart - something fast of course like setting some gpio values or writing to some memory)
Is there any way to get a callback whenever an interrupt fires
-
MicroController
- Posts: 2705
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Is there any way to get a callback whenever an interrupt fires
You can try and use XT_INTEXC_HOOKS and _xt_intexc_hooks:
https://github.com/espressif/esp-idf/bl ... ors.S#L390
https://github.com/espressif/esp-idf/bl ... ors.S#L390
Re: Is there any way to get a callback whenever an interrupt fires
@MicroController thanks, this looks interesting! I couldn't find any documentation or examples on how to use this, could you possibly provide some pointers?
Also I assume this only works on xtensa based esp32 socs? what about RISC-V based chips?
Also I assume this only works on xtensa based esp32 socs? what about RISC-V based chips?
-
MicroController
- Posts: 2705
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Is there any way to get a callback whenever an interrupt fires
There likely is no 'proper' documentation, and no 'official' examples either.
Hooking interrupts at this level is very low-level stuff and not supported via an IDF API.
What I glean from it is that you 1) -D XT_INTEXC_HOOKS, then 2) in your code, declare "extern int (*_xt_intexc_hooks)(int);" and assign your hook function ("int myHook(int cause)") to it. If the hook function returns -1 the actual interrupt handler is not called.
Haven't checked if this hook can be written in C or in assembly only.
See also: viewtopic.php?t=2197
Hooking interrupts at this level is very low-level stuff and not supported via an IDF API.
What I glean from it is that you 1) -D XT_INTEXC_HOOKS, then 2) in your code, declare "extern int (*_xt_intexc_hooks)(int);" and assign your hook function ("int myHook(int cause)") to it. If the hook function returns -1 the actual interrupt handler is not called.
Haven't checked if this hook can be written in C or in assembly only.
See also: viewtopic.php?t=2197
-
MicroController
- Posts: 2705
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Is there any way to get a callback whenever an interrupt fires
On the RISC-V's, you may be able to have the linker wrap _global_interrupt_handler.
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 2 guests