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

Global Interruption Disable/Enable

Which is the easiest way for Global Interruptions Disable/Enable in CA for LPC2129?

Varuzhan

  • There are really two solutions to this problem.

    1. If you need just a single routine that has the interrupt system disabled, you should write a __swi function. swi (= software interrupt) prevents that a function can be interrupted by an __irq. __fiq functions are not blocked.

    2. For specific interrupt blocking see:
    http://www.keil.com/support/docs/2888.htm

    Reinhard

  • As I understand, if program uses both IRQ and FIQ, the __swi function cannot be used. More, if I want to disable interruptions not for the whole function, but only for a part of code, I must write to the VICIntEnClr register as in the example. But in the example one need to disable only TIMER0 interruption. What if I need to disable all interruptions?
    If I write

    temp = VICIntEnable;
    VICIntEnClr = temp;
    ...
    VICIntEnable = temp;

    there is a risk, that if interruption happened between the two first operators, and the interrupt handler changes the value of the VICIntEnable register, a wrong value will be restored by the last operator.
    Am I wrong?
    Is there an absolutely reliable way to disable ALL interruptions for LPC2100? It is so easy in other microcontrollers.

    Varuzhan

  • You are correct about the __swi, but why do you need to block an fiq?

    It would be dangerous to change VICIntEnable in an interrupt function! You should not partice this programming style.

    Reinhard

  • As I understand, if program uses both IRQ and FIQ, the __swi function cannot be used. More, if I want to disable interruptions not for the whole function, but only for a part of code, I must write to the VICIntEnClr register as in the example. But in the example one need to disable only TIMER0 interruption. What if I need to disable all interruptions?
    If I write

    temp = VICIntEnable;
    VICIntEnClr = temp;
    ...
    VICIntEnable = temp;

    there is a risk, that if interruption happened between the two first operators, and the interrupt handler changes the value of the VICIntEnable register, a wrong value will be restored by the last operator.
    Am I wrong?
    Is there an absolutely reliable way to disable ALL interruptions for LPC2100? It is so easy in other microcontrollers.

    Varuzhan

  • I am sorry for repeating message - bad working telephone line.
    I agree about the bad stile.
    Then can I define two macros:

    unsigned int temp;
    #define _DISABLE (temp = VICIntEnable; VICIntEnClr = temp);

    #define _ENABLE (VICIntEnable = temp;)

    and use them in my code?

    Thank you,
    Varuzhan

  • Each ARM controller is somehow different.

    A generic solution to disable all interrupts is to set the CPSR I + F flag (similar code as documented under: http://www.keil.com/support/docs/2910.htm).

    But tell my: why can you not use the __swi method?

    Reinhard

  • Thank you very much!
    The __swi method is really nice, but sometimes one will not want to have a function call overhead to protect only a couple of instructions.

    Another question: do the methods, mentioned in whole this topik, including the __swi, protect from Spurious Interrupts?

    Varuzhan

  • The __swi method is really nice, but sometimes one will not want to have a function call overhead to protect only a couple of instructions.

    Isn't the __swi call less code (and overhead) than disabling interrupts?

    do the methods, mentioned in whole this topik, including the __swi, protect from Spurious Interrupts?

    Masking interrupts inhibits interrupts (spurious or not). However, a spurious interrupt is an unexpected interrupt. Once interrupts are unmasked, the spurious interrupt triggers. Then, the interrupt handler will need to handle it.

    Jon