libftdi Archives

Subject: Re: Baud rate confusion

From: Jim Paris <jim@xxxxxxxx>
To: linux@xxxxxxxxxxxxxxxxx
Cc: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 20 Jan 2016 18:33:03 -0500
linux@xxxxxxxxxxxxxxxxx wrote:
> Using libftdi, I specify:
> 9600 baud to the library call - I see 0x4138 sent to the device - my
> DVM shows 96KHz (9600 "baud" x 20 bit positions per second) -
> consistent with the IR rates.
> 
> If I swap the baud/bitbang call order (so that the bitbang inherits
> the baud set in RS232 clocking), 9600 baud maps to 24.6KHz which I
> guess is 2.5 times - a factor of 2 different to the x5 factor
> observed elsewhere.

Hmm, I'm out of ideas, sorry.  As another test, you can figure out the
real bitrate by timing how long it takes to write data, rather than
relying on the DVM (which will depend on the bit pattern you're
writing).  The results are still fairly accurate (and can be improved
by writing more data).  For example:

https://gist.github.com/jimparis/d95375588e31d983dbcc

$ ./time 9600
Desired bitrate: 9600
Writing data..
100000 bits written in 10.368 seconds = 9645.0 bits per second
$ ./time 76000
Desired bitrate: 76000
Writing data..
100000 bits written in 1.30888 seconds = 76401.0 bits per second
$ ./time 1000000
Desired bitrate: 1000000
Writing data..
100000 bits written in 0.0997873 seconds = 1002131.9 bits per second

Jim

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread