2020-01-12 10:39 PM
2020-01-12 11:13 PM
You don't need to do anything particular in the UART, just change the Tx pin's setting in respective GPIO_MODER to GPIO_Output, perform the operation you want, and then change it back to AF.
JW
2020-01-13 1:09 AM
Many thanks. I go it to work. HAL_UART2_Init() after the GPIO toggling?
2020-01-13 1:42 AM
I don't use Cube/HAL, but I don't see the reason to do so.
JW
2020-01-13 2:12 AM
Surely you must re-configure the UART2?
2020-01-13 6:50 AM
i don't see any reason why you would need to reconfigure it, you only mess with the GPIO registers not usart periephal registers.
i believe that at most, messing with the GPIO, would toggle the TE(bit 3 -> Transmit enable) or UE(bit 0 -> usart enable) in USARTx_CR1 register, but you would have to confirm it with debugger. i suspect that it wont do anything to usart registers in the end, and simple changing the GPIO back to Alternative function will make it work again.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.