Issue in configuring the GPIOs in LPC1778

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in configuring the GPIOs in LPC1778

412 Views
sakib
Contributor I

Hi all,

I'm having difficulties in initializing the GPIO into the Input/ Output mode. I'm using LPC1778FBD144, wherein I'm trying to use some GPIOs for the specific task that required reading as well as writing on the same Pins. 

Issues:
1. After setting GPIOs into the Read-Mode, I'm continuously getting 'High State' on all the GPIOs regardless of the external voltage source (0v and 3.3v) supplied on it. 
2. When I'm setting GPIOs into the Write-Mode, I'm able to read the GPIO's status successfully (although which is not a correct method). 

Luckily, after setting GPIOs into the Write-Mode, I'm able to set the Pin's status successfully. Moreover, I'm attaching my code block, if anyone can pin-point the issue or guide me in any way will be much appreciated. 

/******TEST CODE BLOCK FOR GPIO READ*******/
// Init GPIO P4.9, P4.10, P4.11, P4.12 into Normal GPIOs-Mode
PINSEL_ConfigPin (PORT_4 , PIN_9   , PIN_FUNC0); 
PINSEL_ConfigPin (PORT_4 , PIN_10 , PIN_FUNC0); 
PINSEL_ConfigPin (PORT_4 , PIN_11 , PIN_FUNC0); 
PINSEL_ConfigPin (PORT_4 , PIN_12 , PIN_FUNC0);

/*** This method works, but with this method, I might get the loopback data of whatever I try to write on these Pins when. Hence, I will not able to differentiate whether the data is coming from the out or I'm setting myself. ****/

// Define P4.9, P4.10, P4.11, P4.12 into Write-Mode
GPIO_SetDir (PORT_4 , (1<<(PIN_9 ))  , (uint8_t)0x01);
GPIO_SetDir (PORT_4 , (1<<(PIN_10)) , (uint8_t)0x01); 
GPIO_SetDir (PORT_4 , (1<<(PIN_11)) , (uint8_t)0x01); 
GPIO_SetDir (PORT_4 , (1<<(PIN_12)) , (uint8_t)0x01); 

/***** with this defination we're not able to read the Data at the pins! 

// Define P4.9, P4.10, P4.11, P4.12 into Read-Mode
GPIO_SetDir (PORT_4 , (1<<(PIN_9 ))  , (uint8_t)0x00);
GPIO_SetDir (PORT_4 , (1<<(PIN_10)) , (uint8_t)0x00); 
GPIO_SetDir (PORT_4 , (1<<(PIN_11)) , (uint8_t)0x00); 
GPIO_SetDir (PORT_4 , (1<<(PIN_12)) , (uint8_t)0x00); 
*****/
while(1)
{

Delay_ms(1000);

uint32_t uiGPIO_Value = GPIO_ReadValue(PORT_4);
uint8_t ucRetData        = uiGPIO_Value & (uint8_t)0xFF ;
printf("DATA=%x\n\r",ucRetData  ); 
}

Labels (3)
0 Kudos
5 Replies

226 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

I as far the code snippet that you are showing I dont see anything evidently wrong. I am however a bit confused as to what you mean by  

specific task that required reading as well as writing on the same Pins

For this I want to clarify you can only do one a time with the same pin. You can either write on the pin or read from the pin.

Try using GPIO_SetPortDIR instead, let me know if the results are different.

Best Regards,

Sabina

0 Kudos

226 Views
sakib
Contributor I

Hello Sabina Bruce‌, Thanks for your reply! 

The specific task that I'm trying to achieve here is I'm trying to interface the Graphical LCD RA8872 (parallel interface with controller).  

https://www.displaytech-us.com/sites/default/files/driver-ic-data-sheet/RAiO-RA8872.pdf

And yes, I'm aware that I can't use the GPIO-Read and GPIO-Write at the same time. Therefore, I'm always changing the definition of these Pins (Re-Init with required direction) before Writing or Reading anything on these GPIOs. 

Moreover, I can't use the GPIO_SetPortDIR, because there are some control lines are on the same port, which has to be in the GPIO-Write Mode.

The complete definition of the Pins are as follow:
Control lines: CS, RS, RD, WR (Fixed GPIO-Write). Data Lines: DB0 toDB7 (GPIO-Read/ GPIO-Write). 

Somehow, I've made the code working as per the requirement by add "PINSEL_SetPinMode".

/******after addition of these definitions, the GPIOs are switching into GPIO-Write and GPIO-Read mode easily. 

although, I'm not able to understand why I specifically needs to defined these Pins into the PullDown mode*****/
PINSEL_SetPinMode(PORT_4 , PIN_9 ,  PINSEL_BASICMODE_PULLDOWN );

PINSEL_SetPinMode(PORT_4 , PIN_10 ,  PINSEL_BASICMODE_PULLDOWN);

PINSEL_SetPinMode(PORT_4 , PIN_11 ,  PINSEL_BASICMODE_PULLDOWN);

PINSEL_SetPinMode(PORT_4 , PIN_12 ,  PINSEL_BASICMODE_PULLDOWN);

Till now, I'm still not able to make the LCD work, so, If you've any kind of reference or link where I can get some tips or any information, please share with me.

0 Kudos

226 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

Hope you are doing well. I'm glad it is working now. Generally the pin's internal state can be pull up or pull down or floating as well. So it is strange that it is only working as pull down. Are you basing your application on an example? If so, what version are you using?

As far as the LCD screen not working, yet, I'd like to know your connections from the mcu to the lcd. If you have schematic of your connections that would be fine. If not, then just describe what pins you have connected to cs, rs, rd, wr..etc. This way we can first rule out any hardware issues.

Best Regards,

Sabina

0 Kudos

226 Views
sakib
Contributor I
hello, Sabina,
Thank you for your help. up till now, the LCD is displaying the desired output. I am using the Displaytech INT028ATFT LCD module.
now I hope the pull-up/pull-down issue has been sorted but the problems happening are
1.when I am connecting the LCD module to the LPC controller after approx five to ten minutes the LPC controller stops operating and sometimes just at the moment of connecting the LCD.
2. with the LCD still connected it displays the same picture, but I am unable to restart(reset) the LPC controller or reprogram it.
3. when I disconnect the module(manually disconnecting the connector) the controller restarts and works normally.
 I am posting an image of the schematic for your reference.
Best Regards,
sakib khan
105-113300-03-4.jpg
0 Kudos

226 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello Sakib,

This sounds like it could be a power distribution issue. I would recommend to mesure the supply currents and voltage as stated in the data sheet for both the LPC1778 and your LCD module.

Here make sure that you are not getting a sudden unexpected drop in the votlage or current when you connect the LCD. From your schematic I see that all power lines ar connected to the same 3.3V. If you do see an anomily, please try to  separe the power sources and measure these points again.

Let me know your results,

Sabina

0 Kudos