2017-03-06 01:42 PM
There is an extra 'else' at the end of UART_DMATransmitCplt function which prevents the HAL_UART_TxCpltCallback to be called in normal (non-circular) mode
[...]
}
/* DMA Circular mode */
else
{
HAL_UART_TxCpltCallback(huart);
}
Compare to UART_DMAReceiveCplt which ends normally with
[...]
}
HAL_UART_RxCpltCallback(huart);
Solved! Go to Solution.
2017-03-07 01:45 AM
Yes, Jan, you're right.
HAL_UART_TxCpltCallback
() in DMA normal mode will be called after TC interrupt will be raised (this means UART interrupt has to be enabled).It is not a bug : this has been implemented for ensuring that user callback is not executed while last data was still on transmitting (please consider that UART_DMATransmitCplt() is called when DMA has loaded last data in TDR, but data transmission is not completed yet).
Without this check, if in user callback, user wants for example to disable USART block, it might lead to last data not properly transmitted.
Regards
Guenael
2017-03-06 02:16 PM
Maybe that is not the bug that prevents
HAL_UART_TxCpltCallback to be called, as the DMA transfer ends before the UART transfer?
In any case, does
HAL_UART_TxCpltCallback get called for anyone after a DMA transfer?
2017-03-06 02:54 PM
I have found the following workaround / solution: one has to activate UART global interrupt in cube even if all transfers are done using DMA.
Not sure it is a feature or a bug, hope it helps!
2017-03-06 05:22 PM
Isn't
https://community.st.com/0D50X00009XkYAlSAN
andhttps://community.st.com/0D50X00009XkYAlSAN
a related information?JW
2017-03-07 01:45 AM
Sure, thank you. I had more or less discovered this by trial and error [+ code inspection]. I was maybe a bit too quick to post is as bug. Just comparing the code of the two functions and the asymmetric behavior, I was convinced it was a bug that survived for too long.
General remarks. I am new to the platform and I find Cube + HAL refreshing comparing to my old platform. On top of great hardware. Definitely new to this community / forum.
2017-03-07 01:45 AM
Yes, Jan, you're right.
HAL_UART_TxCpltCallback
() in DMA normal mode will be called after TC interrupt will be raised (this means UART interrupt has to be enabled).It is not a bug : this has been implemented for ensuring that user callback is not executed while last data was still on transmitting (please consider that UART_DMATransmitCplt() is called when DMA has loaded last data in TDR, but data transmission is not completed yet).
Without this check, if in user callback, user wants for example to disable USART block, it might lead to last data not properly transmitted.
Regards
Guenael