cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H747I-DISCO Virtual Com USART Example

Louie88
Associate III

Hi,

If I understand right USART1 is used in STM32H747I-DISCO board for VCOM. I could not find any example for my board. I would like to want for an 8-byte host command using:

HAL_UART_Receive_IT(&huart1, hostCommand.buffer, 8);

 Once a command is received then I process it, I create the answer and wait for the next command. So simple. 

Noe: on CN13 pin 13 I see the command from my PC on scope, but the HAL_UART_RECEIVE_IT() never receives anything. 

Can sombody send me a short example?

Thanks,

Louie

26 REPLIES 26

Okay I did not know that. This is why I originally asked for an example app. I will try it using your way.

Thanks,

Louis

The examples in CubeIDE/CubeMX would illustrate that.

 

void USART1_IRQHandler(void) // gets called per byte/interrupt
{
  HAL_UART_IRQHandler(&huart1); // calls into HAL, it works the buffering and calls your call-back when complete
}


void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) // call from HAL_UART_IRQHandler
{
  // Do something with the filled buffer
  ..

  HAL_UART_Receive_IT(&huart1, hostCommand.buffer, 8); // initate again (returns immediately)
}


void HAL_UART_ErrorCallback(UART_HandleTypeDef *UartHandle)
{
  Error_Handler(); // or manage failure
}

main()
{
  ..

  HAL_UART_Receive_IT(&huart1, hostCommand.buffer, 8); // start (returns immediately)

  while(1);
}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

However I noticed the followings:

  • TouchGFX Created the project in C:\TouchGFXProjects\RCTDigitalClock folder which is out of my default workspace (C:\Users\[UserName]\STM32CubeIDE\workspace_1.17.0\RCTDigitalClock . 
  • TouchGFX Created a `STM32CubeIDE` folder with CM4 and CM7 folders.
  • TouchGFX Created a `STM32H747I-DISCO.ioc` file. Why not RCTDigitalClock.ioc?

  • The first one is normal.
  • The second one is normal.
  • The third one has been like this since ST acquired TouchGFX. This is very annoying because if you have several TGFX projects using the same board, you can only import 1 at a time. This is because STM32CubeIDE does not allow the same project name to be opened simultaneously. Surprisingly, to this day, ST still can't seem to fix this annoyance. Here is a video that shows how to rename the projects to a useable name including the IOC file. 

STM32F429I-DISCO & TouchGFX Setup 

 

 


When I enabled the USART1 then STM32CubeMX automatically created PB7 as Rx pin. This is the bug or issue or whatever you call it. This was teste at least 20 times.

This is not a bug. I get the same results when enabling USART1 from a TGFX project. Now this could be because the IOC file was generated by TGFX, not by STM32CubeIDE. As I said before, you can override and select the available Rx pins for USART1.

But, if you start a new board project in STM32CubeIDE/CubeMX, and not a TGFX project, it gives you an option to initialize default configurations. When you enable default configurations, then PA9 and PA10 are selected for USART1.

 

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.

@Andrew Neil wrote:

The examples in CubeIDE/CubeMX would illustrate that.


Apparently not for that exact board:

AndrewNeil_0-1738084809661.png

 

Thanks Tesla DeLorean, this is what I really asked for. 

Louis

 

Louie88
Associate III

Thanks for the demo.

Louis