Hello everybody, I just tried to readout the interrupt status from port 2 pin1 and I've trouble with it:
/* use port2_1 as input event, interrupt test. */ GPIOSetDir( PORT2, 1, 0 ); /* port2_1, single trigger, active high. */ GPIOSetInterrupt( PORT2, 1, 1, 0, 0 ); GPIOIntEnable( PORT2, 1 ); while( 1 ) { if ( GPIOIntStatus( PORT2, 1 )==1 ) { i++; GPIOIntClear( PORT2, 1 ); } } I step to the line with "if" and when I don't pull the port 2 pin1 to GND the debugger goes to the function GPIOIntStatus. In this function I step to the line:
case
PORT2:
if ( LPC_GPIO2->MIS & (0x1<<bitPosi) ) regVal = 1;
and then pull the port 2 pin 1 to GND. Then the regVal is 1 and if I step back to the main my variable "i" will be increased. BUT if i pull the port2 pin 1 to GND before the debugger is on the line "case PORT2:" , for example I'm at the line "if ( GPIOIntStatus( PORT2, 1 )==1 )" in main() then the debugger crashes. Why???
Can everbody help???
No, we can't manage to read the "code" since you did not manage to format the code according to the instructions.
We don't want to spend our times trying to make the code readable so we do the best we can - we spend as much time on your posts as you did on checking the rules/requirements. In short - we just ignore your posts until you make a clear and descriptive post with easy-to-read source code.
we spend as much time on your posts as you did on checking the rules/requirements.
It is amzing the so many treat FREE help with the attitude "so what if it takes them an hour to do a 5 minute job, it is FREE"
Erik
this is the formated code you asked for.everytgything you wanted is done.
you help now?
/* use port2_1 as input event, interrupt test. */ GPIOSetDir( PORT2, 1, 0 ); /* port2_1, single trigger, active high. */ GPIOSetInterrupt( PORT2, 1, 1, 0, 0 ); GPIOIntEnable( PORT2, 1 ); while( 1 ) { if ( GPIOIntStatus( PORT2, 1 )==1 ) { i++; GPIOIntClear( PORT2, 1 ); } } send reply to aamir.hasan@hotmasil.com </endcode> PORT2: if ( LPC_GPIO2->MIS & (0x1<<bitPosi) ) regVal = 1;
I don't think I'm too much off if I claim that you are one of the least careful people who have visited this forum.
First you post random noise, while missing the difference between your name and the post summary.
Then you create a new thread with badly indented code.
You still haven't mentioned what processor you have.
And you post code playing with interrupts, but don't show any interrupt handler.
And you seem to have a main loop that turns on interrupts and then busy-loops looking at interrupt flags. The goal with interrupts is to have the processor jump to an interrupt handler to perform some action and then return to the main loop.
We don't even know if you have an interrupt handler. But if you don't, and the processor jumps to some undefined address, your program will fail badly. And besides an interrupt handler - do you have any stack configured for your interrupt handlers?
How much time have you spent looking at the sample code for your processor?