lpcware

LPC812 GPIO freezes during I2C and MRT interrupts

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by ucniranjan on Tue Apr 08 21:54:02 MST 2014
Friends,

I am using LPC812 on LPCXpresso Board. I use I2C, MRT and GPIO all in interrupt modes with interrupt priorities 0 (I2C), 1 (MRT) and 2 (GPIO). The GPIO pin is connected to a switch matrix. When a switch is pressed a manchester-encoded waveform is generated. The GPIO interrupts for the rising and falling edges of this waveform. The GPIO is a state machine and based on these transitions, decides the code of the switch pressed.

The MRT is programmed as a repetitive Timer with interval value 6 times that of duration between two transitions of switch matrix waveform. When a key is pressed only the GPIO is continuously interrupted, as the Timer is reset for almost every waveform transition in the GPIO ISR. Thus, when a key is pressed the MRT interrupt is not serviced.

After the completion of the all the waveform transitions (when the key is released) the MRT is interrupted. In the MRT interrupt service routine (ISR), the MCU LPC812, programmed as
I2C slave, sends the code of the switch pressed to a I2C Master (an Android device). I have used the I2C ROM APIs of the LPC812 for I2C slave send functionality (in interrupt mode).

The I2C master keeps reading the I2C Bus, every 2 seconds. If the LPC812 does not send a code, the master reads a zero and displays the code.

During GPIO activity, I2C send does not happen on LPC812. When I2C is active and till it's completion, GPIO and MRT interrupts are disabled.

The program runs well for some time. But, after a few key presses the GPIO freezes. The MRT and I2C continue to run actively as can be seen from the debug LED blinks and
old key code being sent and received by the master over I2C Bus.

But the GPIO does not recover even when the GPIO is initialized afresh again. In the GPIO Initialization the GPIO pins are again configured as per the requirement, but is not reset.

I have to use the I2C, MRT and GPIO all in interrupt modes, because in the background a 'breathing LED' is always active. If I use the I2C in polled mode the 'breathing LED' stops intermittently.

What could be the problem? Where I might have gone wrong? How do I make the program run without a hitch?

Thanks in anticipation,
Niranjan

Outcomes