What is the correct method to use PIO0_20 as GPIO on LPC1517?

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

What is the correct method to use PIO0_20 as GPIO on LPC1517?

1,215 Views
aykut_kocak
Contributor I

Hello,

On my custom board, I need to enable PIO0_20 pin GPIO function. But I could not manage to enable it. Could you suggest the correct way ?

Labels (1)
0 Kudos
Reply
5 Replies

1,071 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Izzet Aykut KOCAK,

Thanks for contacting our technical support, to serve you quickly, I recommend you

first refer to a GPIO demo, under LPCopen, there is a gpio demo named "periph_gpio":

LPCOpen Software for LPC15XX | NXP    


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

1,071 Views
aykut_kocak
Contributor I

Dear Alice_Yang,

Thank you for your kind reply. But this is not the answer of my question. Maybe, I asked the question wrong way.

I already know hot to use GPIO on LPC15xx. My question was a little more specific about the pin PIO0_20 which has got a special function for hardware debugging ( SWDIO). I need to disable this function and use that pin as GPIO.  

I already, disable the fixed function of PIO0_20 with following values given below  and enabled GPIO pin function. But the pin does not give any response at all. So, I thought I am missing something and asked the question.

{

#define I2C0_MASK ~( (1 << 3 ) | (1 << 4) )
#define RESET_PIN_MASK ~( (1 << 21 ) )
#define PINENABLE1_VAL (0xFFFFFFFF & I2C0_MASK & RESET_PIN_MASK )

LPC_SWM->PINENABLE[1] = PINENABLE1_VAL;
}

0 Kudos
Reply

1,071 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello lzzet Aykut Kocak,

Have you enable SWM clock before configuration ?

    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM );


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

1,071 Views
aykut_kocak
Contributor I

Dear Alice_Yang‌,

Yes SWM clock is already enabled. Other SWM setup is working fine, indeed.

I had attached the board_sysinit.c in the first post. You can check from that file.

Rgrds.

Aykut

0 Kudos
Reply

1,071 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Aykut,

How do you know it doesn't work ?

 I haven't LPC1517,  while I test on LPC1549, it can work well.

After I configure the PIO0_20 to GPIO, can't debug project . I measure the PIO0_20 pin, it works well as my

code.  On my code, toggle this pin in a timer interrupt, the PIO0_20 can out put low - high - low -high... as GPIO.

#define PORT_MASK       ((1 << 0) | (1 << 1) | (1 << 24)|(1<<20))

void SysTick_Handler(void)
{
    uint32_t states;

    /* Get current masked port states */
    states = Chip_GPIO_GetMaskedPortValue(LPC_GPIO, 0);

    /* Toggle all the states */
    states = ~states;

    /* Write states back via masked set function. Only the enanled
       (masked states) will be changed. */
    Chip_GPIO_SetMaskedPortValue(LPC_GPIO, 0, states);
}

#define PINENABLE1_VAL  ((1<<13)|(1<<23))

In main()

{

...

    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
    LPC_SWM->PINENABLE[1] |= PINENABLE1_VAL;

...

}

I configure the code  based on "periph_gpio" demo under LPCopen.

I also checked your board_sysinit.c file , it seem there is no error, just disable the SWDIO pin two times:

 pastedImage_11.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply