cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G-DISCO and UART code generation

SHarr.2
Associate

Hello,

I am working with this board using STM32CubeIDE version 1.5.0. I would like to use the USART6 or UART7 peripheral. When I configure the UART 7 or USART6 peripherals from the .ioc file and generate the code I believe that the code generator should include a section to configure these peripherals in the MX_GPIO_Init function in main.c.

I believe that there should be some code generated that would include something like:

GPIO_InitStruct.Alternate = GPIO_AF8_UART7;

and a few other lines of code. After configuring these peripherals in the .ioc file however, the corresponding code does not appear in the MX_GPIO_Init function in main.c. I could add the code manually but the problem would be that an .ioc changes would overwrite this code I believe. Am I doing something wrong? I've attached the project file.

Thanks.

2 REPLIES 2
SHarr.2
Associate

Looking into this a bit more CUBEIDE appears to generate the MX_GPIO_Init code when UART7 or USART6 are in disabled mode but does not generate the UART handle and the UART_Init code. When the peripherals are enabled, it appears to generate the UART handle and the UART_Init code but not the corresponding MX_GPIO_Init code.

I added the missing code to the MX_GPIO_Init function and I can confirm that UART7 works as a result.

Khouloud ZEMMELI
ST Employee

Hi @SHarr.2​ ,

The IP GPIO Configuration is generated under stm32f7xx_hal_msp.c file, in your case in the void HAL_UART_MspInit(UART_HandleTypeDef* huart) function.

You can check it and you will find the "GPIO_InitStruct.Alternate = GPIO_AF8_UART7;" well generated.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thanks, Khouloud