[LPC1769] Problems with GPIO Interrupt

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

[LPC1769] Problems with GPIO Interrupt

2,803件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nykelaz on Sat May 25 20:29:04 MST 2013
Hi all,

I have problems with the GPIO interrupt and hope to get some some pointers. I am using GPIO pins P2.5 and P2.6 for external interrupt (Rising edge). Below is a truncated version of my code:

void EINT3_IRQHandler(void)
{
    if ((LPC_GPIOINT->IO2IntStatR>>5)& 0x1)
    {
LPC_GPIOINT->IO2IntClr=1<<5;
printf("Interrupt p2.5 ");
    }

    if ((LPC_GPIOINT->IO2IntStatR>>6)& 0x1)
    {
    LPC_GPIOINT->IO2IntClr=1<<6;
    printf("Interrupt p2.6 ");
    }
}

int main (void)
{
       PINSEL_CFG_Type PinCfg;

       // Initialize P2.5
       PinCfg.Funcnum = 0;
       PinCfg.OpenDrain = 0;
       PinCfg.Pinmode = 0;
       PinCfg.Portnum = 2;
       PinCfg.Pinnum = 5;
       PINSEL_ConfigPin(&PinCfg);

       // Initialize P2.6
       PinCfg.Funcnum = 0;
       PinCfg.OpenDrain = 0;
       PinCfg.Pinmode = 0;
       PinCfg.Portnum = 2;
       PinCfg.Pinnum = 6;
       PINSEL_ConfigPin(&PinCfg);

       //Set as input       
       GPIO_SetDir(2, 1<<5, 0);
       GPIO_SetDir(2, 1<<6, 0);

       //Enable interrupt
       LPC_GPIOINT->IO2IntEnR |=1<<5;
       LPC_GPIOINT->IO2IntEnR |=1<<6;
       NVIC_EnableIRQ(EINT3_IRQn);
}


However, when I trigger an interrupt on either one of the pins, both interrupts will be activated. It will print "Interrupt p2.5 Interrupt p2.6" regardless of which interrupt is triggered.

Is there anything wrong with my configuration?
0 件の賞賛
返信
3 返答(返信)

1,162件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat May 25 22:21:50 MST 2013

Quote: nykelaz
I understood from the manual the 1769 should be able to accept interrupt on rising, falling or both edges. Any advice on that?


I'm not sure how good this is working with fast signals. My sample is working without problems with 1kHz. Scope and 'cycle counter' are both showing nothing unusual
#include "LPC17xx.h"

#include <cr_section_macros.h>
#include <NXP/crp.h>
#include <stdio.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

void EINT3_IRQHandler(void)
{
 if(LPC_GPIOINT->IO2IntStatR & (1<<6))
 {
  LPC_GPIOINT->IO2IntClr=(1<<6);
  printf("Rising P2.6\n");
 }
 if(LPC_GPIOINT->IO2IntStatF & (1<<6))
 {
  LPC_GPIOINT->IO2IntClr=(1<<6);
  printf("Falling P2.6\n");
 }
}

int main(void)
{
 volatile static int i = 0 ;
 printf("GPIO Rising / Falling Interrupt\n");
 //Enable interrupt
 LPC_GPIOINT->IO2IntEnR |=(1<<6);
 LPC_GPIOINT->IO2IntEnF |=(1<<6);
 NVIC_EnableIRQ(EINT3_IRQn);
 while(1)
 {
  i++ ;
 }
 return 0 ;
}
0 件の賞賛
返信

1,162件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nykelaz on Sat May 25 21:50:02 MST 2013

Quote: R2D2
Doesn't look too wrong

A lot of your code isn't necessary, but a reduced version shouldn't behave different.

So I think you have a hardware problem and you should scope / measure P2.5 / P2.6.

This version is working here in a Standard LPCXpresso Project.
#include "LPC17xx.h"

#include <cr_section_macros.h>
#include <NXP/crp.h>
#include <stdio.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP;

void EINT3_IRQHandler(void)
{
 if(LPC_GPIOINT->IO2IntStatR & (1<<5))
 {
  LPC_GPIOINT->IO2IntClr=(1<<5);
  printf("Interrupt P2.5\n");
 }
 if(LPC_GPIOINT->IO2IntStatR & (1<<6))
 {
  LPC_GPIOINT->IO2IntClr=(1<<6);
  printf("Interrupt P2.6\n");
 }
}

int main(void)
{
 volatile static int i = 0 ;
 printf("GPIO_Interrupt Sample\n");
 //Enable interrupt
 LPC_GPIOINT->IO2IntEnR |=(1<<5);
 LPC_GPIOINT->IO2IntEnR |=(1<<6);
 NVIC_EnableIRQ(EINT3_IRQn);
 while(1)
 {
  i++ ;
 }
 return 0 ;
}



Thanks for your response. It's good to know that the code is correct *phew* I'll do a check on the hardware then

On a side note, I have problems enabling the interrupt to be triggered on both edges on the same pin. For my case, the LPC recognizes only either the rising or falling edge but not both. I understood from the manual the 1769 should be able to accept interrupt on rising, falling or both edges. Any advice on that?
0 件の賞賛
返信

1,162件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat May 25 21:14:46 MST 2013

Quote: nykelaz
Is there anything wrong with my configuration?



Doesn't look too wrong

A lot of your code isn't necessary, but a reduced version shouldn't behave different.

So I think you have a hardware problem and you should scope / measure P2.5 / P2.6.

This version is working here in a Standard LPCXpresso Project.
#include "LPC17xx.h"

#include <cr_section_macros.h>
#include <NXP/crp.h>
#include <stdio.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP;

void EINT3_IRQHandler(void)
{
 if(LPC_GPIOINT->IO2IntStatR & (1<<5))
 {
  LPC_GPIOINT->IO2IntClr=(1<<5);
  printf("Interrupt P2.5\n");
 }
 if(LPC_GPIOINT->IO2IntStatR & (1<<6))
 {
  LPC_GPIOINT->IO2IntClr=(1<<6);
  printf("Interrupt P2.6\n");
 }
}

int main(void)
{
 volatile static int i = 0 ;
 printf("GPIO_Interrupt Sample\n");
 //Enable interrupt
 LPC_GPIOINT->IO2IntEnR |=(1<<5);
 LPC_GPIOINT->IO2IntEnR |=(1<<6);
 NVIC_EnableIRQ(EINT3_IRQn);
 while(1)
 {
  i++ ;
 }
 return 0 ;
}
0 件の賞賛
返信