Populate GPIO pin configuration

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Populate GPIO pin configuration

跳至解决方案
5,628 次查看
EugeneHiihtaja
Senior Contributor I

Hello !

Now if you need to manipulate with GPIO pin configuration during runtime ( change mode, input/output/Z)

I need to write definitions for pin manually:

/* Debug console RX pin: PORTC14 MUX: 3 */
#define DEBUG_CONSOLE_RX_PORT PORTC
#define DEBUG_CONSOLE_RX_GPIO GPIOC
#define DEBUG_CONSOLE_RX_PIN 14
#define DEBUG_CONSOLE_RX_PINMUX kPORT_MuxAlt3

But it seem to me it should be possible to export the same definitions from ConfigTool to pin_mux.h header file.

How I can activate this feature in latest MCUXpresso IDE ?

Regards,

Eugene

0 项奖励
回复
1 解答
5,027 次查看
EugeneHiihtaja
Senior Contributor I

Hi Jorge !

Yes, it generate right lines:

/* PORTC3 (pin 73) is configured as CMP1_IN1 */
PORT_SetPinMux(BOARD_INITPINSLOWPOWER_LPUART1_RX_PORT, BOARD_INITPINSLOWPOWER_LPUART1_RX_PIN, kPORT_PinDisabledOrAnalog);

/* PORTC4 (pin 76) is disabled */
PORT_SetPinMux(BOARD_INITPINSLOWPOWER_LPUART1_TX_PORT, BOARD_INITPINSLOWPOWER_LPUART1_TX_PIN, kPORT_PinDisabledOrAnalog);

Thank you !

Eugene

在原帖中查看解决方案

0 项奖励
回复
9 回复数
5,027 次查看
EugeneHiihtaja
Senior Contributor I

Hello !

I find one more missing definitions ( output ) from config tool.

For proper manipulation of GPIO pin , e.g configure port as GPIO port, manipulate with pin state and return this pin as peripheral pin

2 different "port" definition are reguired, GPIO_Type and PORT_Type.

But Config tool generates only PORT definition.

#define BOARD_INITPINS_SENSOR_I2C_SCL_PORT PORTA /*!<@brief PORT device name: PORTA */
#define BOARD_INITPINS_SENSOR_I2C_SCL_PIN 2U            /*!<@brief PORTA pin index: 2 */

Is any settings exists what can force Config tool for generate GPIO type as well.

#define BOARD_INITPINS_SENSOR_I2C_SCL_GPIO_PORT  GPIOA

Regards,

Eugene

0 项奖励
回复
5,028 次查看
EugeneHiihtaja
Senior Contributor I

Hi Jorge !

Yes, it generate right lines:

/* PORTC3 (pin 73) is configured as CMP1_IN1 */
PORT_SetPinMux(BOARD_INITPINSLOWPOWER_LPUART1_RX_PORT, BOARD_INITPINSLOWPOWER_LPUART1_RX_PIN, kPORT_PinDisabledOrAnalog);

/* PORTC4 (pin 76) is disabled */
PORT_SetPinMux(BOARD_INITPINSLOWPOWER_LPUART1_TX_PORT, BOARD_INITPINSLOWPOWER_LPUART1_TX_PIN, kPORT_PinDisabledOrAnalog);

Thank you !

Eugene

0 项奖励
回复
5,027 次查看
EugeneHiihtaja
Senior Contributor I

Hi Marek !

Yes this is problem. Not all pins have option (n/a, disabled). As result, they can be configured as GPIO pin and Z-state can't be generated if pin available in RoutedPins table.

You can see this pin has dimmed green color and already belong to Board_InitPins group.

And I try to put it to other group for be configured in Z state.

pin_configuration.png

0 项奖励
回复
5,027 次查看
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Eugene Hiihtaja

For the K82 the analog mode is CMP1_IN1:

/* Configure LPUART1 pins to Z state. */
PORT_SetPinMux(PORTC, 3, kPORT_PinDisabledOrAnalog); // RX
PORT_SetPinMux(PORTC, 4, kPORT_PinDisabledOrAnalog); // TX

pastedImage_2.png

So, that mode configuration is the one that you can use.

Regards

Jorge Alcala

0 项奖励
回复
5,027 次查看
EugeneHiihtaja
Senior Contributor I

Hi !

I'm using K82 MCU.

I would like to generate explicit code what put some gpio line to Z state.

So in some power modes, some gpio lined used as peripherals pins, after that in low power mode they should be set to Z state.

After that I will call it in proper places where transition between power modes implemented.

Regards,

Eugene

0 项奖励
回复
5,027 次查看
marek-trmac
NXP Employee
NXP Employee

Hi Eugene,

in Pins tool, open "Pins" view on the left side, and click on first column on the pin you want to configure. Typically each pin is possible to assign to several peripherals, so dialog with peripheral signal appears - see attached screenshot.Capture.PNG

Select check box (n/a,disabled) to configure pin to disabled state (the state is highlighted on the picture above).

Then open "Code Preview" view on the right side and check, whether generated code is what you expect. The code preview is refreshed automatically, so you can easily review each change.

Hope this helps.

Regards

Marek

Regards,
Marek


NOTE: If you find the answer useful, kindly click on [ACCEPT AS SOLUTION] button
0 项奖励
回复
5,027 次查看
EugeneHiihtaja
Senior Contributor I

Hi !

Yes, it work as expected and even better e.g groups and pin definitions.

But it seems to me it is problem to generate explicit settings for pin Z state.

/* Configure LPUART1 pins to Z state. */
PORT_SetPinMux(PORTC, 3, kPORT_PinDisabledOrAnalog); // RX
PORT_SetPinMux(PORTC, 4, kPORT_PinDisabledOrAnalog); // TX

Tool generate or Input/Output or no initialisation at all.

But before switching to low power mode I need to put some pins to "Analog" state.

How it can be done ?

Regards,

Eugene

0 项奖励
回复
5,027 次查看
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Eugene Hiihtaja

Could you clarify what MCU are you using in order to reproduce your issue?

Also, please consider that once that you have your specific functional group, then you have to call it when you need it in your code.

Regards

0 项奖励
回复
5,027 次查看
marek-trmac
NXP Employee
NXP Employee

Hi Eugene,

Config Tools (Pins) support runtime configuration using Functional Groups, see toolbar Capture.PNG

and click properties to define new functional group. Each group contains independent pins configuration and there is one C function generated for each group. You can call the function in runtime to switch the pins configuration.

Hope this helps

Regards Marek

Regards,
Marek


NOTE: If you find the answer useful, kindly click on [ACCEPT AS SOLUTION] button
0 项奖励
回复