Keil Logo

Global Interruption Disable/Enable

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Varuzhan Danielyan
Posted
1-Feb-2005 12:17 GMT
Toolset
ARM
New! Global Interruption Disable/Enable
Which is the easiest way for Global Interruptions Disable/Enable in CA for LPC2129?

Varuzhan
Read-Only
Author
Keil Reinhard
Posted
1-Feb-2005 13:05 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Varuzhan Danielyan
Posted
1-Feb-2005 18:01 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Keil Reinhard
Posted
1-Feb-2005 18:05 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Varuzhan Danielyan
Posted
1-Feb-2005 18:06 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Varuzhan Danielyan
Posted
1-Feb-2005 18:13 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Varuzhan Danielyan
Posted
1-Feb-2005 18:21 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
Sure, without brackets
Read-Only
Author
Keil Reinhard
Posted
2-Feb-2005 07:00 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Varuzhan Danielyan
Posted
2-Feb-2005 08:04 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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
Read-Only
Author
Jon Ward
Posted
2-Feb-2005 15:03 GMT
Toolset
ARM
New! RE: Global Interruption Disable/Enable
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

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.