libftdi Archives

Subject: Re: Baud rate confusion

From: Alex Scarbro <alex.scarbro@xxxxxxxxxxxxxx>
To: "libftdi@xxxxxxxxxxxxxxxxxxxxxxx" <libftdi@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 23 Jan 2016 00:28:14 +0000
Hi, are you certain that BitBang mode as actually clocked by the baud rate generator?

There are some modes on the FTDI devices that are internally timed from a a fixed clock and independent of the baud rate generator.

Best regards,
Alex

On Friday, January 22, 2016, <linux@xxxxxxxxxxxxxxxxx> wrote:
Hi

I remembered that I'd got an RS232 level shifter sat at the bottom of a box in the garage hanging off an old microcontroller.

Strangely enough, if I run the chip in RS232 mode, it uses a correct baud rate and the line runs fine (at speeds of 300 baud up to 115200).

So it only seems to affect the bitbang mode :-(


Interestingly I spotted in the FTDI AN108 (MPSSE) that there is a command to enable/disable a x5 clock mode for the -H chips (page 23):

6.2 Enable Clk Divide by 5
0x8B
This will turn on the divide by 5 from the 60 MHz clock to give a
12MHz master clock for backward compatibility with FT2232D designs.

I have tried playing with this but it gives no joy (enter MPSSE, set divide by 5, set baud, enter bitbang, set baud).  I can only assume that the company who made the part (FTDI or otherwise) has screwed up somewhere along the line and somewhere mixed this in to conventional bitbang...

Thanks for your help.  Next stop, FTDI...


Andy

On 20/01/16 23:33, Jim Paris wrote:
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   


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


Current Thread