LPC 1343 interrupt handler

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

LPC 1343 interrupt handler

1,081 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed Oct 13 08:40:15 MST 2010
Hi,

After some search work i can not find where i am looking for.
I have set an interrupt at pin 0_8:

    GPIOSetDir(0, 8, 0);
    GPIOSetInterrupt(0,8,0,1,0);
    GPIOIntEnable(0,8);

if(!GPIOIntStatus(0,8))
     {
        //do something
     }
     else
     {
         //do something
     }
Everything works fine till the interrupts comes up.
The program is in an infinite loop because there was a unexpected interrupt.
I think i need to make a interrupt handler in my file. I already made a search but could not find how to make one for the pin 0_8.

Hope you can help me with it.
0 Kudos
Reply
5 Replies

960 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 13 10:13:20 MST 2010
No.

[SIZE=2][B][COLOR=#7f0055]void[/COLOR][/B] [B]PIOINT0_IRQHandler[/B]([B][COLOR=#7f0055][COLOR=#7f0055]void[/COLOR][/COLOR][/B])[/SIZE]

is the interrupt handler for all interrrupts of PIO0. Like in the example you have to read the interrupt status (GPIOIntStatus) of your pin and clear the interrupt (GPIOIntClear).
0 Kudos
Reply

960 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed Oct 13 10:09:13 MST 2010
That could me an idea indeed.

Another question about interrupts. I know an interrupt that as it will go automatically to an subroutine when an interrupt flag is active.
After that it will return to the main program.
Do you need to use the GPIOIntStatus to see if there is any interrupt flag active? Or does the program automatically goes to the subroutine?
0 Kudos
Reply

960 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 13 10:06:11 MST 2010
I think it's no misuse to read several interrupts and set flags in ISR to handle them in main loop.
I've done this often enough and think this is a common way to work with interrupts.
0 Kudos
Reply

960 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed Oct 13 09:57:23 MST 2010
Thanks for your fast answer.

I already find those things, i thought there was a special alias for the port and bit number.
I do not want to mis use the default interrupt handler, it could me that we want to use more interrupts.

How can i define one for my own? Like for port 0_8?
Just make a alias? [SIZE=2][COLOR=#7f0055][B][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/B][/COLOR][/SIZE][SIZE=2] [B]PIOINT0_8IRQHandler[/B] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]) ALIAS(IntDefaultHandler)
[/SIZE]How does the program knows that it needs to go to the right handler?
0 Kudos
Reply

960 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 13 09:43:14 MST 2010
Of course you are right. In cr_startup_lpc13.c you can find the forward declaration of interrupts and their 'ALIAS', which is used if you don't define your own.

With:
Quote:

[SIZE=2][COLOR=#7f0055][B][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/B][/COLOR][/SIZE][SIZE=2] [B]PIOINT0_IRQHandler[/B] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]) ALIAS(IntDefaultHandler);[/SIZE]


and
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static [/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] [B]IntDefaultHandler[/B]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Go into an infinite loop.[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](1)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]}[/SIZE][/LEFT]
[SIZE=2]}[/SIZE]

[LEFT]you can find your loop:). [/LEFT]

[LEFT]In LPCXpresso1343_exint project you can also find a good example for your own interrupt in gpio_int.c:[/LEFT]
 
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] [B]PIOINT0_IRQHandler[/B]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])[/SIZE]
[LEFT][SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] regVal;[/SIZE]

[SIZE=2]gpio0_counter++;[/SIZE]
[LEFT][SIZE=2]regVal = GPIOIntStatus( PORT0, 1 );[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( regVal )[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]p0_1_counter++;[/SIZE]
[SIZE=2]GPIOIntClear( PORT0, 1 );[/SIZE]
[SIZE=2]}[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[/LEFT]
[/LEFT]
0 Kudos
Reply