LPC812 GPIO freezes during I2C and MRT interrupts

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

LPC812 GPIO freezes during I2C and MRT interrupts

490 Views
lpcware
NXP Employee
NXP Employee
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
Labels (1)
0 Kudos
3 Replies

361 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ucniranjan on Fri Apr 18 18:55:03 MST 2014
Thank you very much for the replies.

As per your suggestion, I disabled the I2C and tested the GPIO and MRT. Now the code runs well, but occasionally gets struck. Interestingly the 'breathing LED' keeps running, the GPIO is also active as seen in the debug LED blinks. It is the MRT that stops working.

This happens mainly when the User keeps pressing a Key. The MRT is used in one-shot interrupt mode. After code for a key is gathered in the FIFO, the MRT stops. It starts/enabled/reset again when the key is pressed next. GPIO is always active.

For some reason, the MRT does not function after a few key presses. How is that the LPC812 continues to be active (seen from breathing LED) and the GPIO is also active (as can be seen from the debug LED blinks) but the MRT stops? Does the MRT registers get corrupted? What could be causing this behavior?

Thanks again,
Niranjan
0 Kudos

361 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Wed Apr 09 09:02:29 MST 2014
mechanical switches are noisy and can bounce between 1 and 0 many times with durations up to 50ms of bounce noise.
Are you de bouncing the mechanical switches?
0 Kudos

361 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Wed Apr 09 05:02:07 MST 2014
The user might press a key at any time, so your GPIO software need to run all the time. And wou will need some sort of FIFO between the keyboard input and the I2C software.

Disable the I2C software and test the PIO/MRT software alone.

You will need some sort of FIFO which is multitasking-safe, because the FIFO will be read/written by 2 interrupt tasks. You might use a read index and a write index. Be carefull to store only valid indices in memory.

regards
Wolfgang

0 Kudos