LPC Interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC Interrupt

1,838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by drvrh on Tue Jul 07 03:15:06 MST 2015
Hello, my first program in interrupt.

void EINT0_IRQHandler(void){
if(y < 5){
PotisniChar(0, y, 1, ">");
y++;
}else{
y = 1;
}

}

void PinInit(){
GPIOSetDir(0, 9, INPUT);
GPIOSetPull(0, 9, PULLUP);
}

void MainMenu(){
PinInit();
LPC_GPIOINT -> IO0IntEnF |= (1 << 9);
NVIC_EnableIRQ(EINT0_IRQn);

}


I have button on P0.9 pin, I have PULLUP resistor on VCC. And Button on GND. As you can on this right picture:
PICS

But no working.

0 Kudos
Reply
7 Replies

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Jul 08 11:50:51 MST 2015

Quote: drvrh
...how debounce correct.



For sure without a delay in ISR  :O

I prefer to use a timer to disable the interrupt a few milliseconds...

See: http://electronics.stackexchange.com/questions/165044/understanding-interrupts-and-software-button-d...
0 Kudos
Reply

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by drvrh on Wed Jul 08 03:22:50 MST 2015
OK I'am solve problem from before.

But I have a problem with debouncing how debounce correct. Now I have create with counter who counting press buttom. And if counter == 1, then made else no made.
But no working.

void EINT3_IRQHandler(void){
counter1++;
if((LPC_GPIOINT -> IO0IntStatF) & (1 << UPTIPKA_PIN)){
//counter1++;
if(counter1 == 1){
_delay_ms(150);
LPC_GPIOINT -> IO0IntClr |= (1 << UPTIPKA_PIN);
flagIO1 = 1;
Kurzor();
}else{
counter1 = 0;
}
}
}


#define UPTIPKA_PORT0
#define UPTIPKA_PIN9
0 Kudos
Reply

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Jul 08 00:49:07 MST 2015

Quote: drvrh
I have a one big problem



One  :D

- Could be useful to post your complete code, as mentioned already. Nobody knows what flagIO1 or MENUTIPKA_PIN is...

- Could be useful to read the User manual:

Quote:
External Interrupt 3 (EINT3). Note: EINT3 channel is shared with GPIO interrupts



- Could be useful to avoid incredible slow LCD functions in interrupts. You are filling your ISR with LCD functions and the main loop is empty? That's nonsense  :)

- Could be useful to start with a working example for your toolchain...



0 Kudos
Reply

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by drvrh on Wed Jul 08 00:26:17 MST 2015
LPC1769

Now updated my code and other, but:

1. I don't know how to use EINTX handler, for one button one handler or how?

2. I have a problem with debouncing please let me know how debounce on my example code

Here is the my class:
void EINT3_IRQHandler(void){

if((LPC_GPIOINT -> IO0IntStatF) & (1 << UPTIPKA_PIN)){
LPC_GPIOINT -> IO0IntClr |= (1 << UPTIPKA_PIN);
//LCDPocisti();
//MainMenu();
flagIO1 = 1;
}
if((LPC_GPIOINT -> IO0IntStatF) & (1 << MENUTIPKA_PIN)){
LPC_GPIOINT -> IO0IntClr |= (1 << MENUTIPKA_PIN);
if(flagIO2 == 0){
LCDPocisti();
MainMenu();
}else{
ZacetniZaslon();
}
}
}
void EINT2_IRQHandler(void){
if((LPC_GPIOINT -> IO0IntStatF) & (1 << HOLDTIPKA_PIN)){
LPC_GPIOINT -> IO0IntClr |= (1 << HOLDTIPKA_PIN);
if(stHoldLogo == 0){
PotisniHoldLogo();
}else{
PotisniChar(0, 4, 1, " ");
PotisniChar(0, 5, 1, " ");
stHoldLogo = 0;
flagIO3 = 0;
}
}
}

void IOIntInit(){
LPC_GPIOINT -> IO0IntEnF = (1 << UPTIPKA_PIN) | (1 << MENUTIPKA_PIN) | (1 << HOLDTIPKA_PIN);
NVIC_EnableIRQ(EINT3_IRQn);
NVIC_EnableIRQ(EINT2_IRQn);
}



here is the main program:

int main(void) {
LCDInit();
LCDPocisti();
RTCInit(0, 0, 0, 0, 15, 4, 2015);
PinInit();
    IOIntInit();
    ZacetniZaslon();

    while (1) {

    //LCDDEMO();
    //LCDPocisti();
    //MainMenu();

    }
    return 0;
}



3. I have a one big problem, I work on menu project, with button MENU i go to MainMenu function in MainMenu function button UP no working. Why. Maybe because in the MainMenu function if who test flagIO1 (button UP) and not set when I entrance in function MainMenu.
Here is my function MainMenu():

void MainMenu(){
flagIO2 = 1;
PotisniChar(16, 0, 1, "MENU");
PotisniChar(10, 1, 1, "LANG");
PotisniChar(10, 2, 1, "TIME");
PotisniChar(10, 3, 1, "HOLD");
PotisniChar(10, 4, 1, "TIMER");
PotisniChar(10, 5, 1, "TEMP");

if(flagIO1){
if(y > 5){
y = 1;
}
switch (y){
case 1:{

flagIO1 = 0;
yp = y;
yp = 5;
PotisniChar(0, yp, 1, " ");
PotisniChar(0, y, 1, ">");
y++;
break;
}case 2:{

flagIO1 = 0;
yp = y;
yp--;
PotisniChar(0, yp, 1, " ");
PotisniChar(0, y, 1, ">");
y++;
break;
}case 3:{

flagIO1 = 0;
yp = y;
yp--;
PotisniChar(0, yp, 1, " ");
PotisniChar(0, y, 1, ">");
y++;
break;
}
case 4:{

flagIO1 = 0;
yp = y;
yp--;
PotisniChar(0, yp, 1, " ");
PotisniChar(0, y, 1, ">");
y++;
break;
}
case 5:{

flagIO1 = 0;
yp = y;
yp--;
PotisniChar(0, yp, 1, " ");
PotisniChar(0, y, 1, ">");
y++;
break;
}
case 6:{

flagIO1 = 0;
yp = y;
yp--;
PotisniChar(0, yp, 1, " ");
y++;
break;
}
default:{
yp = 0;
y = 1;
break;
}
}
}
}
0 Kudos
Reply

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Jul 07 09:22:43 MST 2015

Quote: drvrh
But no working.



No clearing interrupt, no working  :O
0 Kudos
Reply

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 1234567890 on Tue Jul 07 08:33:09 MST 2015
1.) This is not a complete program.
2.) What's not working?
...
...
...
23.) You probably want to use the key word 'volatile'.
0 Kudos
Reply

1,548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Tue Jul 07 06:16:35 MST 2015
which MCU?
0 Kudos
Reply