Skip to main content
RPhil
Associate
March 2, 2020
Question

extra byte in front of USART buffer received with DMA

  • March 2, 2020
  • 3 replies
  • 1134 views

I have inherited code that received 1400 bytes over a 2mbps serial link. I've increased that to 1892 bytes and on occasion (not always, but frequently enough to be annoying) I receive my buffer "shifted" by one byte and a garbage byte for byte 0 in the buffer. I can shift the data "left" by one byte in a loop and the buffer is correct.

Before enabling DMA I make sure to read the USART until RXNE is cleared.

Anyone else ever seen this and hopefully have a solution?

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
March 2, 2020

Which STM32?

> Before enabling DMA I make sure to read the USART until RXNE is cleared.

Does this "before enabling DMA" include a clear/set cycle for USART_CR3.DMAR?

JW

RPhil
RPhilAuthor
Associate
March 2, 2020

STM32F072

It did not include a clear of DMAR before its set but now it does. Alas, that doesn't seem to help.

Tesla DeLorean
Guru
March 2, 2020

RXNE being clear doesn't mean that the USART isn't in the middle of receiving something.

Should perhaps correlate these events with data as observed externally via a logic analyzer or secondary capture method.

Is this byte random, zero, what exactly?

Does your protocol permit for synchronization? So for example it can recognize the start of the packet, and recover from extra bytes or byte loss.

Is this signal multiplexed? ie RS-485, or otherwise sharing a single wire using a half-duplex protocol, or transmission medium?

Check also for noise, parity, or framing errors.

Perhaps you can enable RE (receive enable) after configuring the DMA transaction.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..