This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SAM7X calling function from interrupt

Note: This was originally posted on 5th November 2008 at http://forums.arm.com

I am trying to use a timer interrupt to "Set up" a function call. INstead of setting a flag in the interrupt and then polling that flag I would like the interrupt to call a function as soon as teh interrupt is done, but not during the interrupt.

I tried setting a software (swi) interrupt to fire during the timer interupt, but the problem was that it called the software int immediatley during the timer IRQ and not after. I thought the swi was a lower priotrity int then the timer IRQ (set to priority 7), But I guess not...am I wrong????

Is ther a way to do this?
Possibley use a lower priority IRQ to call a function by "Setting" that IRQ during a higher priority IRQ ?
Parents
  • Note: This was originally posted on 6th November 2008 at http://forums.arm.com

    I think you've misunderstood...

    You could trigger a higher-priority interrupt during your routine and your routine would still run until it completes. Specifically, it will run until it unmasks the interrupts, which is usually when it exits IRQ (or FIQ) mode.

    I don't recommend setting up another interrupt to run your other code as it's not a terribly clean solution. In particular, that routine will still block other interrupts if you don't have interrupt nesting, so whilst it provides a kind of "yield" functionality, any significant processing you do in the DFC will still affect your interrupt latency.

    If you really want to trigger another interrupt, you will need to use a peripheral on your processor to do that. I can't help you with the specifics, but it's very rare for processors to have a simple "trigger an interrupt" peripheral, so you'll probably need to use another timer (or re-use the one you have).

    I would recommend using a task queue of some kind to register a DFC for execution in system mode; this is a simple solution and is effective in most applications.

    For example, your main (non-IRQ) loop could look like this:

    while (1)
    {
    waitForInterrupt();  // This will typically put the processor in a low-power mode until an interrupt is received.
    // An interrupt is received and (maybe) adds a task to a DFC list.
    runNextDFC();  // This can be interrupted.
    // Note that the implementation of the DFC list must be thread-safe, even if this is implemented by simply masking interrupts whilst it is being modified.
    }
Reply
  • Note: This was originally posted on 6th November 2008 at http://forums.arm.com

    I think you've misunderstood...

    You could trigger a higher-priority interrupt during your routine and your routine would still run until it completes. Specifically, it will run until it unmasks the interrupts, which is usually when it exits IRQ (or FIQ) mode.

    I don't recommend setting up another interrupt to run your other code as it's not a terribly clean solution. In particular, that routine will still block other interrupts if you don't have interrupt nesting, so whilst it provides a kind of "yield" functionality, any significant processing you do in the DFC will still affect your interrupt latency.

    If you really want to trigger another interrupt, you will need to use a peripheral on your processor to do that. I can't help you with the specifics, but it's very rare for processors to have a simple "trigger an interrupt" peripheral, so you'll probably need to use another timer (or re-use the one you have).

    I would recommend using a task queue of some kind to register a DFC for execution in system mode; this is a simple solution and is effective in most applications.

    For example, your main (non-IRQ) loop could look like this:

    while (1)
    {
    waitForInterrupt();  // This will typically put the processor in a low-power mode until an interrupt is received.
    // An interrupt is received and (maybe) adds a task to a DFC list.
    runNextDFC();  // This can be interrupted.
    // Note that the implementation of the DFC list must be thread-safe, even if this is implemented by simply masking interrupts whilst it is being modified.
    }
Children
No data