0
votes

I'm trying to capture a signal much like UART communication.

This specific signal is composed by:

1 start bit(low)

16 data bits

1 stop bit (high)

From testing, I figured out that signal is about ~8-9μs / bit. This led me to believe that the baud is around 115.2kbps.

My frist idea was to try a "manual" approach, and wrote a small C program. Although I couldn't sample the signal at the proper timing.

From here, I decided to look for libraries that could do the job. I did try "termios" and "asio::serial_port" from boost, but those don't seem to be able to receive 16 bit characters.

Am I being naive trying to configure a 16 bit receiver? Does a "16 bit UART" even make sense?

Thanks!

-nls

1
Most UARTs don't support 16 data bits - you'll probably need to use a general purpose I/O line on whatever hardware you are using and implement a software UART from scratch. - Paul R
Maybe use a simple uC controller Dev Board for the time critical conversion. Here you should be able to implement your 16bit UART in software. For closer info check mikrocontroller.net/topic/85900 - Jonny Schubert
You can do this type of thing by "bit-banging" on an Arduino easily enough, see arduino.cc/en/Reference/SoftwareSerial and arduiniana.org/libraries/newsoftserial and also this one which is about SPI rather than RS232 but shows you the technique. - Mark Setchell
I tried using an Arduino board with Atmega328, but wasn't sure if the port manipulation was fast enough for 115.2kbps, and switched to Raspberry Pi. I'll read more read more deeply into "bit-banging". - nfls

1 Answers

4
votes

There's nothing fundamentally wrong with the idea of a UART which supports a 16-data-bit configuration, but I'm not aware of any which do. 8 or 9 is usually the limit.

If you're communicating with a device which only supports that configuration (what the heck kind of device is that?), your only real option is bit-banging, which would be best done by a MCU dedicated to the purpose. You are not going to get microsecond-accurate timing in user space on a multitasking operating system, no matter what libraries you bring to bear.

EDIT: Note that you could do this, more or less, with bit-banging from a dedicated kernel-space driver. But that would make the system nearly unusable. The whole reason UARTs exist is because the CPU has better things to do than poll a line every few microseconds.