how to enable a port pins in a single line

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to enable a port pins in a single line

1,044件の閲覧回数
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 件の賞賛
返信
2 返答(返信)

1,000件の閲覧回数
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

 

 

990件の閲覧回数
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 件の賞賛
返信