sakib khan

Issue in configuring the GPIOs in LPC1778

Discussion created by sakib khan on Oct 1, 2019
Latest reply on Oct 12, 2019 by Sabina Bruce

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  ); 
}

Outcomes