EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

GPIO pin interrupts on LPC17xx

Started by Tim Mitchell September 15, 2010
On my LPC1754 I'm trying to set up a falling edge pin interrupt on P0.25.
This is my first time with a cortex-m3 part, I am more used to the ARM7's.
I can't seem to get the interrupt to happen.

Using Crossworks v2.

I do this...

IO0IntEnF|=(1<<25); //enable interrupt on falling edge
NVIC_SetPriority(EINT3_IRQn,0x08);
NVIC_EnableIRQ(EINT3_IRQn);

And the int handler is defined like this...

static void EINT3_IRQHandler(void)
{
...
}

P0.25 is wiggling up and down but the int handler never gets called.

Have I made a stupid error?

--
Tim Mitchell

An Engineer's Guide to the LPC2100 Series

Hi:

1. Is the P0.25 selected as a GPIO (see PINSEL1)?

2. Are Interrupts enabled (globally)?

// Enable all interrupts
__enable_irq();

3. Do you clear the P0.25 interrupt flag? Maybe you get the first interrupt, but without clearing the flag, you won't get any more.

Regards,

Alex.

--- In l..., "Tim Mitchell" wrote:
>
> On my LPC1754 I'm trying to set up a falling edge pin interrupt on P0.25.
> This is my first time with a cortex-m3 part, I am more used to the ARM7's.
> I can't seem to get the interrupt to happen.
>
> Using Crossworks v2.
>
> I do this...
>
> IO0IntEnF|=(1<<25); //enable interrupt on falling edge
> NVIC_SetPriority(EINT3_IRQn,0x08);
> NVIC_EnableIRQ(EINT3_IRQn);
>
> And the int handler is defined like this...
>
> static void EINT3_IRQHandler(void)
> {
> ...
> }
>
> P0.25 is wiggling up and down but the int handler never gets called.
>
> Have I made a stupid error?
>
> --
> Tim Mitchell
>

Hello Tim,

Wednesday, September 15, 2010, 4:15:08 PM, you wrote:
TM> And the int handler is defined like this...

TM> static void EINT3_IRQHandler(void)
TM> {
TM> ...
TM> }

TM> P0.25 is wiggling up and down but the int handler never gets called.

TM> Have I made a stupid error?

Is your source C or C++? If C++, you need to make sure to declare the
interrupt handler as C function:

extern "C" void EINT3_IRQHandler(void)

Also, if you use "static", it will be local to that source file and
linker won't link it to the startup. So don't.

--
WBR,
Igor mailto:s...@mail.ru

Hi Tim

See also: http://tech.groups.yahoo.com/group/lpc2000/message/48671

Your port change config looks OK so I think that your problem must be outside of this setup somewhere.

Regards

Mark

--- In l..., "Tim Mitchell" wrote:
>
> On my LPC1754 I'm trying to set up a falling edge pin interrupt on P0.25.
> This is my first time with a cortex-m3 part, I am more used to the ARM7's.
> I can't seem to get the interrupt to happen.
>
> Using Crossworks v2.
>
> I do this...
>
> IO0IntEnF|=(1<<25); //enable interrupt on falling edge
> NVIC_SetPriority(EINT3_IRQn,0x08);
> NVIC_EnableIRQ(EINT3_IRQn);
>
> And the int handler is defined like this...
>
> static void EINT3_IRQHandler(void)
> {
> ...
> }
>
> P0.25 is wiggling up and down but the int handler never gets called.
>
> Have I made a stupid error?
>
> --
> Tim Mitchell
>

Thanks everyone, it was the "static" declaration that was the problem.

The linker was not overriding the default "weak" definition of the handler with my routine so it was still jumping to the default handler.

Now working! Phew!!

--
Tim Mitchell
t...@sabretechnology.co.uk
t: 01482 800981 f: 01482 801078

-----Original Message-----
From: l... on behalf of Igor Skochinsky
Sent: Wed 15/09/2010 20:13
To: Tim Mitchell
Subject: Re: [lpc2000] GPIO pin interrupts on LPC17xx

Hello Tim,

Wednesday, September 15, 2010, 4:15:08 PM, you wrote:
TM> And the int handler is defined like this...

TM> static void EINT3_IRQHandler(void)
TM> {
TM> ...
TM> }

TM> P0.25 is wiggling up and down but the int handler never gets called.

TM> Have I made a stupid error?

Is your source C or C++? If C++, you need to make sure to declare the
interrupt handler as C function:

extern "C" void EINT3_IRQHandler(void)

Also, if you use "static", it will be local to that source file and
linker won't link it to the startup. So don't.

--
WBR,
Igor mailto:s...@mail.ru


The 2024 Embedded Online Conference