2017-04-07 03:00 PM
I am trying to implement UART in DMA mode to transmit a simple string every time a push button is pressed.
So I have used CubeMX to generate the code and I have configured UART2 TX DMA in normal (not circular) mode and also no FIFO and no burst.
Whenever I run the code in debugging mode, I see the first time I attemp to send the string, it works ok and sends the string, but inside the DMA IRQ handler, it calls TxHalfCpltCallback and not TxCpltCallback and also UART gState will remain in BUSY mode so I can't use it to transmit no more string.
My Question is why it calls TxHalfCpltCallback and not TxCpltCallback? and how should I handle it (because HAL reference says it waits for sending the second half of buffer! what?)
And also, would sending the next half of data relase the gState of UART?
#uart #dmaSolved! Go to Solution.
2017-04-09 02:46 AM
OK, I have figured out how to solve this problem. as Nesrine M has replied in this thread:
https://community.st.com/0D50X00009XkfT3SAJ
, it is mandatory to enable HAL_UART_IRQHandler() , this is because uart irq handler function will reset gState.My
previous reply was my mistake to understan how HAL handles this, but I think ST must explicity mention in HAL driver that enabling HAL_UART_IRQHandler() is required.
2017-04-07 11:29 PM
Are you sure not to be using the double buffer mode for continuous sending of multiple memory blocks?
2017-04-08 02:43 AM
Where is double buffer mode to configure?
IDK about it!!!
I have attached a report of configurations, please take a look at DMA page
Thanks in advance
________________ Attachments : report.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyir&d=%2Fa%2F0X0000000bBY%2FUXp9XrHk3VyhdEY3foKaWweXwu6Fq6nJAV0Fb6RxDEA&asPdf=false2017-04-08 10:44 AM
The inference is that you're going to need to cross check the code that Cube generates, and determine WTF is going on in the HAL with all the circular logic and blocking, and whether things should be called in interrupt context or not.
One of the key problems seem to be the lack of 'dog fooding' within ST to use these tools to create anything moderately complicated or deliverable.
2017-04-08 10:54 AM
I have reviewed the code many times, but tge lack of efficient documents, prevents me to understand what tge hell is going on and how I should handle single/double buffer mode and what to do when half transmit call back is called. I will attach the code when ASAP
2017-04-08 12:39 PM
I can't support HAL/Cube code issues.
2017-04-08 03:38 PM
it's a bug, it enables HTIE regardless of user configurations with only one memory address, thus prevents transfer to complete.
2017-04-09 02:11 AM
Then go for low layer cube library (if confortable enough). What is the baudrate and sysclk value in the application? Which device?
2017-04-09 02:46 AM
OK, I have figured out how to solve this problem. as Nesrine M has replied in this thread:
https://community.st.com/0D50X00009XkfT3SAJ
, it is mandatory to enable HAL_UART_IRQHandler() , this is because uart irq handler function will reset gState.My
previous reply was my mistake to understan how HAL handles this, but I think ST must explicity mention in HAL driver that enabling HAL_UART_IRQHandler() is required.
2017-11-07 06:58 AM
For those looking for the location to 'fix' this issue as noted in the solution:
STM32CubeMX -> Configuration Tab -> USART# Oval Button -> NVIC Settings -> USART# Global Interrupt -> Enabled [Must Check if DMA in Normal Mode]