cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA does not receive any bytes if started before peripheral is outputting

TomC
Senior

I have a distance laser outputting at 10KB/s (BAUD 921500).

I cannot miss any of the information output by the laser so want to turn it on after the UART DMA is turned on and listening.

Hence the steps are

  1. Start UART DMA
  2. Start laser

However, doing things in this order prevents any bytes from being received by the UART DMA.

I was wondering if anyone might have some insights into this problem, many thanks.

6 REPLIES 6
KnarfB
Principal III

There is no intrinsic timeout with your approach. UART receive using cyclic DMA waits forever for the next byte. Possibly "start laser" causes some garbage output on the serial line which puts the USART in an error state? Use a scope/LA to check and also the error bits.

If there are no such errors, show your code.

hth

KnarfB

Hi KnarfB thanks for your response,

It does appear that the laser is outputting some garbage that causes the DMA to lock up. If the DMA listens to the laser <20ms after it has begun outputting the DMA will lock up. I'm in the process of looking at the initial laser output (0-20ms) right now

If the behaviour is caused by garbage output do you have any suggestions to ensure the DMA is able to capture the first non-garbage byte that the laser outputs?

awesome thank you

Actually it does not appear that's there's any garbage data being output. This is confirmed empirically by doing the following

  1. Turn on lidar
  2. Wait 25ms
  3. Turn on DMA
  4. Observe data being recorded to DMA
  5. Turn off lidar
  6. Turn on lidar
  7. Observe data being recorded to DMA
  8. Repeat steps 5,6,7 n times

If garbage data were the problem I would expect turning the laser on and off to produce more garbage that causes the UART to error

Which STM32?​

> prevents any bytes from being received by the UART DMA.

How do you observe this, exactly?

Both ​UART and DMA do have status bits/bytes, check them (keeping in mind that debugging may be intrusive).

JW​