2016-10-13 05:43 PM
STM32CubeMX generates MX_GPIO_Init() which calls HAL APIs in following order,
static void MX_GPIO_Init(void){ __HAL_RCC_GPIO_CLK_ENABLE(); ... HAL_GPIO_Init();...
HAL_GPIO_WritePin();This calling order makes a problem when the pin should output high level from the beginning. Because the default output level is low, the pin outputs low between HAL_GPIO_Init() and HAL_GPIO_Write().My board has a sub CPU whose RESETn pin is connected to GPIO of STM32F7. Every time MX_GPIO_Init() is called, the sub CPU is reset because of this calling order.Calling APIs in following order fixes the problem. __HAL_RCC_GPIO_CLK_ENABLE(); ... HAL_GPIO_WritePin(); // call WritePin() before Init() ... HAL_GPIO_Init(); #stm32cubemx2016-10-14 01:35 AM
Hi sakurai.hiroshi,
Thank you for your feedback. The issue has been reported internally.-Syrine-2016-10-20 09:10 AM
Hello sakurai.hiroshi,
As farasI can see, this is corrected from version 4.13.
I test it using F745 SoC, and the generated code shows me the sequence you are expected.
I guess you are using a version before 4.13. Could you please let me know your cubeMX version ?
Could you let me know the SoC ref you are using ?
Thanks in advance.
Sirma
2016-10-21 12:10 AM
Hi Sirma,
I'm using STM32CubeMX 4.0 Please try attached ioc file. The code generated calls HAL_GPIO_WritePin after HAL_GPIO_Init. ________________ Attachments : proj.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtmG&d=%2Fa%2F0X0000000aWn%2FNzfOOMByjTrUUSNRub0GAFpxj4EMhtZklS2jDo4DKcc&asPdf=false2016-10-21 01:03 AM
Hello sakurai.hiroshi,
Great thanks for your ioc sharing.
I am checking it.
KR
Sirma
2016-10-21 06:42 AM
Hello sakurai.hiroshi,
you point out an interresting issue.
When only GPIO outputs are selected, the sequence is as you mention: Write->Init.
When there is a mixe between GPIO and alternate functions, then the sequence is inverted: Init->Write.
This has been forwarded to relevant team for deep analyze.
Thanks for your inputs.
KR
Sirma
2017-01-06 01:33 AM
Hello sakurai.hiroshi,
I want to thank you for your bug report.
I can confirm you that this bug will be resolved in CubeMX 4.19.
This version will be available soon.
KR
Sirma
2019-01-31 02:31 AM
Hi,
I am using the HAL drivers which are associated with the below release e.g. file
/**
* @file stm32l4xx_hal_def.h
* @author MCD Application Team
* @version V0.1.0
* @date 06-October-2014
* @brief This file contains HAL common defines, enumeration, macros and
* structures definitions.
*/
And see the exact issue which @Hiroshi Sakurai has mentioned.
Above you mentioned about the sequence which should be used in old releases
"
When only GPIO outputs are selected, the sequence is as you mention: Write->Init.
When there is a mixe between GPIO and alternate functions, then the sequence is inverted: Init->Write.
"
Is this valid for the release i am using V0.1.0
Regards,
Siddiq