EmbeddedRelated.com
Forums

Vectored Interrupt Crossworks

Started by heedaf November 12, 2006
I've got the interrupt to work but when I try using vectored
interupts I can't get it to work. Can someone tell me where I may
have made a mistake or if I have defined it correctly for Crossworks?
Thanks,
Dewayne

VICVectAddr0 = (unsigned int) &I2C0_Isr;
VICVectCntl0 = 0x29; // Channel1 on Source#9 ... enabled
VICIntEnable |= 0x200; // 9th bit is the I2C
.
.
.

void I2C0_Isr(void) __attribute__ ((interrupt ("IRQ")));

void I2C0_Isr(void)
{
.
.
.
VICVectAddr = 0; // reset VIC
}

An Engineer's Guide to the LPC2100 Series

If you have a default IRQ handler routine set up (in place of the irq
handler in Startup.s) then I'm guessing this is where you're finding
that you end up?

You need to set a #define in Startup.s, VECTORED_IRQ_INTERRUPTS

Just stick #define VECTORED_IRQ_INTERRUPTS somewhere above the line
"#ifdef VECTORED_IRQ_INTERRUPTS" in the exception vector table setup area

What's happened is that this #define configures the LPC to jump off to
the address of your irq handler (found in VICVectAddr) instead of the
hard coded address of the irq_handler function (found at the bottom of
Startup.s)


#ifdef VECTORED_IRQ_INTERRUPTS
.word 0xB9205F88
ldr pc, [pc, #-0xFF0]
#else
.word 0xB8A06F60
ldr pc, [pc, #irq_handler_address - . - 8]
#endif



#ifndef VECTORED_IRQ_INTERRUPTS
irq_handler_address: .word irq_handler
#endif


--- In l..., "heedaf" wrote:
>
> I've got the interrupt to work but when I try using vectored
> interupts I can't get it to work. Can someone tell me where I may
> have made a mistake or if I have defined it correctly for Crossworks?
> Thanks,
> Dewayne
>
> VICVectAddr0 = (unsigned int) &I2C0_Isr;
> VICVectCntl0 = 0x29; // Channel1 on Source#9 ... enabled
> VICIntEnable |= 0x200; // 9th bit is the I2C
> .
> .
> .
>
> void I2C0_Isr(void) __attribute__ ((interrupt ("IRQ")));
>
> void I2C0_Isr(void)
> {
> .
> .
> .
> VICVectAddr = 0; // reset VIC
> }
>
It's probably a good idea to stick this little bit of code somewhere
in your project... This way if your code ends up jumping off into the
whops, then you've got a better chance of being able to "stop" it and
see where you're sitting...

These functions are also found in startup.s but are prototyped as
.weak so the function you put in your .c project will effectively
override the default function. Sticking a debug_printf in there will
also let you know your code is stuck.
void irq_handler (void)
{
debug_printf("Bad Interrupt - IRQ Handler\n");
while (1) ;
}

void fiq_handler (void)
{
debug_printf("Bad Interrupt - FIQ Handler\n");
while (1) ;
}

void swi_handler (void)
{
debug_printf("Bad Interrupt - SW Interrupt Handler\n");
while (1) ;
}

void undef_handler (void)
{
debug_printf("Bad Interrupt - Undefined Handler\n");
while (1) ;
}

--- In l..., "heedaf" wrote:
>
> I've got the interrupt to work but when I try using vectored
> interupts I can't get it to work. Can someone tell me where I may
> have made a mistake or if I have defined it correctly for Crossworks?
> Thanks,
> Dewayne
>
> VICVectAddr0 = (unsigned int) &I2C0_Isr;
> VICVectCntl0 = 0x29; // Channel1 on Source#9 ... enabled
> VICIntEnable |= 0x200; // 9th bit is the I2C
> .
> .
> .
>
> void I2C0_Isr(void) __attribute__ ((interrupt ("IRQ")));
>
> void I2C0_Isr(void)
> {
> .
> .
> .
> VICVectAddr = 0; // reset VIC
> }
>
Darcy,
You are a life saver! That was the problem. Any idea why #define VECTORED_IRQ_INTERRUPTS is not included in the startup file from Rowley?
Thanks,
Dewayne

----- Original Message -----
From: darcy_will
To: l...
Sent: Sunday, November 12, 2006 6:46 PM
Subject: [lpc2000] Re: Vectored Interrupt Crossworks
If you have a default IRQ handler routine set up (in place of the irq
handler in Startup.s) then I'm guessing this is where you're finding
that you end up?

You need to set a #define in Startup.s, VECTORED_IRQ_INTERRUPTS

Just stick #define VECTORED_IRQ_INTERRUPTS somewhere above the line
"#ifdef VECTORED_IRQ_INTERRUPTS" in the exception vector table setup area

What's happened is that this #define configures the LPC to jump off to
the address of your irq handler (found in VICVectAddr) instead of the
hard coded address of the irq_handler function (found at the bottom of
Startup.s)


#ifdef VECTORED_IRQ_INTERRUPTS
.word 0xB9205F88
ldr pc, [pc, #-0xFF0]
#else
.word 0xB8A06F60
ldr pc, [pc, #irq_handler_address - . - 8]
#endif



#ifndef VECTORED_IRQ_INTERRUPTS
irq_handler_address: .word irq_handler
#endif


--- In l..., "heedaf" wrote:
>
> I've got the interrupt to work but when I try using vectored
> interupts I can't get it to work. Can someone tell me where I may
> have made a mistake or if I have defined it correctly for Crossworks?
> Thanks,
> Dewayne
>
> VICVectAddr0 = (unsigned int) &I2C0_Isr;
> VICVectCntl0 = 0x29; // Channel1 on Source#9 ... enabled
> VICIntEnable |= 0x200; // 9th bit is the I2C
> .
> .
> .
>
> void I2C0_Isr(void) __attribute__ ((interrupt ("IRQ")));
>
> void I2C0_Isr(void)
> {
> .
> .
> .
> VICVectAddr = 0; // reset VIC
> }
>
Dewayne,

You would do well to read the documentation that the LPC2000 package comes
with.

Take a look at Philips_LPC210X_Startup.s and each and every preprocessor
define is documented along with its effect.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

> -----Original Message-----
> From: l...
> [mailto:l...] On Behalf Of Ruffell Family
> Sent: 13 November 2006 08:20
> To: l...
> Subject: Re: [lpc2000] Re: Vectored Interrupt Crossworks
>
> Darcy,
> You are a life saver! That was the problem. Any idea why
> #define VECTORED_IRQ_INTERRUPTS is not included in the
> startup file from Rowley?
> Thanks,
> Dewayne
>
> ----- Original Message -----
> From: darcy_will
> To: l...
> Sent: Sunday, November 12, 2006 6:46 PM
> Subject: [lpc2000] Re: Vectored Interrupt Crossworks
> If you have a default IRQ handler routine set up (in place
> of the irq
> handler in Startup.s) then I'm guessing this is where you're finding
> that you end up?
>
> You need to set a #define in Startup.s, VECTORED_IRQ_INTERRUPTS
>
> Just stick #define VECTORED_IRQ_INTERRUPTS somewhere above the line
> "#ifdef VECTORED_IRQ_INTERRUPTS" in the exception vector
> table setup area
>
> What's happened is that this #define configures the LPC to
> jump off to
> the address of your irq handler (found in VICVectAddr)
> instead of the
> hard coded address of the irq_handler function (found at
> the bottom of
> Startup.s)
>
>
> #ifdef VECTORED_IRQ_INTERRUPTS
> .word 0xB9205F88
> ldr pc, [pc, #-0xFF0]
> #else
> .word 0xB8A06F60
> ldr pc, [pc, #irq_handler_address - . - 8]
> #endif
>
> #ifndef VECTORED_IRQ_INTERRUPTS
> irq_handler_address: .word irq_handler
> #endif
> --- In l..., "heedaf" wrote:
> >
> > I've got the interrupt to work but when I try using vectored
> > interupts I can't get it to work. Can someone tell me where I may
> > have made a mistake or if I have defined it correctly for
> Crossworks?
> > Thanks,
> > Dewayne
> >
> > VICVectAddr0 = (unsigned int) &I2C0_Isr;
> > VICVectCntl0 = 0x29; // Channel1 on Source#9 ... enabled
> > VICIntEnable |= 0x200; // 9th bit is the I2C
> > .
> > .
> > .
> >
> > void I2C0_Isr(void) __attribute__ ((interrupt ("IRQ")));
> >
> > void I2C0_Isr(void)
> > {
> > .
> > .
> > .
> > VICVectAddr = 0; // reset VIC
> > }
> >
>
>
>
>
> Yahoo! Groups Links
>
No worries, we had the same problem last week :) The ARM is a tricky
little sod to learn (compared to an 8051/PIC/AVR) and it's
configurability offers more than a few trip-ups. You'll possibly have
also noticed all the other bits n pieces being configured in
startup.s. As Paul suggested, it's definitely worth familiarising
yourself with that file as a lot of work is done there that you'd
otherwise have to do yourself.

Cheers
D.
--- In l..., "Ruffell Family"
wrote:
>
> Darcy,
> You are a life saver! That was the problem. Any idea why #define
VECTORED_IRQ_INTERRUPTS is not included in the startup file from Rowley?
> Thanks,
> Dewayne