[SAM3S] Split-priority interrupt service routines?

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

cfranck
Posts: 18
Joined: Mon Mar 05, 2007 10:28 pm

[SAM3S] Split-priority interrupt service routines?

Wed Aug 25, 2010 2:19 pm

Hello,

I have another question.

In my current project, I have two interrupt sources which both have fairly tight latency requirements. One allows up to 10 us (let's call is "ISR A", the other one even less (5 us, "ISR B").

However, ISR B not only needs to respond quickly, it also calls an operating system function which may take several microseconds to execute in order to signal a task. This part of ISR B is not latency-critical.

What I would like to do is set ISR B to the highest priority at first (so it can preempt ISR A as soon as the interrupt is asserted), but change the priority to be lower than that of ISR A as soon as the latency-critical part of the processing has taken place so ISR A can preempt ISR B.

I have tried to change the interrupt priority in ISR B, but the NVIC does not appear to recognize that the priority of an already-active ISR has changed and that it needs to switch to a different ISR.

Is there any way to make the NVIC switch to a different ISR if the current ISR changes the interrupt priorities, or do I have to find a way to work around this problem (e.g. by using an unused interrupt vector as a "software interrupt" and put the second part of ISR B into its own interrupt service routine with a lower priority than ISR A)?
cfranck
Posts: 18
Joined: Mon Mar 05, 2007 10:28 pm

Re: [SAM3S] Split-priority interrupt service routines?

Wed Aug 25, 2010 4:10 pm

I believe I found a solution.

I split ISR B into two separate functions, one containing the latency-critical part (B1) and one containing the other part (B2). The first part changes the interrupt vector to the second part and lowers the interrupt priority before it returns, while the second part sets the interrupt vector back to the first part and raises the interrupt priority.

This way, if ISR A became pending during B1, it is called after B1 returns but before B2 begins. If ISR A becomes pending while B2 is active, B2 is preempted by ISR A.

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 6 guests