MCUXpresso Config Tools Swap Pins

cancel
Showing results for 
Search instead for 
Did you mean: 

MCUXpresso Config Tools Swap Pins

Jump to solution
97 Views
carstenhoffmann
Contributor I

Hi,

is there a simple way to swap GPIO pins?

Let's say I have already defined a LED output signal (label, identifier, direction...) and routed it to GPIO C11 P1_29.

For PCB layout reasons I want to change it to GPIO A6 P4_12.

Do I have to define A6 from scratch or is there an easier way?

 

Thanks and regards,

Carsten

 

0 Kudos
1 Solution
71 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Carsten
You want to change another GPIO to control a LED. Thus you need:
- HW: Swap GPIO on PCB
- SW: define A6 from scratch

I don't think there is other simple way.

Have a nice day,
Jun Zhang

View solution in original post

0 Kudos
3 Replies
31 Views
Babycat
Contributor II

Hi, 

I realized some pre-define lables are treated and generated the associated code in board.h file such: 

 

#define LED_GREEN_ON() \
GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */
#define LED_GREEN_OFF() \
GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */
#define LED_GREEN_TOGGLE() \
GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */

 

 However, with my own defined-lable: MY_GPIO_LED, it is not in board.h file but in pin_mux.h instead. 

How to make MY_GPIO_LED same as pre-defined lable? So that I can use the autogenerated code: MY_GPIO_LED_ON();

Thank you!

0 Kudos
61 Views
Petr_H
NXP Employee
NXP Employee

Hi,

If you are using the Pins tool from MCUXPresso Config tools, you have the option to not use directly the port and pin numbers, but you can refer to the pin using the identifier defined in the Pins tool.

The name of the identifier can be set in the 'Identifier' column (let's have 'MOTOR' as example): 

Petr_H_1-1617092120873.png

If it's specified, there is generated a set of defines for the pin into the pin_mux.h:

/* Symbols to be used with GPIO driver */
#define BOARD_MOTOR_GPIO GPIO                /*!<@brief GPIO peripheral base pointer */
#define BOARD_MOTOR_GPIO_PIN_MASK (1U << 7U) /*!<@brief GPIO pin mask */
#define BOARD_MOTOR_PORT 0U                  /*!<@brief PORT peripheral base pointer */
#define BOARD_MOTOR_PIN 7U                   /*!<@brief PORT pin number */
#define BOARD_MOTOR_PIN_MASK (1U << 7U)      /*!<@brief PORT pin mask */

Note: The BOARD_ prefix can be configured (or removed) in the settings of the functional group (using the function group configuration via the toolbar button).

The defines can then be referred from you application code:

...
GPIO_PinWrite(BOARD_MOTOR_GPIO, BOARD_MOTOR_PORT, BOARD_MOTOR_PIN, 1);
...

With such approach, you can freely change routing later in the Pins tool to other pin and you don't have to modify all references to it's port and pin numbers. You just need invoke the 'Update code' command in the Pins tool to update the generated code (pin_mux.c/h).

best regards

Petr Hradsky 

Config Tools Team

 

 

0 Kudos
72 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Carsten
You want to change another GPIO to control a LED. Thus you need:
- HW: Swap GPIO on PCB
- SW: define A6 from scratch

I don't think there is other simple way.

Have a nice day,
Jun Zhang

View solution in original post

0 Kudos