Skip to main content
Senior
September 13, 2017
Question

How to use STM32CubeMX's 'pin stacking' function

  • September 13, 2017
  • 7 replies
  • 7712 views
Posted on September 13, 2017 at 12:35

In the latest version, I find there is a 'pin stacking'  choice when configure a pin. But I can't find any description of this function. What's the purpose of this function and how it work?

#pin-stacking
    This topic has been closed for replies.

    7 replies

    Chris Jameson-Groves
    Associate II
    November 21, 2017
    Posted on November 21, 2017 at 11:13

    This appears to allow a pin to be assigned for multple purposes (for example GPIO and I2C). I was excited when I saw this feature as I expected it to generate seperate functions which can be called to simply switch which purpose you wish to use it for. However, at the moment when you select pin stacking and compare the generated code with the same project without pin stacking you can see that those pins gets absolutly nothing generated. Its affectivly the same as not assigning those pins at all.

    Hopefully this will be a feature in the near future?!!?

    ST Technical Moderator
    November 21, 2017
    Posted on November 21, 2017 at 13:45

    Hello,

    I will raise your feedback to CubeMx team.  All your suggestion are welcome.

    Best Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Chris Jameson-Groves
    Associate II
    November 21, 2017
    Posted on November 21, 2017 at 14:19

    Many thanks. Its great to see a company actively monitoring their forums for issues and suggestions

    I have found a few other issues/bugs. Should I post them in a new topic to report them?

    ST Technical Moderator
    November 21, 2017
    Posted on November 21, 2017 at 15:17

    Hello

    Jameson_Groves.Chris

    ,

    You can report your finding issues in the STM32 forum, then ST moderators will take in charge to answer you or raiseyour feedback/issues internally to the appropriate team.

    We appreciate your contribution as this will help us to improve our solutions.

    Best Regards,

    Imen.

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    stm32cube-t
    ST Employee
    November 27, 2017
    Posted on November 27, 2017 at 11:58

    Hello,

    The pin stacking function is currently introduced for board design purposes only. There is no effect on the generated code.

    It allows board designers to set all the possible pin configurations offer by a board design and that can be achieved through different solder bridge configurations on the board.

    Best regards/

    Chris Jameson-Groves
    Associate II
    November 27, 2017
    Posted on November 27, 2017 at 12:22

    It does effect the code generated as any stacked pins get nothing generated. I understand why it does this, but just wanted to point out that the statement 'There is no effect on the generated code' is incorrect.

    stm32cube-t
    ST Employee
    November 29, 2017
    Posted on November 29, 2017 at 09:01

    Hello Chris,

    Thanks for your feedback.

    I actually found two issues

    1/ Code is duplicated (using test.ioc attached)

    I used an instance of I2C1 and on one of the pin I stacked other signals.

    The following code is generated twice in the main.c and in the hal_msp.c file:

    /*Configure GPIO pin : PA9 */

    GPIO_InitStruct.Pin = GPIO_PIN_9;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

    GPIO_InitStruct.Pull = GPIO_PULLUP;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    2/ when a pin gets assigned stacked signals no “GPIO_InitStruct.Alternate = “ gets generated in MX_GPIO_Init (test_stackedpins.ioc)

    I guess this is the issue you are talking about, correct?

    I guess you would expect MX to generate at least the “GPIO_InitStruct.Alternate =�? the AF for the first signal being stacked?

    /*Configure GPIO pin : PA9 */

    GPIO_InitStruct.Pin = GPIO_PIN_9;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

    GPIO_InitStruct.Alternate = GPIO_AF2_TIM1;/** to generate

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    Thanks for your feedback,

    I will log the issue in our bug tracking system once I get your confirmation.

    ________________

    Attachments :

    test.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyBv&d=%2Fa%2F0X0000000b5R%2FkXNhG6kdiBRdo8lrAdToTTehLq1RPmrSsDIONFSfhFk&asPdf=false

    test_stackedpins.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxkL&d=%2Fa%2F0X0000000b5Q%2F5DhL_rSz5rZ7Tr_aU6gGGcswuRNGvF.3yvtXOAFaeyQ&asPdf=false