What is the procedure to setup Uart Transmission in One shot mode with a DMA?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-29 11:16 AM
Hi guys,
for some reason I can't this working for the life of me.
I am trying to implement a DMA with Uart Transmission with a one shot, reason being is that I noticed with the DMA on circular mode it just transfers whatever is in the buffer even theres nothing in it so its just sending 0's. I want it to control the timing of when to transmit data, like once the buffer as a real value in it.
Nothing been working for me. Things i have tried are
- Initially the DMA is disabled for Uart Transmit
- Write to the Buffer not TDR but the buffer thats affiliated with the DMA
- Enable DMA for Uart Transmission
- Wait for TC flag to set
- Clear the TC flag
- Disable DMA buffer
However this lead to receiving garbage values on the other end.
The problems I have occurred is that TC flag gets stuck on the second send, or the transmissions sends twice and not once.
Any ideas?
- Labels:
-
DMA
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-29 1:39 PM
The procedure you described should work, although you need to set up the DMA and UART correctly. Note that you don't need to disable the DMA as it will disable itself when the transmission is complete.
There are many examples for UART + DMA you can follow. Here is one at random (since you didn't specify a chip or family):
> it just transfers whatever is in the buffer even theres nothing in it so its just sending 0's.
Why would it not transfer 0s? How can the DMA possibly know that a 0 value is invalid in your mind?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-29 1:47 PM
"you need to set up the DMA and UART correctly"
- I mean, this is true, I would assume so as when I put it in Circ mode it works as expected, and the Rx mode of the Uart is working perfectly
"that you don't need to disable the DMA as it will disable itself when the transmission is complete."
- This is true, correct. I dont have to
I am using the STM32H7 family.
Why would it not transfer 0s? How can the DMA possibly know that a 0 value is invalid in your mind?
Let me further explain, I didnt mean to say its invalid I mean its the not way I want it. Thats all.
I am using bare metal, so not sure how far ill get with HAL in that example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-29 1:48 PM
And just to further expand, that example has a buffer already filled. I am talking about when the initial buffer is empty and x time later the buffer will get filled eventually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-29 1:51 PM
and to futher explain, if I enable Circ mode, it works when the buffer is initially empty it will print zero, then when I access a function that populates the buffer with a '1' it will then print out 1's. In single shot mode, nothing works. It wont send the proper value and unexpected behavior happens
