Page 1 of 1

Infinite Loop in ISR.C

PostPosted: Thu Feb 01, 2007 7:46 am
by jmles
I'm writing a program with two tasks, I signal a Message Queue from one to the other one, sometimes it works well, but sometimes when I'm simulating the program, when it reaches the OS_WaitMsgQ line it enters an infinite loop in that line of code. When I stop the simulation I can see it is executing the IntVectorHigh routine once and once again and it never finishes, this routine is in the ISR.C file(line 55 of this code). Why? Why sometimes happens and sometimes don't?

Re: Infinite Loop in ISR.C

PostPosted: Thu Feb 01, 2007 7:52 am
by jmles
I'm using PIC18F452, how can I clear the source of the interrupt? I've noticed that if I declar the variables which contains the message I'm gonna signal like a static variable the amount of times it enters that infinite loop decrements. I don't know if it is simply my impresion or it is true. What can you tell me about it? when should I declare a variable like static in Salvo RTOS?

Re: Infinite Loop in ISR.C

PostPosted: Thu Feb 01, 2007 8:50 am
by aek
That sounds like you are failing to clear the source of the interrupt, which results in the code re-entering the ISR immediately upon exiting the ISR, since the source of the interrupt is still present.

You didn't mention which processor + compiler you are using. Some processors (e.g. MSP430) automatically clear the source of the interrupt, others (e.g. PIC) do not and require an explicit clearing.

------------------


Re: Infinite Loop in ISR.C

PostPosted: Fri Feb 02, 2007 1:07 am
by aek
Which compiler?

With MPLAB-C18 + Salvo, all local variables (i.e. the auto variables ina task) must be static.

Review the PIC18 datasheets for how to clear the source of an interrupt. It's usually the IF (interrupt flag) associated with the peripheral.

------------------

[This message has been edited by aek (edited February 02, 2007).]