Pins Tool quirk: same configuration, different code is generated

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

Pins Tool quirk: same configuration, different code is generated

ソリューションへジャンプ
1,766件の閲覧回数
danielholala
Senior Contributor II

Hi again,

I'm fiddling with Pins Tools (MCUXpresso 11.4.0) and example code "led_blinky" from the LPC5526 SDK.

I added another GPIO output with "Invert" set to "disabled" as follows:

danielholala_0-1627136160567.png

Pins Tool generates this code (relevant parts only):

    gpio_pin_config_t LED_RED_config = {
        .pinDirection = kGPIO_DigitalOutput,
        .outputLogic = 0U
    };
    /* Initialize GPIO functionality on pin PIO0_7 (pin 6)  */
    GPIO_PinInit(BOARD_INITPINS_LED_RED_GPIO, BOARD_INITPINS_LED_RED_PORT, BOARD_INITPINS_LED_RED_PIN, &LED_RED_config);


    const uint32_t LED_RED = (/* Pin is configured as PIO0_7 */
                              IOCON_PIO_FUNC0 |
                              /* No addition pin function */
                              IOCON_PIO_MODE_INACT |
                              /* Standard mode, output slew rate control is enabled */
                              IOCON_PIO_SLEW_STANDARD |
                              /* Input function is not inverted */
                              IOCON_PIO_INV_DI |
                              /* Enables digital function */
                              IOCON_PIO_DIGITAL_EN |
                              /* Open drain is disabled */
                              IOCON_PIO_OPENDRAIN_DI);
    /* PORT0 PIN7 (coords: 6) is configured as PIO0_7 */
    IOCON_PinMuxSet(IOCON, BOARD_INITPINS_LED_RED_PORT, BOARD_INITPINS_LED_RED_PIN, LED_RED);

 

Now in Pins Tool I switch "Invert" to "Reset (Disabled)" (which should be the same configuration as before):

danielholala_1-1627136315487.png

Spot the difference? Disabled is in italics now.

The generated code, however, looks mighty different:

IOCON->PIO[0][7] =
        ((IOCON->PIO[0][7] &
          /* Mask bits to zero which are setting */
          (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_SLEW_MASK | IOCON_PIO_DIGIMODE_MASK | IOCON_PIO_OD_MASK)))

         /* Selects pin function.
          * : PORT07 (pin 6) is configured as PIO0_7. */
         | IOCON_PIO_FUNC(PIO0_7_FUNC_ALT0)

         /* Selects function mode (on-chip pull-up/pull-down resistor control).
          * : Inactive.
          * Inactive (no pull-down/pull-up resistor enabled). */
         | IOCON_PIO_MODE(PIO0_7_MODE_INACTIVE)

         /* Driver slew rate.
          * : Standard-mode, output slew rate is slower.
          * More outputs can be switched simultaneously. */
         | IOCON_PIO_SLEW(PIO0_7_SLEW_STANDARD)

         /* Select Digital mode.
          * : Enable Digital mode.
          * Digital input is enabled. */
         | IOCON_PIO_DIGIMODE(PIO0_7_DIGIMODE_DIGITAL)

         /* Controls open-drain mode.
          * : Normal.
          * Normal push-pull output. */
         | IOCON_PIO_OD(PIO0_7_OD_NORMAL));

 

I wonder why this is.

0 件の賞賛
返信
1 解決策
1,756件の閲覧回数
marek-trmac
NXP Employee
NXP Employee

Hi Daniel,

"Reset (Disabled)" means that configuration relies on after-reset value and does not affect the after reset configuration. This feature is not supported by "IOCON_PinMuxSet" function (this function always sets all bits), and so the generated code uses direct write to configuration register instead using SDK API.

Hope this helps

Regards,Marek

 

Regards,
Marek

元の投稿で解決策を見る

1 返信
1,757件の閲覧回数
marek-trmac
NXP Employee
NXP Employee

Hi Daniel,

"Reset (Disabled)" means that configuration relies on after-reset value and does not affect the after reset configuration. This feature is not supported by "IOCON_PinMuxSet" function (this function always sets all bits), and so the generated code uses direct write to configuration register instead using SDK API.

Hope this helps

Regards,Marek

 

Regards,
Marek