LPC 11C24 GPIO read problem while debugging.

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

LPC 11C24 GPIO read problem while debugging.

200 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gaurav.ec on Thu Aug 28 08:16:49 MST 2014
I have a strange problem with reading the Port data for the GPIO. The summary of the issue is that I realized that while in the debug mode if I read a GPIO data register it will give me erroneous values, and if I turn off the debug mode and let the program run I start getting correct values. I came to know of this while working on a project. I have written a test program to illustrate the problem.

My processor is LPC11C24 and I am using LPCXpresso 7.3.0 IDE. To understand the problem look at the following code.



Quote:
int main(void) {

UART_Init(230400);


while(1) {

UART_PrintString("\nPort_0_Data: ");
UART_Printn(LPC_GPIO0->DATA);

UART_PrintString(" Port_1_Data: ");
UART_Printn(LPC_GPIO1->DATA);

UART_PrintString(" Port_2_Data: ");
UART_Printn(LPC_GPIO2->DATA);

UART_PrintString(" Port_3_Data: ");
UART_Printn(LPC_GPIO3->DATA);
DELAY_Ms(500);

}
return 0 ;
}




In the above code I am just trying to read all the GPIO registers and print them. The code is written for illustrative purposes. If I run the code in debug mode the value  of the data resisters fluctuates. For example it will give the output

Port_0_Data: 166 Port_1_Data: 145 Port_2_Data: 250 Port_3_Data:32
Port_0_Data: 167 Port_1_Data: 145 Port_2_Data: 254 Port_3_Data:32

Clearly it says that Bit 0 of port 1 has changed value, and bit 2 of port 2 has changed value even though all pins are set as input with pullup enabled (by default). Its not a hardware issue, I have tried this on LPCXpresso board with nothing connected at the input of the pins.

The  most interesting thing is that the GPIO pin values will keep on fluctuating till I have the debug mode on, as soon as I stop the debug mode (from the IDE) and let the program run, with the debug cable still connected to the board, the problem goes away! Now the GPIO data does not change not matter how long I run the program

Please help me out, unless I am missing something obvious , this could be a sever flaw and could potentially hamper all my debugging attempts.

Thank you.
0 Kudos
0 Replies