HAL USART DMA buffer reset method?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-27 4:43 PM
Hi Community,
I find a method to reset a buffer of USART DMA Buffer.
because I use USART DMA basically.
​
my system is consist of android smartphone, bluetooth and microcontroller(STM32F407VET), PC
​
when I click a button that implemented in a android, some packet is send to the bluetooth RX
and Bluetooth TX that connected to micro controller USART3 RX.
​
than Received USART3 Data directly send to USART1 and I can see the packet in PC program.
(So... long)
​
I learned about HAL USART DMA is need a fixed buffer size.
so I designed the system the length of the packet is always fixed.
​
But! when the Bluetooth is connected, the packet is occurred by Bluetooth like
"Connected X" (X is MAC address of Bluetooth)
​
Due to the packet that I don't want, DMA buffer is shifted.
​
like under example.
​
ex)​
Normal State
​buffer size 5
send "12345" => receive​ "12345"
​
Abnormal state​
send "12345" => add packet "ab"=>receive​ "ab123"​
​
For this reason, I would like to ask community How to reset DMA buffer.
​
Of course, using a ring buffer is best way, but I'm not have a code that work normally, and other is I can't understand the code algorithms.
​
Ask for help...
​
Thank.
- Labels:
-
DMA
-
STM32CubeMX
-
STM32F4 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-28 12:57 AM
Thanks TJ,
what type is U1RxBufferPtrIN and U1RxBufferPtrOUT?
char readableU1(void) {
U1RxBufferPtrIN = U1RxBufSize - huart1.hdmarx->Instance->CNDTR;
return U1RxBufferPtrIN - U1RxBufferPtrOUT;
}
readableU1 is means that USART1 RX Channel is available?
It is not a clear buffer methods?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-28 2:03 AM
uint32_t U1RxBufferPtrIN ;
uint32_t U1RxBufferPtrOUT=0;
make your buffer size 2^N like 256 or 512 or 1024 or 2048 or 4096 bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-28 2:23 AM
Yes, use clear clearRxBuffer() to make the U1RxBufferPtrOUT equal to the DMA pointerIN , U1RxBufferPtrIN
then when you do readableU1() there return value will be Zero...

- « Previous
-
- 1
- 2
- Next »