2

I'm trying to transmit data between 2 Raspberry Pi's (unidirectionally) with Raspbian via UART at 4Mbps. I'm using UART0 (BCM2835 Peripherals page 175).

I have successfully configured the UART clock source so I am able to transmit/receive at such a high speed, and indeed it works. I can send bytes and receive them correctly at the other side.

However, if I try to do a continuous transfer of data, a few bytes are lost (~2%) so I guess I'm overflowing a buffer on reception (because up to 1Mbps, continuous transmission works fine).

As far as I know, there are two buffers on reception, the hardware buffer which in case of Raspberry Pi's UART0 is 16 bytes and the software buffer on main memory. Kernel moves data from hardware buffer to software buffer and my application takes data from there.

Is there any way to know which of those two buffers overflowed? If so, how?

Thanks!

3
  • 2
    The hardware buffer is probably overflowing. At 4 Mbps, it fills up every 32 microseconds; servicing that reliably is tough.
    – user149341
    Dec 5, 2014 at 18:52
  • But, is there any way to prove it? Any FLAG or similar? By the way, since it's 8N1, there are 10 bits per byte (8 + 1 start + 1 stop) so I think it would take ~40 microseconds for the buffer to fill up. Not very different from 32, though. Thanks. Dec 5, 2014 at 19:01
  • Try using the TIOCGICOUNT ioctl() on the open serial port file descriptor. Among the counter stats are receive overruns and buffer overruns. But one user reports difficulty in using that ioctl(): stackoverflow.com/questions/11791813/…
    – sawdust
    Dec 6, 2014 at 23:38

1 Answer 1

3

The issue got solved for me by using Hardware Flow Control (CTS & RTS). At higher speeds, you must need to use the HSUART (UART with DMA capabilities). If your serial-port supports 16550A or similar, you can configure CONFIG_8250, CONFIG_DW, CONFIG_DMA in your linux kernel and start using DMA-capable UART. I have been working on High-Speed UART (HSUART) with baud rates as high as 3M/4M using h/w flow control without any issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.