I am working with the following CPU: Stellaris LM4F120H5QR Microcontroller. This CPU contains a MPU and I want to utalize this thing. But a lot of registers are no longer accessable when inside unpriviliged mode and I cannot seem to find a register which indicates that the system is inside an interrupt and is readable from unpriviliged mode.
I need this because there is code that might take a different route when called from an interrupt. If I do a wrong check from unprivileged mode, the system will immedeatly jump to access fault.
So how can I check if a function is called from an interrupt in a way that will not create a fault when called from unprivileged mode?
According to ARM's documentation the
CONTROL
andISR
registers might be just what you need.So, using the CMSIS prototypes, the code might look like:
As far as I know, reading those should be allowed even to a user thread.