2016-12-07 10:16 AM
Hello !
I did implement a fast transmit queue successfully for serial port printing. That works well with a development board. But in my real circuit, the TX pin is driving the LED of an opto-isolator. The result is that it still works but it inserts a faulty character after each completed DMA transfer. I found why: when the transmission completes, the tx pin go to high impedance state instead of continuing to drive a 1. So the LED is not driven and it appears like a 1 on the other side. Because the print buffer is often full, the high impedance state duration is very short, 15us. With 115200 baud it looks like a valid zero while it is just the time it takes to re-enable the UART in the interrupt. I could add a fix with a pull-up resistor, but this have serious drawback in the application context. I am looking to find a firmware way to do it. This is roughly how I am using the HAL drivers:
The HAL_UART_Init() is called before starting the main loop.
The HAL_UART_Transmit_DMA() is called when a print buffer is ready.
The HAL_UART_TxCpltCallback() is called by the DMA after transfer complete, and from it, I call immediately HAL_UART_Init() again while I set a flag to ask the main loop for checking if a new print buffer is ready.
Thank you !
#hal-uart-dma-transmit-keep-tx-pin-enabledSolved! Go to Solution.
2016-12-07 10:35 AM
The problem is caused by your second call to HAL_UART_Init(). This only needs to be done once at system intialization, not after every message transmission. Is there a reason why you are doing that?
2016-12-07 10:35 AM
The problem is caused by your second call to HAL_UART_Init(). This only needs to be done once at system intialization, not after every message transmission. Is there a reason why you are doing that?
2016-12-07 11:52 AM
Hi Bauch !
Thanks a lot for your answer ! I removed the extra calls to HAL_UART_Init() and the problem is gone. I do not remember exactly in the learning/debugging process I followed where I put this in, but at some point it solved a problem. I can see now that is it not necessary anymore. Thanks again, you made my day !