how to enable a port pins in a single line

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

how to enable a port pins in a single line

791 Views
karthikjai
Contributor II

hi

i am Karthikeyan J(student).

 

i tried to enable all GPIO pins in a layout of LPC54628[OM13098] Board. but i cant enable all pins in a single line(0xffffffffU) 32bit.

i can enable pins one by one.

FOR example (port , pin, 1)-> (1U,18U,1);

BUT when i am giving (1U, 0XFFFFFFFFU, 1);[Enable all pins] is not working.

1.)i am giving now the program which was working for single pin

#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC54628.h"
#include "fsl_debug_console.h"

int main()

{
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput,
0,
};
GPIO_PortInit(GPIO, 1U);


GPIO_PinInit(GPIO, 1U, 18U , &led_config);
GPIO_PinWrite(GPIO, 1U,18U, 0);
return(0);
}

this code is working and output is coming at the port(1), 18th pin.

2.)i am giving now the program which was not working 

#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC54628.h"
#include "fsl_debug_console.h"

int main()

{
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput,
0,
};
GPIO_PortInit(GPIO, 1U);


GPIO_PinInit(GPIO, 1U, 0XFFFFFFFFU , &led_config);
GPIO_PinWrite(GPIO, 1U,0XFFFFFFFFU, 0);
return(0);
}

When i am enabling all pin in a port, it was not working.

this was my issue,please solve it and answer it.

wanted to enable this port pins in a single line

 

0 Kudos
2 Replies

747 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Nivesha,

I suspect that the SDK driver does not provide the corresponding function to write ONE port, but GPIO hardware itself supports port writing.

You can use the code to set/clear one port:

1)set port direction:

GPIO->DIR[1]=0x33553355; //set the bit in direction reg will make the pin as GPIO output mode

2)write the PIN register
GPIO->PIN[1]=0x33553355; //set a bit will me make the pin High logic

for the line GPIO->PIN[1], the 1 is GPIO port number. For PIO0_x, it is 0, for  PIO1_x, it is 1.

 

Hope it can help you

BR

XiangJun Rong

 

 

737 Views
karthikjai
Contributor II

Thank You,

i tryed it and get the out put to enable all GPIO pins in board layout.

here i shown it below,

int main()
{

GPIO_PortInit(GPIO, 1U);
GPIO->DIR[1] = 0XFFFFFFFF;
GPIO->PIN[1] = 0XFFFFFFFF;

GPIO_PortInit(GPIO, 2U);
GPIO->DIR[2] = 0XFFFFFFFF;
GPIO->PIN[2] = 0XFFFFFFFF;

GPIO_PortInit(GPIO, 3U);
GPIO->DIR[3] = 0XFFFFFFFF;
GPIO->PIN[3] = 0XFFFFFFFF;

GPIO_PortInit(GPIO, 4U);
GPIO->DIR[4] = 0XFFFFFFFF;
GPIO->PIN[4] = 0XFFFFFFFF;

GPIO_PortInit(GPIO, 0U);
GPIO->DIR[0] = 0XFFFFFFFF;
GPIO->PIN[0] = 0XFFFFFFFF;


return(0);
}

 

0 Kudos