Strange problem

I was using LPC22xx. I set the P0.16 as an external interrupt input. It was active at the falling edge. In the interrupt handling function, I tried to get the state of this pin, and waited until it became high. Here are some of the codes.

#define IO0PIN (*((volatile unsigned long *)0xe0028000))

while((IO0PIN & 0x10000) == 0);

Though after an interrupt, pin 16 would turn to high, but the CPU could not detect it. It kept on running the instruction above all the time. I read the register with OpenOCD command.

mdw 0xe0028000 0x1, the returned value also indicated pin 16 is LOW. And I used an oscilloscope to check pin 16 of the CPU, it was HIGH.

Does anyone have such experience? What’s the reason?

Best regards,

Kevin

you did set the port pin as an input corect ?

IO0DIR &=~ 0x00010000;

Hi,

I tried the way you suggested. However, it did not work. It seems that the status of the PINs will not be updated when CPU is in exception mode. Anyone knows more about it?

I also changed PIN0.16 to be a GPIO when an interrupt occured, and set it as input, but it did not help. Whenever I read the register 0xe0028000, which is IO0PIN, it was alway 0, though it was actually 1 when checking it with an oscilloscope.

Regards,

Kevin

volunteer:
Hi,

I tried the way you suggested. However, it did not work. It seems that the status of the PINs will not be updated when CPU is in exception mode. Anyone knows more about it?

I also changed PIN0.16 to be a GPIO when an interrupt occured, and set it as input, but it did not help. Whenever I read the register 0xe0028000, which is IO0PIN, it was alway 0, though it was actually 1 when checking it with an oscilloscope.

Regards,

Kevin

I have used EINT0 on P0.16 on an LPC2138, and I was able to read the state of the pin in a serial data decoder application, but I approached it a little differently. When I got the external interrupt, I acknowledged the interrupt and then started a timer interrupt to wait for the center of the expected bit at the P0.16 input. In the handler for the timer interrupt, I changed P0.16 from the EINT0 function to the GPIO input function and read the state of the pin. After reading the state of the pin, I reconfigured it to be EINT0 again. This may have been more complex than necessary, but it works very well for my serial data decoder application.

– Dave