P0_26 on LPC54102

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

P0_26 on LPC54102

Jump to solution
851 Views
skanda19
Contributor III

Hello,

I been having some difficulties to control P0_26 on lpc54102. I know this pins is used to contro i2c1, but i our pcb design we map this pin to be used gpio (output), but I been having a hard time doing this, i feel kinda dumb hahah. 

I modified the blinky.c example code:

#include "board.h"
 
/*****************************************************************************
 * Private types/enumerations/variables
 ****************************************************************************/
 
#define TICKRATE_HZ (10) /* 10 ticks per second */
 
/*E1 - OUTPUT*/
#define     PORT0                           0
#define     RS485_REn_PORT                  PORT0
#define     RS485_REn_PIN                   26
#define     RS485_REn_OUT                   LPC_GPIO->DIR[RS485_REn_PORT]|=(1UL <<RS485_REn_PIN)
#define     RS485_REn_HI                    LPC_GPIO->B[RS485_REn_PORT][RS485_REn_PIN] = true
#define     RS485_REn_LO                    LPC_GPIO->B[RS485_REn_PORT][RS485_REn_PIN] = false
#define     RS485_REn_INP                   LPC_GPIO->DIR[RS485_REn_PORT]&=~(1UL <<RS485_REn_PIN)
#define     RS485_REn_IN                    LPC_GPIO->B[RS485_REn_PORT][RS485_REn_PIN]
#define     RS485_REn_TOG                   LPC_GPIO->NOT[RS485_REn_PORT]|=(1UL <<RS485_REn_PIN)
 
/*****************************************************************************
 * Public types/enumerations/variables
 ****************************************************************************/
 
/*****************************************************************************
 * Private functions
 ****************************************************************************/
 
/*****************************************************************************
 * Public functions
 ****************************************************************************/
 
/* Systick handler ISR */
void SysTick_Handler(void)
{
Board_LED_Toggle(0);
    RS485_REn_TOG;
}
 
/* main function (C entry point) */
int main(void)
{
int loop = 1; /* Used to fix the unreachable statement warning */
SystemCoreClockUpdate();
Board_Init();
 
Board_LED_Set(0, false);
    
    Chip_IOCON_PinMuxSet(LPC_IOCON, RS485_REn_PORT, RS485_REn_PIN,
                                    (IOCON_FUNC0 | IOCON_DIGITAL_EN | IOCON_GPIO_MODE));
    
    RS485_REn_OUT;
    RS485_REn_HI;
 
/* Enable SysTick Timer */
SysTick_Config(SystemCoreClock / TICKRATE_HZ);
 
while (loop) {
__WFI();
}
 
return 0;
}

but I am not been able to change the behavior of this pin, on our custom project and also the lpcXpresso 54102 board. when I change the configuration on debug mode the value goes back to 0 (keil). 
 
can someone help me sort this out ? 
 
thanks 
0 Kudos
Reply
1 Solution
748 Views
skanda19
Contributor III
Hey Alex, 

Thanks for the quick response. I was able to figure out what was the issue: 
In the user manual for the LPC54102, specifically in the IOCON  chapter mentions that the type I pin doesn't have any Pull-Up or Pull-Down resistors and if the user wants to use them as output the line will stay low because will be in and open-drain state. I solved the issue when I added an external resistor to be able to pull the level on the line. 

again, thanks for your help,
Ricardo B. 

View solution in original post

0 Kudos
Reply
7 Replies
816 Views
skanda19
Contributor III

skanda19_0-1711382462716.png

 

both ports of the gpio are initialized. The pins are type I and I can control with the same method pins:

  • 23
  • 24
  • 27
  • 28

the only ones that i can't control is those 2:

  • 25
  • 26

IOCON are configured as follow:

skanda19_1-1711383548691.png

but the state of the gpio no matter what remains low.

0 Kudos
Reply
808 Views
skanda19
Contributor III
the only way i can switch the line state, is when I change the invert bit. while this can be a work around, i would like to understand why is this happening ?

thanks,
RB
0 Kudos
Reply
792 Views
Alex_Wang
NXP Employee
NXP Employee

Hi, @skanda19 

I use the lpcxpresso54201 development board to control the LED blink of P0_26 (connect J2-16(P0_26)->J1-14(LED_GREEN)), for details, see the attached project configuration.

Hope this helps you.

Best regards, Alex

0 Kudos
Reply
779 Views
skanda19
Contributor III

hey alex! thanks for the support,

just to make sure:
you're initializing gpio (clk enable), setting iocon as gpio mode and setting pin 0_26 as alternate func 0,setting the pin as output and writting to B[port0][pin26].

am I correct ? or am I missing something ?

0 Kudos
Reply
756 Views
Alex_Wang
NXP Employee
NXP Employee

Hi, @skanda19 

Yes, I multiplexed P0_26 in gpio mode, initialized gpio (clk), and then wrote 0 or 1 to the pin to control the blink of the led.

Best regards, Alex

0 Kudos
Reply
749 Views
skanda19
Contributor III
Hey Alex, 

Thanks for the quick response. I was able to figure out what was the issue: 
In the user manual for the LPC54102, specifically in the IOCON  chapter mentions that the type I pin doesn't have any Pull-Up or Pull-Down resistors and if the user wants to use them as output the line will stay low because will be in and open-drain state. I solved the issue when I added an external resistor to be able to pull the level on the line. 

again, thanks for your help,
Ricardo B. 

0 Kudos
Reply
822 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @skanda19 

You can refer to "led_blinky" demo to config gpio.

Check whether enabled gpio clock.

Alice_Yang_0-1711332567683.png

 

BR

Alice

0 Kudos
Reply