Why doesn't the config tool use IOCON_PinMuxSet?

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

Why doesn't the config tool use IOCON_PinMuxSet?

Jump to solution
1,071 Views
rex_lam
Contributor IV

The MCUXpresso config tool generates code that configures the pins of an MCU. For example, the following code was generated by the tool:

    IOCON->PIO[0][22] = ((IOCON->PIO[0][22] &
                          /* Mask bits to zero which are setting */
                          (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
                         /* Selects pin function.
                          * : PORT022 (pin B12) is configured as USB0_VBUS. */
                         | IOCON_PIO_FUNC(PIO022_FUNC_ALT7)
                         /* Select Analog/Digital mode.
                          * : Digital mode. */
                         | IOCON_PIO_DIGIMODE(PIO022_DIGIMODE_DIGITAL));

Compare this to code from standalone SDK examples:

    const uint32_t port0_pin22_config = (/* Pin is configured as USB0_VBUS */
                                         IOCON_PIO_FUNC7 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    /* PORT0 PIN22 (coords: B12) is configured as USB0_VBUS */
    IOCON_PinMuxSet(IOCON, 0U, 22U, port0_pin22_config);

Why doesn't the config tool use IOCON_PinMuxSet? Is the config tool behaving correctly, and are there any plans to change the tool to generate consistent code with the standalone SDK examples?

0 Kudos
1 Solution
796 Views
Petr_H
NXP Employee
NXP Employee

Hi,

The Pins tool is able to generate both SDK function call or register writes.

The issue is that the SDK function (as it's visible in the code you pasted here) initializes all the features of the pin like Open drain, Slew rate or Input filter. In case you don't specify these features (which may mean you don't want to change them), the function cannot be used and the tool produces register writes code instead.

Best regards

Petr Hradsky

View solution in original post

0 Kudos
4 Replies
797 Views
Petr_H
NXP Employee
NXP Employee

Hi,

The Pins tool is able to generate both SDK function call or register writes.

The issue is that the SDK function (as it's visible in the code you pasted here) initializes all the features of the pin like Open drain, Slew rate or Input filter. In case you don't specify these features (which may mean you don't want to change them), the function cannot be used and the tool produces register writes code instead.

Best regards

Petr Hradsky

0 Kudos
796 Views
rex_lam
Contributor IV

Petr,

Thank you for the information. I experimented with the Pins tool and found out that explicitly setting each option will make the tool generate SDK function calls instead of register writes.

There is one issue I discovered. The default mode after reset is PullUp. For USB0_VBUS, the spec (table 891) says to set the mode to Inactive. So in the case of the Pins tool using register writes, the mode was not set correctly because it was not changed from default. I am guessing that the Pins tool does not know the required mode for USB0_VBUS and it is up to the user to configure the pin according to specs. Please let me know if that is not the case. The project template code in the SDK also uses register write without setting the mode to Inactive so that appears to be wrong.

Thanks again for your help.

Rex

0 Kudos
797 Views
Petr_H
NXP Employee
NXP Employee

Yes, exactly, when you set all the features explicitly, the SDK function is used. 

Could you please write which MCU are you using and if you have selected a board or just processor when you create the project? 

0 Kudos
797 Views
rex_lam
Contributor IV

Petr,

I apologize for not including that information before. I am using LPC54608 on LPCXpresso54608. I selected the LPCXpresso54608 board when I created the project.

Rex

0 Kudos