cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_Transmit() works; HAL_UART_Transmit_IT() does nothing and breaks printf

cbcooper
Associate

I've got the NUCLEO-G491RE board and have it connected to my PC over the only USB port which is of course also used for the debugger.

Both printf() and HAL_UART_Transmit() work to send data to a terminal program on the PC, but I can't use polling for my communication (there's too much else going on).  If I call HAL_UART_Transmit_IT() it returns HAL_OK but doesn't actually transmit anything, and any subsequent calls to printf() or HAL_UART_Transmit() no longer do anything.

I'm assuming this is because this isn't a "real" UART but some kind of virtual UART that gets converted into USB commands that cooperate with the debugger.

Is there a way to use interrupt-driven communication over this (virtual) serial port?

Thanks,

Chris

 

12 REPLIES 12
cbcooper
Associate

Interesting - when configured as a virtual com port, LPUART1 talks on PA2 and PA3 but when configured as a regular LPUART1 it talks on PC0 and PC1.

I think I found the solution, I'll write it up here for the next poor person trying to figure it out:

1) Look at "Virtual Com Port" in the "BSP" section of the IOC and write down the parameters (especially baud rate)

2) Disable "Virtual Com Port"

3) Under "Connectivity" select LPUART1 and under Parameter Settings set Mode to Asynchronous and the other parameters as needed (e.g. baud rate)

4) Change the output pins of the LPUART1 from the default (PC0/PC1) to the alternate (PA2/PA3).  Notice that the LPUART1 section has a "GPIO Settings" that shows you the current pin selection but doesn't let you change it.  You have to look in the "Pinout view" and click on the desired pins (PA2 and then PA3) and it will give you a box to select the alternate use

5) Enable the "LPUART1 global interrupt" in the NVIC Settings of the LPUART1

 

Karl Yamashita
Principal

After seeing your code and I was about to reply, but you ended up beating me to it. But yeah, I never use any of ST's default BSP configuration on the Nucleo. 

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.