libftdi Archives

Subject: Re: libftdi-1.0: More patches

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 5 Sep 2011 14:22:06 +0200
>>>>> "Thomas" == Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> writes:

    Thomas> Hi Uwe, On Friday, 2. September 2011 16:49:00 Uwe Bonnes wrote:
    >> The other basic is how this bits get stuffed in the USB request. I
    >> didn't find any documentation about it. AN_120 is not explicit. Have
    >> you more information?
    >> 
    >> I wrote the code with a strong look at the corresponding calculations
    >> in /usr/src/linux/drivers/usb/serial/ftdi_sio.c and a test with the
    >> scope.  For the cases I tested, I saw somehow sensible
    >> results. However with the RS232 pattern you can't easily measure
    >> exact frequency with the scope.
    >> 
    >> What are your doubts? A slight misscalcuation and bad rounding in my
    >> code or values really far off the set value. The last case I can
    >> easily test with the scope. Perhaps tell the setting that you expect
    >> a bigg error.  It is quite easy to test now with examples/serial.

    Thomas> Some (lower) baud rates get rounded and I can easily adjust the
    Thomas> unit test for that.

Where are your reference values from?

    Thomas> For some chips the data written to "value" and "index" changes a
    Thomas> lot.  I'll come up with examples in the afternoon.

One fractional bit is at 0x100 of index. The other fractional bits are
0x8000 and 0x4000 of value. So a small change in baudrate might cause huge
changes in index/value

    Thomas> If you can aknowledge me that the written USB data looks sane,
    Thomas> I'm willing to accept the patch even though I can't verify it
    Thomas> myself.

Perhaps the unit test should look at devisor, fractional bit and clock
pre-divider separate. 
Divisor = value & 0x3ff
Encoded Fractional bits = (index & 0x100)?4:0 + value >>12
clk = (index & 0x100)? 120 MHz: 48 MHz

Then difference get more readable.
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

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

Current Thread