I Implement the operating system for a customer. One of OS features is to enable the user to configure interrupts with any priority and my OS is responsible for handling these interrupt using VIM controller.
Customer only implement the handler content itself and me as OS developer create the wrapper for this handler.
The design goes like the following (only pseudo code to show the idea):
OS_Wrapper:
B USER_HANDLER
B END_ISR
END_ISR:
clear the interrupt at VIM (clear VIM_STS bit for this source)
And it is expected from the user in his user handler (USER_HANDLER) to clear the interrupt at its source.
So the clearing for interrupt at its source is done first then clearing it at VIM (Interrupt is configured as level interrupt in VIM_INTTYPE)
The problem happens when the exact same interrupt is triggered again during the handling of the first user handler.
Then the sequence will be as follows:
1-User handler is entered and interrupt is cleared at its source.
2-Interrupt comes again and raise the interrupt source again.
3-OS clears VIM flag at END_ISR
4-Now we have interrupt source is 1 and VIM flag is 0. Software stuck forever for this interrupt and never assert VIM flag to 1 again even if the source is kept triggered over and over again.
(The only way to get away from this state is to clear the soucrce explictly and wait for the sourcr to come again)
Expectation:
If interrupt source is 1 then VIM should be 1 again so the interrupt is triggered again (The same interrupt did not get missed if it comes during the handling of the previous handler of the same interrupt)