libftdi Archives

Subject: 3.8.1 Set TCK/SK Divisor (FT2232D)

From: John Oyler <john.oyler@xxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 1 Sep 2010 18:12:45 -0500
I know this sets the clock rate, but I have no idea what my ideal clock rate is.

Having hooked up to the digital oscilloscope, I don't know why it never occurred to me to run the windows software for this device. Compared against the (minimal) software of my own, the clock rate is definitely slower. I don't know how to use the scope, but eyeballing it each high half of a clock was about 4-5 times as long.

Here is my code (irrelevant portions omitted):

#define DIVIDE_BY 3

        buf[0] = 0x86;          /* command "set divisor" */
        /* valueL/valueH are (desired_divisor - 1) */
        buf[1] = (DIVIDE_BY - 1) & 0xff;
        buf[2] = ((DIVIDE_BY - 1) >> 8) & 0xff;
        if (send_buf(ftdic, buf, 3))  
                return -1;

Now, this is with a FT2232D that has a 6Mhz crystal wired up to it. Can anyone help me interpret what I'm currently setting the clock to?

The source code for the windows software is some sort of C#.NET abomination, and I'm having trouble understanding what it's really setting this to. It has a similar constant, and it does the bitwise stuff in the same manner. But it looks as if it's setting the divide-by to 60.


As most of the rest of my code is working as I should expect it to, I'm half convinced this is the answer. Or if not *the* answer, then at least a big piece of the puzzle.

And secondly, I'm still trying to understand how best to sync things up when reading the registers out of this. If I pump 0xaa's at the thing, I can do this in a while loop expecting a 2 byte reply that will eventually be non-0x00. But what happens if I get a 0x00fa back? At that point I should immediately try to read (with no command) 1 byte (should be 0xaa), and then jump into my "read registers" block, right? 

Thanks,
John O.






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


Current Thread