EmbeddedRelated.com
Forums

Timer and UART interrupt simultaneously

Started by "emiel.guide" January 21, 2009
I am working with Crossworks 1.7 and I am having some trouble with the
interrupts that occur. The interrupts are working fine untill they
occur simultaneously. (I have 5 interrupts total, 3 external(buttons))

The interrupts are all vectored based. Timer IRQ is on vector adress 0
to give it the highest priority.

The programs seems to go to 'pabort handler' when there are more than
2 flags set in the VEC-IRQ register.

I did clear all the interrupts at the end of the interrupt in register
VicIntEnClear. I did also turned off all the vectored interrupts at
the beginning of a interrupt handler and turn it on again at the end.

Unfortunatly that didn't work. Also putting the standaard functions
"libarm_disable_irq() and libarm_enable_irq();" at the beginning and
end of every interrupt wasn not working.

The code I did write for it is below..

//// init///

VICVectAddr1 = (unsigned int) &TIME_IRQ;
VICVectCntl1 = (1<<5) | TIM0_BIT;
VICIntEnable |= TIM0;

VICVectAddr2 = (unsigned int) &UART0_IRQ;
VICVectCntl2 = (1<<5) | UART0_BIT;
VICIntEnable |= UART0;

VICDefVectAddr = (unsigned int) NoVect_IRQ;

///timer //occures every 250ms, 4 times per second

T0IR = 0x01; //clear timerinterrupt.

iSeconds = iSeconds + 1;

if(iSeconds == 239)
{
iSeconds = 0; // Seconds resetten
iMinutes++; // extra minuut definieren.
}

But like I said, the interrupts are working fine untill the occur both
at the same time. Did anyone solve this problem ? Thanks

An Engineer's Guide to the LPC2100 Series

emiel.guide schrieb:

> Unfortunatly that didn't work. Also putting the standaard functions
> "libarm_disable_irq() and libarm_enable_irq();" at the beginning and
> end of every interrupt wasn not working.
>
> The code I did write for it is below..

Missing the interrupt routine ... Did you tell the compiler that these
functions are called in IRQ context ?

BTW:
///timer //occures every 250ms, 4 times per second
^^^^^^^^^^
or
iSeconds = 0; // Seconds resetten
^^^ ^^^^^^^^
I would not comment obvious things.

--
42Bastian

Note: SPAM-only account, direct mail to bs42@...

Hi:

I've had problems with Nested Interrupts. They seem to always abort
(using LPC2366, Keil Compiler).

If your application can afford it, do not use Nested interrupts.

You didn't show all your Interrupt Handler code, but I guess you have
the macro IENABLE at the beginning of the ISR. If you remove it, you
won't have nested interrupts.

In this case, if two interrupts arrive a the same time at the VIC, the
one with higher priority will be executed first, followed by the
second one. Note that the latency of the second ISR depends of the
execution time of the first one. Therefore, it is always a good idea
to make the ISR's as short as possible.

Regards,

Alex
--- In l..., "emiel.guide" wrote:
>
> I am working with Crossworks 1.7 and I am having some trouble with the
> interrupts that occur. The interrupts are working fine untill they
> occur simultaneously. (I have 5 interrupts total, 3 external(buttons))
>
> The interrupts are all vectored based. Timer IRQ is on vector adress 0
> to give it the highest priority.
>
> The programs seems to go to 'pabort handler' when there are more than
> 2 flags set in the VEC-IRQ register.
>
> I did clear all the interrupts at the end of the interrupt in register
> VicIntEnClear. I did also turned off all the vectored interrupts at
> the beginning of a interrupt handler and turn it on again at the end.
>
> Unfortunatly that didn't work. Also putting the standaard functions
> "libarm_disable_irq() and libarm_enable_irq();" at the beginning and
> end of every interrupt wasn not working.
>
> The code I did write for it is below..
>
> //// init///
>
> VICVectAddr1 = (unsigned int) &TIME_IRQ;
> VICVectCntl1 = (1<<5) | TIM0_BIT;
> VICIntEnable |= TIM0;
>
> VICVectAddr2 = (unsigned int) &UART0_IRQ;
> VICVectCntl2 = (1<<5) | UART0_BIT;
> VICIntEnable |= UART0;
>
> VICDefVectAddr = (unsigned int) NoVect_IRQ;
>
> ///timer //occures every 250ms, 4 times per second
>
> T0IR = 0x01; //clear timerinterrupt.
>
> iSeconds = iSeconds + 1;
>
> if(iSeconds == 239)
> {
> iSeconds = 0; // Seconds resetten
> iMinutes++; // extra minuut definieren.
> }
>
> But like I said, the interrupts are working fine untill the occur both
> at the same time. Did anyone solve this problem ? Thanks
>

--- In l..., "emiel.guide" wrote:
>
> I am working with Crossworks 1.7 and I am having some trouble with
the
> interrupts that occur. The interrupts are working fine untill they
> occur simultaneously. (I have 5 interrupts total, 3
external(buttons))
>
> The interrupts are all vectored based. Timer IRQ is on vector adress
0
> to give it the highest priority.
>
> The programs seems to go to 'pabort handler' when there are more
than
> 2 flags set in the VEC-IRQ register.
>
> I did clear all the interrupts at the end of the interrupt in
register
> VicIntEnClear. I did also turned off all the vectored interrupts at
> the beginning of a interrupt handler and turn it on again at the
end.
>
> Unfortunatly that didn't work. Also putting the standaard functions
> "libarm_disable_irq() and libarm_enable_irq();" at the beginning
and
> end of every interrupt wasn not working.
>
> The code I did write for it is below..
>
> //// init///
>
> VICVectAddr1 = (unsigned int) &TIME_IRQ;
> VICVectCntl1 = (1<<5) | TIM0_BIT;
> VICIntEnable |= TIM0;
>
> VICVectAddr2 = (unsigned int) &UART0_IRQ;
> VICVectCntl2 = (1<<5) | UART0_BIT;
> VICIntEnable |= UART0;
>
> VICDefVectAddr = (unsigned int) NoVect_IRQ;
>
> ///timer //occures every 250ms, 4 times per second
>
> T0IR = 0x01; //clear timerinterrupt.
>
> iSeconds = iSeconds + 1;
>
> if(iSeconds == 239)
> {
> iSeconds = 0; // Seconds resetten
> iMinutes++; // extra minuut definieren.
> }
>
> But like I said, the interrupts are working fine untill the occur
both
> at the same time. Did anyone solve this problem ? Thanks
>

I am not familiar with use of Crossworks as I went the Eclipse/GNU
route. I had not trouble getting nested interrupts to work with the
VIC on the LPC2103. Are you doing a dummy write (of any data) to the
VICADDRESS register at the end of the ISR? This is required.

TC
At 19:33 21.01.2009 +0000, you wrote:
>I've had problems with Nested Interrupts. They seem to always abort
>(using LPC2366, Keil Compiler).
>
>If your application can afford it, do not use Nested interrupts.
>
>You didn't show all your Interrupt Handler code, but I guess you have
>the macro IENABLE at the beginning of the ISR. If you remove it, you
>won't have nested interrupts.
IENABLE *did* work on the former Keil CARM compiler, but does not
work on Realview anymore. I remember that I've found some other code
on the Keil website for Realview (with an extra assembler file
calling the main routine written in C) but that did not work either.

So does anybody have code snippets to make nested interrupts working
again on Realview ???

Herbert

Yes,

--T0IR = 0x01;

I do reset the timer\counter when it equals

--T0MR0 = 3000000; (clk at 12 Mhz)

in the timer interrupt routine.

Thks for the hint anyway :) .

I did use libarm_(dis or en)able_irq(). I think that is the equal to
the IEnable routine. I am not working in a keil environment but in
Crossworks from Rowley.

When I remove them both from the beginning and the start of the
interrupt. The interrupts routines are not called again after the
first interrupt occurs.

Thks for the hint anyway :) .
yes,

VICVectAddr = 0;

At 09:29 22.01.2009 +0000, you wrote:
>I did use libarm_(dis or en)able_irq(). I think that is the equal to
>the IEnable routine. I am not working in a keil environment but in
>Crossworks from Rowley.

No. that's not the same. What we want is to enable nested interrupts.

Herbert
Why ? I prefer not to enable nested interrupt to keep the code simple.
Or are you referring that it is only possible to avoid the 'bug' by
enabling nested interrupts ?

Thanks for your input :) .

--- In l..., Herbert Demmel wrote:
>
> At 09:29 22.01.2009 +0000, you wrote:
> >I did use libarm_(dis or en)able_irq(). I think that is the equal to
> >the IEnable routine. I am not working in a keil environment but in
> >Crossworks from Rowley.
>
> No. that's not the same. What we want is to enable nested interrupts.
>
> Herbert
>