Passing parameters between interrupt handlers on the Cortex-M3
I am building a lightweight core for Cortex-M3.
From a high priority interrupt, I would like to call some code to run on a lower priority interrupt, and pass some parameters.
I don't want to use a queue to publish a job with a lower priority interrupt.
I just have a buffer and size to go to.
The scrolling guide states that the SVC interrupt handler is synchronous, which presumably means that if you call it from an interrupt that has a lower priority than the SVC handler, it gets called immediately (meaning you can pass parameters to it's like calling a function (a bit like BIOS calls in MS-DOS).
I would like to do it differently: by passing parameters from a preemptive interrupt to a lower priority (for the moment I am doing this by leaving the parameters in a fixed location in memory).
What's the best way to do this (if at all)?
Thanks,
a source to share
I'm not familiar with the Cortex-M3 architecture, but I'm sure you need to provide a shared memory locking mechanism.
A higher priority interrupt can interrupt lower priority processing at any time (unless some of them are specifically synchronized with the hardware and you are gaurenteed this will not happen, but it probably is not)
The locking mechanism can be as simple as a single bit flag on a critical section (disabling read-modify-write interrupts on the flag) to guarantee atomic exchange on the lock flag (i.e. if the lower priority process / interrupt is access / update of the lock flag, an interrupt with a higher priority occurs and its change.) The flag is a synchronization mechanism for reading and writing to shared memory space, allowing both processes to block another, it accesses a shared resource without disabling interrupts for a long time. (I think if accessing shared memory is fast enough, you can just disable interrupts while you access the shared folder directly)
a source to share