Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can OS_ENTER_CRITICAL(); stop the external interrupt ?

Status
Not open for further replies.

timerc

Newbie level 6
Newbie level 6
Joined
Nov 22, 2008
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,358
A problem of interrupt !

OS_ENTER_CRITICAL();
it is a interrupt function;can it stop the external interrupt ?
my CPU I/O use this function to stop the external interrupt,and then to receive the data ,but it can not receive anything.

thanks .
 

Re: A problem of interrupt !

typically, the first thing an interrupt routine will do is to disable the interrupt. This allows the routine to complete without being further interrupted. You could allow further interrupts, but you run the risk of overflowing the stack.

Once the routine has run and returned, you would enable the interrupt once again, if so desired.
 

Re: A problem of interrupt !

Critical sections are sections that can not be interrupted. You generally only use these sections on either time critical code or code that accesses shared resources that can not be interrupted until they have been completed.

Critical sections will disable interrupts on entry and then restore the previous state on exit.

I assume you are accessing a UART. UART handlers are generally interrupt driven so if you disable the interrupts then the UART handler for receiving a character can not execute until interrupts are enabled again. If you are waiting for a character then you will get a deadlock condition.

Critical section should be as short as possible.

Here is an example

volatile unsigned char x;

void DoSomething(void)
{
char y;

BEGIN_CRITICAL()
x ++;
if (x > 99) x = 0;
END_CRITICAL()
y = getch();
if (y == 'R') x = 0;
if (y == 'M')
{
BEGIN_CRITICAL();
if (x) x--;
END_CRITICAL();
}
}

In the above example I have made critical sections around parts of the code that do a read-modify-write operation on the variable x. The reason for this is to prevent an interrupt or another task changing x until we have finished modifying it.
Also by declaring x volatile we are telling the compiler to do immediate reads and writes instead of caching the variable in a register.

The line "if (y == 'R') x = 0;" does not need protection if the processor can write the whole variable with one instruction and it is a write only statement. An 8 bit processor will probably need protection if it was writing to a long because this would require multiple instructions.

Variable y does not need any protection because it can not be changed by an external task or interrupt.

Hope this helps.
 

Re: A problem of interrupt !

I use this interrupt I/O to get the interrupt message,and then I disable the interrupt and use the same I/O to get data from the line .But this I/O can't get anything from the line.
May I/O funtion worse setting within it .
I use LPC2114 P0.7 to do this work .
 

Re: A problem of interrupt !

Ok. Without seeing the code it is hard to tell what is happening.

Knowing which processor does help a bit.

Do you try and read P0.7 from within the interrupt?
Have you checked if the interrupt routine actually executes?

The ARM7TDMI has several shadow registers. A different CSPR is used for interrupts,exceptions,user mode, superviser mode etc. Disabling interrupts in one mode will not effect another. An interrupt routine automatically has interrupts disabled.

A couple of things to check are:
Are the PIN CONNECT, VIC end EXTERNAL INTERRUPT registers programmed correctly?
Because you are using EINT2, are you clearing the EINT2 interrupt flag in your interrupt routine? It is important to do this!.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top