2017-03-21 10:48 AM
Hi STM32 Support Team,
I have an existing STM32CubeMX project for the Nucleo-F303RE board which uses UART2. In the project the pins PA2 (Tx) and PA3 (RX) are configured as alternate function pins. In the old code (probably generated with V4.x) I could see that the pins were correctly initialized, file main.c, function MX_GPIO_Init: /*Configure GPIO pins : USART_TX_Pin USART_RX_Pin */
GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);�?�?�?�?�?�?�?
Now, I am using a newer version of STM32CubeMX (V.4.0 and also newer libraries) and the above mentioned code is missing! Also, the TX pins is showing a low level in idle state. (I would have expected a high level.)
Can you confirm this issue? Is this an intentioned feature?
Regards,
michaeLPS at developmentteam: I would be very helpful if you would enclose in all auto-generated fils which STM3CubeMx was used and which libraries were involved.
#uart #stm32cubemx2017-03-22 01:40 AM
Hello michaeL ,
Please share your .ioc file, I will report internally your issue for further check.
Imen
2017-03-22 04:21 AM
Hello
DAHMEN.IMEN
,I just uploaded theIOC file to
https://community.st.com/servlet/JiveServlet/downloadBody/1418-102-1-1712/UART_test.ioc.zip
.When I generate code with STM32CubeMX V4.20 in the file main.c the above code snippet is missing.
michaeL
2017-07-06 09:29 AM
Hello
Kotthaus.Michael
,I would like to thank you for your feedback.
I used a CubeMX4.1 to reproduce your symptoms, and the only way to have the code you mention, is to select the F303 SoC, and select PA2 and 3 as USART2_TX and RX, modify the label with USART_TX and RX, and then the GPIO code is generated as following:
/*Configure GPIO pins : USART_TX_Pin USART_RX_Pin */
GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF7_USART2; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);Which is the same as your.
But doing this, the UART IP initialisation is not generated.
I test with latest cube version (ver 4.21) and I can generate the same code
If you want to generate the UART initialisation code, you have to select it in the IP list.
But then the gpio init code will not be generated.. they are exclusive.
To have the high level, I guess you have to configure the pull-up in GPIO configuration panel, go under GPIO Settings tab and select pull-up.
Hope it help
Kind regards
Sirma
2017-08-25 04:11 AM
Hello
Kotthaus.Michael
,What I wrote in my last comment is slightly incorrect.
Actually, in the main.c, you can see either the GPIO or UART init code.
However, when the UART IP is selected, the UART init code hide the GPIO init.
You can go dowm into theHAL_UART_MspInit function to see GPIO config.
Hope it clarify.
Kind regards
Sirma
2017-08-25 07:08 AM
Thank you, Sirma, for the additional Information.
The code which I originally posted related to the CubeMXVersion were it was all right.
The bad issue which I mentioned was noticed at V.4.20.0.
If I understood you correctly with your statement
'I test with latest cube version (ver 4.21) and I can generate the same code'
it seems to be corrected.
Regards,
michaeL