Sign in

Not a member? | Forgot your Password?

Search lpc2000

Search tips

Subscribe to lpc2000

Free PDF Downloads

An Engineer's Guide to the LPC2100 Series

Advanced Linux Programming

What Every Programmer Should Know About Memory

Introduction to Embedded Systems

C++ Tutorial

Embedded Systems - Theory and Design Methodology

Microcontroller Programming and Interfacing

Introduction to Microcontrollers


More Free PDF Downloads

Discussion Groups

See Also

ElectronicsDSPFPGA

Discussion Groups | LPC2000 | GPIO Interrupt lpc1768

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

GPIO Interrupt lpc1768 - "maike.drewitz" - Dec 9 6:15:31 2010

Hey,
i want to generate a GPIO Interrupt at the raising edge on Port2.10 and at the falling edge on Port0.21.
Is this posible?
I have tried it that way but it doesn't run, maybe anyone can take a look at this and help me, thanks =)
LPC_PINCON->PINSEL4 = 0x01000000; // set P2.12 as EINT2

LPC_GPIOINT->IO2IntEnF = 0x1400; // Port2.12 und 2.10 falling edge
LPC_GPIOINT->IO0IntEnF = 0x200000; // Port0.21 falling edge
LPC_SC->EXTMODE = EINT2_EDGE; // INT0 edge trigger
LPC_SC->EXTPOLAR = 0; /* INT0 is falling edge by default */

NVIC_EnableIRQ(EINT2_IRQn);
NVIC_EnableIRQ(EINT3_IRQn);

...

void EINT3_IRQHandler (void)
{
if(LPC_GPIOINT->IO2IntStatF & (1<<10))
{
LPC_GPIOINT->IO2IntClr |= (1<<10); // clear interrupt
LPC_GPIO1 -> FIOPIN |= D0;
}
if(LPC_GPIOINT->IO0IntStatR & (1<<21))
{
LPC_GPIOINT->IO0IntClr |= (1<<21); // clear interrupt
LPC_GPIO1 -> FIOPIN &= ~D0;
}
}



Re: GPIO Interrupt lpc1768 - arma...@mini-amd.org - Dec 9 6:42:23 2010

Hi Maike,

You need to clear the external interrupt of the GPIO in your
initialization
as well just like you did in your interrupt handler. But it should be done
before the VIC initialization.

Br,

Armand
On Thu, 09 Dec 2010 11:15:27 -0000, "maike.drewitz"
wrote:
> Hey,
> i want to generate a GPIO Interrupt at the raising edge on Port2.10 and
at
> the falling edge on Port0.21.
> Is this posible?
> I have tried it that way but it doesn't run, maybe anyone can take a
look
> at this and help me, thanks =)
> LPC_PINCON->PINSEL4 = 0x01000000; // set P2.12 as EINT2
>
> LPC_GPIOINT->IO2IntEnF = 0x1400; // Port2.12 und 2.10 falling edge
> LPC_GPIOINT->IO0IntEnF = 0x200000; // Port0.21 falling edge
> LPC_SC->EXTMODE = EINT2_EDGE; // INT0 edge trigger
> LPC_SC->EXTPOLAR = 0; /* INT0 is falling edge by default */
>
> NVIC_EnableIRQ(EINT2_IRQn);
> NVIC_EnableIRQ(EINT3_IRQn);
>
> ...
>
> void EINT3_IRQHandler (void)
> {
> if(LPC_GPIOINT->IO2IntStatF & (1<<10))
> {
> LPC_GPIOINT->IO2IntClr |= (1<<10); // clear interrupt
> LPC_GPIO1 -> FIOPIN |= D0;
> }
> if(LPC_GPIOINT->IO0IntStatR & (1<<21))
> {
> LPC_GPIOINT->IO0IntClr |= (1<<21); // clear interrupt
> LPC_GPIO1 -> FIOPIN &= ~D0;
> }
> }


Re: GPIO Interrupt lpc1768 - Tim Mitchell - Dec 9 6:53:18 2010

> LPC_GPIOINT->IO2IntClr |= (1<<10); // clear interrupt
I think this line is wrong (and the IO0IntClr), should just be IO2IntClr = (1<<10)
(not |=) as this register is write-only. Should still work though.

this is my code to do rising and falling edges on P0.25 which works

(init)
IO0IntEnF|=(1<<25);
IO0IntEnR|=(1<<25);
NVIC_SetPriority(EINT3_IRQn,0x08);
NVIC_EnableIRQ(EINT3_IRQn);

void EINT3_IRQHandler(void)
{
if ((IO0IntStatF&(1<<25))!=0) // Routine entered at falling edge of P0.25
{
IO0IntClr=(1<<25); //reset the interrupt
//..do stuff
}
if ((IO0IntStatR&(1<<25))!=0) // Routine entered at rising edge of P0.25
{
IO0IntClr=(1<<25); //reset the interrupt
//do stuff
}
}

--
Tim Mitchell


_____________________________
 Free pdf download: An Engineer's Guide to the LPC2100 Series.


Re: GPIO Interrupt lpc1768 - Paul Curtis - Dec 9 6:56:41 2010

Hi,

> Hey,
> i want to generate a GPIO Interrupt at the raising edge on Port2.10 and
> at the falling edge on Port0.21.
> Is this posible?

From the 1700 manual: "2.2 Interrupt generating digital ports
Port 0 and Port 2 can provide a single interrupt for any combination of
port pins.
Each port pin can be programmed to generate an interrupt on a rising edge,
a falling
edge, or both."

> I have tried it that way but it doesn't run, maybe anyone can take a
> look at this and help me, thanks =)

1. You did turn the ports on using PCONP didn't you?

> LPC_PINCON->PINSEL4 = 0x01000000; // set P2.12 as EINT2

You said above "edge on P2.10 and P0.21" so why bring in P2.12 all of a
sudden?

> LPC_GPIOINT->IO2IntEnF = 0x1400; // Port2.12 und 2.10 falling edge

This is confused. You wanted rising edges on port P2.10 in your spec above,
but you configure P2.10 and P2.12 for falling edges?

> LPC_GPIOINT->IO0IntEnF = 0x200000; // Port0.21 falling edge

Back to port 0.21 again? :-(

> LPC_SC->EXTMODE = EINT2_EDGE; // INT0 edge trigger

Comment does not reflect code, I think.

> LPC_SC->EXTPOLAR = 0; /* INT0 is falling edge by
> default */

This makes all external interrupts falling-edge-sensitive.

> NVIC_EnableIRQ(EINT2_IRQn);
> NVIC_EnableIRQ(EINT3_IRQn);

> void EINT3_IRQHandler (void)
> {
> if(LPC_GPIOINT->IO2IntStatF & (1<<10))
> {
> LPC_GPIOINT->IO2IntClr |= (1<<10); // clear interrupt

This must be = not |=.

> LPC_GPIO1 -> FIOPIN |= D0;
> }
> if(LPC_GPIOINT->IO0IntStatR & (1<<21))
> {
> LPC_GPIOINT->IO0IntClr |= (1<<21); // clear interrupt

Same comment about |= here.

> LPC_GPIO1 -> FIOPIN &= ~D0;
> }
> }

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Winter 2010! http://www.soldercore.com



Re: GPIO Interrupt lpc1768 - "maike.drewitz" - Dec 10 1:16:30 2010

Thanks for your reply =)
I still have another question, my raising and falling edges can change their direction every 1s, is this too fast for the controller?
Because it does not detect every edge



Re: GPIO Interrupt lpc1768 - Tim Mitchell - Dec 10 4:38:43 2010

----Original Message----
From: l...
[mailto:l...] On Behalf Of maike.drewitz
Sent: 10 December 2010 06:16 To: l...
Subject: [lpc2000] Re: GPIO Interrupt lpc1768

> Thanks for your reply =)
> I still have another question, my raising and falling
> edges can change their direction every 1s, is this too
> fast for the controller? Because it does not detect every
> edge

Depends on your clock speed, how many instructions you are executing in the interrupt routine, and if other higher priority interrupts are running.

But in principle, no it isn't too fast.

--
Tim Mitchell



Re: GPIO Interrupt lpc1768 - "maike.drewitz" - Dec 10 7:31:18 2010

okay my cpu clock is 96MHz also the GPIO clock.
in the interrupt routine I set depending on the interrupt a portpin.
The interrupt occurs every 500ns (it is a clock signal with 1 MHz)
But I can see on an oscilloscope that the signal is lower and longer then my clocksignal.

if ((LPC_GPIOINT->IO2IntStatF&(1<<12))!=0) // Routine entered at falling edge of P0.25
{
LPC_GPIOINT->IO2IntClr=(1<<12); //reset the interrupt
LPC_GPIO1 -> FIOCLR = D0;
}
if ((LPC_GPIOINT->IO2IntStatR&(1<<12))!=0) // Routine entered at rising edge of P0.25
{
LPC_GPIOINT->IO2IntClr=(1<<12); //reset the interrupt
LPC_GPIO1 -> FIOSET = D0;
}
--- In l..., "Tim Mitchell" wrote:
>
> ----Original Message----
> From: l...
> [mailto:l...] On Behalf Of maike.drewitz
> Sent: 10 December 2010 06:16 To: l...
> Subject: [lpc2000] Re: GPIO Interrupt lpc1768
>
> > Thanks for your reply =)
> > I still have another question, my raising and falling
> > edges can change their direction every 1s, is this too
> > fast for the controller? Because it does not detect every
> > edge
>
> Depends on your clock speed, how many instructions you are executing in the interrupt routine, and if other higher priority interrupts are running.
>
> But in principle, no it isn't too fast.
>
> --
> Tim Mitchell
>



Re: GPIO Interrupt lpc1768 - Paul Curtis - Dec 10 7:45:57 2010

Hi,

> okay my cpu clock is 96MHz also the GPIO clock.
> in the interrupt routine I set depending on the interrupt a portpin.
> The interrupt occurs every 500ns (it is a clock signal with 1 MHz)
> But I can see on an oscilloscope that the signal is lower and longer
> then my clocksignal.

If you use a clock generator and source in a pure square wave with a 50%
duty cycle, and you track that square wave using the code below to
programmatically output it to another port pin (GPIO1 pin 'D0' it looks
like), you will find that the output does not have a 50% duty cycle. It
cannot have because of the nature of the state detection in your interrupt
service routine.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Winter 2010! http://www.soldercore.com

>
> if ((LPC_GPIOINT->IO2IntStatF&(1<<12))!=0) // Routine entered at
> falling edge of P0.25
> {
> LPC_GPIOINT->IO2IntClr=(1<<12); //reset the interrupt
> LPC_GPIO1 -> FIOCLR = D0;
> }
> if ((LPC_GPIOINT->IO2IntStatR&(1<<12))!=0) // Routine entered at rising
> edge of P0.25
> {
> LPC_GPIOINT->IO2IntClr=(1<<12); //reset the interrupt
> LPC_GPIO1 -> FIOSET = D0;
> }
> --- In l..., "Tim Mitchell" wrote:
> >
> > ----Original Message----
> > From: l...
> > [mailto:l...] On Behalf Of maike.drewitz
> > Sent: 10 December 2010 06:16 To: l...
> > Subject: [lpc2000] Re: GPIO Interrupt lpc1768
> >
> > > Thanks for your reply =)
> > > I still have another question, my raising and falling
> > > edges can change their direction every 1s, is this too
> > > fast for the controller? Because it does not detect every
> > > edge
> >
> > Depends on your clock speed, how many instructions you are executing
> in the interrupt routine, and if other higher priority interrupts are
> running.
> >
> > But in principle, no it isn't too fast.
> >
> > --
> > Tim Mitchell
> >
>
>
>
>
>
>
>

_____________________________
 Free pdf download: An Engineer's Guide to the LPC2100 Series.