Redundant GPIO init

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

Redundant GPIO init

667 Views
JackNXP
Contributor I

I'm using MCXpressos Config 14.0 for RT1064 MCU. 

The generated code has

BOARD_InitBootPins() ->BOARD_InitPins() which calls
   GPIO_PinInit (config struct) for each configured GPIO, setting chip registers

It also creates

BOARD_InitBootPeripherals() ->BOARD_InitPeripherals() which calls  GPIOx_init() for each GPIO group which calls HAL_GpioInit(config) for each configured GPIO, creating a config struct from defines

HAL_GpioInit() converts the struct and calls GPIO_PinInit().

Is there a reason to do all that twice?

 

0 Kudos
Reply
5 Replies

632 Views
mayliu1
NXP Employee
NXP Employee

Hi @JackNXP ,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.

Could you please tell me of the versions of the MCUXPresso IDE and SDK lib.

Which SDK example or operation are you referring to? 

InitBootPins() is the default pin_mux initialization entry point generated by the config tool, while InitPins() represents the specific operations generated by the config tool based on the configuration.  

I did a test for your question.

IDE:  MCUXPresso IDE 25.06

SDK: SDK_2.x_EVK-MIMXRT1064 25.06

When I add an LPI2C1 peripheral by using the Peripherals Tool, the I2C pin initialization is performed by BOARD_InitPins() instead of BOARD_InitBootPeripherals().

mayliu1_0-1754883822931.png

mayliu1_1-1754883841545.png

Wish it helps you.
If you still have question about it, please kindly let me know. 

Best Regards
MayLiu

0 Kudos
Reply

625 Views
JackNXP
Contributor I

Thanks for the response. I'm using Config tools 14.0, as stated in the query, and SDK 2.13.0.

My question is specifically about GPIO pins, not other peripherals.

It occurred to me that perhaps I should only define the GPIOs with the Connfig Pins tab and not the Peripherals tab, but if I take them out of Peripherals then BOTH of the generated GPIO pin initializations are removed.

0 Kudos
Reply

606 Views
danielholala
Senior Contributor II

It occurred to me that perhaps I should only define the GPIOs with the Connfig Pins tab and not the Peripherals tab, but if I take them out of Peripherals then BOTH of the generated GPIO pin initializations are removed.

I agree, you should only define the GPIOs with the "Pins" tool. That's the way I do it and the tool correctly creates initialization code. 

Maybe "calling initialization" is not enabled. This is what is my "Pins" tool looks like:

danielholala_0-1754988489951.pngdanielholala_1-1754988502041.png

Cheers.
Daniel

 

0 Kudos
Reply

592 Views
JackNXP
Contributor I

You're right, that does work. Not sure what I did wrong before. The config Peripherals tool does show a warning that GPIOs are not initialized, but the BOARD_InitPins() code does get built to do the job.

Saves about 2KB flash in my app.

Thanks.

0 Kudos
Reply

612 Views
mayliu1
NXP Employee
NXP Employee

Hi @JackNXP ,

Thanks for your updated information.

If you have any question about Pins Tool, I think you can refer to the MCUXpresso Config Tools User's Guide (IDE) 

There are more detail description.

Wish it helps you.

Best Regards

MayLiu

0 Kudos
Reply