Baud rate confusion

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Baud rate confusion

linux
Hi

I am trying to get lirc working with my Adafruit FT232H device and
having some problems with getting the clock speed (baud) correct.

I'm trying to transmit a carrier frequency of 38KHz which is turned on
and off based on the IR pattern to transmit.

I've created a separate program from LIRC to investigate this which
simply opens the device, sets bit bang mode, sets the baud rate, and
writes a block of 4k alternating 0xff / 0x00.

I'm driving an IR LED and I have a receiver which will print out the
duration it detects the 38KHz carrier for if the frequency is close.

I'm using libftdi-HEAD-c4c9f0a from a few days ago.

If I provide a baud rate of 3800 to ftdi_set_baudrate then that for some
reason gives me the required 72K bits / second transmission rate.  This
is completely at odds with any docs I can find or the LIRC code.

As an experiment I tried building the same program against the FTDI D2XX
libraries which the docs say multiplies the rate up by 16.  But to get
that to give me the correct baud rate, I have to pass 15200 as the
argument to FT_SetBaudRate.

USB sniffing shows that ultimately both of these calls result in the
same value being passed down to the chip.

Can anyone help me understand why I have such a seemingly bizarre bit
rate being used by this device?
I had some eeprom issues initially with the device; is it possible that
the eeprom contents can affect the baud rate like this?
Or have I bought a fake FTDI device which doesn't operate as the genuine
ones do?

TIA for any ideas!
Andy

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

Jim Paris
[hidden email] wrote:

> Hi
>
> I am trying to get lirc working with my Adafruit FT232H device and
> having some problems with getting the clock speed (baud) correct.
>
> I'm trying to transmit a carrier frequency of 38KHz which is turned
> on and off based on the IR pattern to transmit.
>
> I've created a separate program from LIRC to investigate this which
> simply opens the device, sets bit bang mode, sets the baud rate, and
> writes a block of 4k alternating 0xff / 0x00.
>
> I'm driving an IR LED and I have a receiver which will print out the
> duration it detects the 38KHz carrier for if the frequency is close.
>
> I'm using libftdi-HEAD-c4c9f0a from a few days ago.
>
> If I provide a baud rate of 3800 to ftdi_set_baudrate then that for
> some reason gives me the required 72K bits / second transmission
> rate.  This is completely at odds with any docs I can find or the
> LIRC code.

I'm not sure I exactly follow your numbers here.

For a 38KHz carrier, wouldn't you want 76Kbits/second transmission
rate?  I assume 72Kbits was a typo?

You're saying that you need to provide a baudrate of 3800, which means
that it's apparently getting scaled up by (76000 / 3800) = 20
with the libftdi version.

> As an experiment I tried building the same program against the FTDI
> D2XX libraries which the docs say multiplies the rate up by 16.  But
> to get that to give me the correct baud rate, I have to pass 15200
> as the argument to FT_SetBaudRate.

By correct baud rate, you mean it's getting scaled up by (76000 /
15200) = 5 in the D2XX version?  So you're not seeing the baudrate get
multiplied by 16 in either situation?

> USB sniffing shows that ultimately both of these calls result in the
> same value being passed down to the chip.

What is the value?

> Can anyone help me understand why I have such a seemingly bizarre
> bit rate being used by this device?
> I had some eeprom issues initially with the device; is it possible
> that the eeprom contents can affect the baud rate like this?
> Or have I bought a fake FTDI device which doesn't operate as the
> genuine ones do?

Not sure, but it sounds like you have a factor of 4 discrepency
between D2XX (scaling by 5?) and libftdi (scaling by 20?).  I also
saw this mystery factor of 4, with a FT230X in bitbang mode.  For 38
KHz IR, my code uses:

#define CARRIER 38400

  ftdi_set_bitmode(&ftdic, 1, BITMODE_BITBANG);
  ftdi_set_baudrate(&ftdic, (CARRIER * 2 / 16) / 4);

The / 4 was just something I determined experimentally and never dug
into.

Jim

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

linux
Hi

On 20/01/16 03:06, Jim Paris wrote:

> [hidden email] wrote:
>> Hi
>>
>> I am trying to get lirc working with my Adafruit FT232H device and
>> having some problems with getting the clock speed (baud) correct.
>>
>> I'm trying to transmit a carrier frequency of 38KHz which is turned
>> on and off based on the IR pattern to transmit.
>>
>> I've created a separate program from LIRC to investigate this which
>> simply opens the device, sets bit bang mode, sets the baud rate, and
>> writes a block of 4k alternating 0xff / 0x00.
>>
>> I'm driving an IR LED and I have a receiver which will print out the
>> duration it detects the 38KHz carrier for if the frequency is close.
>>
>> I'm using libftdi-HEAD-c4c9f0a from a few days ago.
>>
>> If I provide a baud rate of 3800 to ftdi_set_baudrate then that for
>> some reason gives me the required 72K bits / second transmission
>> rate.  This is completely at odds with any docs I can find or the
>> LIRC code.
> I'm not sure I exactly follow your numbers here.
>
> For a 38KHz carrier, wouldn't you want 76Kbits/second transmission
> rate?  I assume 72Kbits was a typo?
Yes it was a typo, I seem to have a mental block about typing 76 for
some reason.

> You're saying that you need to provide a baudrate of 3800, which means
> that it's apparently getting scaled up by (76000 / 3800) = 20
> with the libftdi version.
>
>> As an experiment I tried building the same program against the FTDI
>> D2XX libraries which the docs say multiplies the rate up by 16.  But
>> to get that to give me the correct baud rate, I have to pass 15200
>> as the argument to FT_SetBaudRate.
> By correct baud rate, you mean it's getting scaled up by (76000 /
> 15200) = 5 in the D2XX version?  So you're not seeing the baudrate get
> multiplied by 16 in either situation?
Yes except that the FTDI D2XX example code and docs say that in bit bang
mode it gets scaled up by 16 not 5.
>> USB sniffing shows that ultimately both of these calls result in the
>> same value being passed down to the chip.
> What is the value?
It is 0x4315 which according to the FTDI docs is a sub integer divisor
of 0.5 and a divisor of 0x315.

If I request 9600 baud, the values which appear here match the values in
the FTDI docs for serial port baud rates.

>> Can anyone help me understand why I have such a seemingly bizarre
>> bit rate being used by this device?
>> I had some eeprom issues initially with the device; is it possible
>> that the eeprom contents can affect the baud rate like this?
>> Or have I bought a fake FTDI device which doesn't operate as the
>> genuine ones do?
> Not sure, but it sounds like you have a factor of 4 discrepency
> between D2XX (scaling by 5?) and libftdi (scaling by 20?).  I also
> saw this mystery factor of 4, with a FT230X in bitbang mode.  For 38
> KHz IR, my code uses:
>
> #define CARRIER 38400
>
>    ftdi_set_bitmode(&ftdic, 1, BITMODE_BITBANG);
>    ftdi_set_baudrate(&ftdic, (CARRIER * 2 / 16) / 4);
>
> The / 4 was just something I determined experimentally and never dug
> into.
The libftdi code multiplies the baud you request by 4 if bitbang is
enabled.  Not quite sure how this relates to the *16 that the FTDI code
but it does at least explain why the libftdi baud parameter is 1/4 of
the equivalent D2XX baud parameter.

thanks
Andy
>
> Jim
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to [hidden email]
>
>  


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

Jim Paris
[hidden email] wrote:

> Hi
>
> On 20/01/16 03:06, Jim Paris wrote:
> >[hidden email] wrote:
> >>Hi
> >>
> >>I am trying to get lirc working with my Adafruit FT232H device and
> >>having some problems with getting the clock speed (baud) correct.
> >>
> >>I'm trying to transmit a carrier frequency of 38KHz which is turned
> >>on and off based on the IR pattern to transmit.
> >>
> >>I've created a separate program from LIRC to investigate this which
> >>simply opens the device, sets bit bang mode, sets the baud rate, and
> >>writes a block of 4k alternating 0xff / 0x00.
> >>
> >>I'm driving an IR LED and I have a receiver which will print out the
> >>duration it detects the 38KHz carrier for if the frequency is close.
> >>
> >>I'm using libftdi-HEAD-c4c9f0a from a few days ago.
> >>
> >>If I provide a baud rate of 3800 to ftdi_set_baudrate then that for
> >>some reason gives me the required 72K bits / second transmission
> >>rate.  This is completely at odds with any docs I can find or the
> >>LIRC code.
> >I'm not sure I exactly follow your numbers here.
> >
> >For a 38KHz carrier, wouldn't you want 76Kbits/second transmission
> >rate?  I assume 72Kbits was a typo?
> Yes it was a typo, I seem to have a mental block about typing 76 for
> some reason.
> >You're saying that you need to provide a baudrate of 3800, which means
> >that it's apparently getting scaled up by (76000 / 3800) = 20
> >with the libftdi version.
> >
> >>As an experiment I tried building the same program against the FTDI
> >>D2XX libraries which the docs say multiplies the rate up by 16.  But
> >>to get that to give me the correct baud rate, I have to pass 15200
> >>as the argument to FT_SetBaudRate.
> >By correct baud rate, you mean it's getting scaled up by (76000 /
> >15200) = 5 in the D2XX version?  So you're not seeing the baudrate get
> >multiplied by 16 in either situation?
> Yes except that the FTDI D2XX example code and docs say that in bit
> bang mode it gets scaled up by 16 not 5.
> >>USB sniffing shows that ultimately both of these calls result in the
> >>same value being passed down to the chip.
> >What is the value?
> It is 0x4315 which according to the FTDI docs is a sub integer
> divisor of 0.5 and a divisor of 0x315.
>
> If I request 9600 baud, the values which appear here match the
> values in the FTDI docs for serial port baud rates.
> >>Can anyone help me understand why I have such a seemingly bizarre
> >>bit rate being used by this device?
> >>I had some eeprom issues initially with the device; is it possible
> >>that the eeprom contents can affect the baud rate like this?
> >>Or have I bought a fake FTDI device which doesn't operate as the
> >>genuine ones do?
> >Not sure, but it sounds like you have a factor of 4 discrepency
> >between D2XX (scaling by 5?) and libftdi (scaling by 20?).  I also
> >saw this mystery factor of 4, with a FT230X in bitbang mode.  For 38
> >KHz IR, my code uses:
> >
> >#define CARRIER 38400
> >
> >   ftdi_set_bitmode(&ftdic, 1, BITMODE_BITBANG);
> >   ftdi_set_baudrate(&ftdic, (CARRIER * 2 / 16) / 4);
> >
> >The / 4 was just something I determined experimentally and never dug
> >into.
> The libftdi code multiplies the baud you request by 4 if bitbang is
> enabled.  Not quite sure how this relates to the *16 that the FTDI
> code but it does at least explain why the libftdi baud parameter is
> 1/4 of the equivalent D2XX baud parameter.

OK.  So this doesn't seem like a libftdi issue then.  Let's assume
we're talking about D2XX which doesn't multiply baudrates by 4.  Is
this correct:

- If you request 9600 baud, it sends 0x4138 to the device which means
  a divisor of 312.5, and the actual bitbang baudrate is 9600 * 16 = 153600

- If you request 15200 baud, it sends 0x4315 to the device which means
  a divisor of 789.5, *but* the actual bitbang bitrate is 15200 * 5 = 76000

If that's true then yes, this does seem like it could be a hardware
issue like a fake chip...

Jim

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

linux


On 01/20/2016 04:59 PM, Jim Paris wrote:

> [hidden email]  wrote:
>> Hi
>>
>> On 20/01/16 03:06, Jim Paris wrote:
>>> [hidden email]  wrote:
>>>> Hi
>>>>
>>>> I am trying to get lirc working with my Adafruit FT232H device and
>>>> having some problems with getting the clock speed (baud) correct.
>>>>
>>>> I'm trying to transmit a carrier frequency of 38KHz which is turned
>>>> on and off based on the IR pattern to transmit.
>>>>
>>>> I've created a separate program from LIRC to investigate this which
>>>> simply opens the device, sets bit bang mode, sets the baud rate, and
>>>> writes a block of 4k alternating 0xff / 0x00.
>>>>
>>>> I'm driving an IR LED and I have a receiver which will print out the
>>>> duration it detects the 38KHz carrier for if the frequency is close.
>>>>
>>>> I'm using libftdi-HEAD-c4c9f0a from a few days ago.
>>>>
>>>> If I provide a baud rate of 3800 to ftdi_set_baudrate then that for
>>>> some reason gives me the required 72K bits / second transmission
>>>> rate.  This is completely at odds with any docs I can find or the
>>>> LIRC code.
>>> I'm not sure I exactly follow your numbers here.
>>>
>>> For a 38KHz carrier, wouldn't you want 76Kbits/second transmission
>>> rate?  I assume 72Kbits was a typo?
>> Yes it was a typo, I seem to have a mental block about typing 76 for
>> some reason.
>>> You're saying that you need to provide a baudrate of 3800, which means
>>> that it's apparently getting scaled up by (76000 / 3800) = 20
>>> with the libftdi version.
>>>
>>>> As an experiment I tried building the same program against the FTDI
>>>> D2XX libraries which the docs say multiplies the rate up by 16.  But
>>>> to get that to give me the correct baud rate, I have to pass 15200
>>>> as the argument to FT_SetBaudRate.
>>> By correct baud rate, you mean it's getting scaled up by (76000 /
>>> 15200) = 5 in the D2XX version?  So you're not seeing the baudrate get
>>> multiplied by 16 in either situation?
>> Yes except that the FTDI D2XX example code and docs say that in bit
>> bang mode it gets scaled up by 16 not 5.
>>>> USB sniffing shows that ultimately both of these calls result in the
>>>> same value being passed down to the chip.
>>> What is the value?
>> It is 0x4315 which according to the FTDI docs is a sub integer
>> divisor of 0.5 and a divisor of 0x315.
>>
>> If I request 9600 baud, the values which appear here match the
>> values in the FTDI docs for serial port baud rates.
>>>> Can anyone help me understand why I have such a seemingly bizarre
>>>> bit rate being used by this device?
>>>> I had some eeprom issues initially with the device; is it possible
>>>> that the eeprom contents can affect the baud rate like this?
>>>> Or have I bought a fake FTDI device which doesn't operate as the
>>>> genuine ones do?
>>> Not sure, but it sounds like you have a factor of 4 discrepency
>>> between D2XX (scaling by 5?) and libftdi (scaling by 20?).  I also
>>> saw this mystery factor of 4, with a FT230X in bitbang mode.  For 38
>>> KHz IR, my code uses:
>>>
>>> #define CARRIER 38400
>>>
>>>    ftdi_set_bitmode(&ftdic, 1, BITMODE_BITBANG);
>>>    ftdi_set_baudrate(&ftdic, (CARRIER * 2 / 16) / 4);
>>>
>>> The / 4 was just something I determined experimentally and never dug
>>> into.
>> The libftdi code multiplies the baud you request by 4 if bitbang is
>> enabled.  Not quite sure how this relates to the *16 that the FTDI
>> code but it does at least explain why the libftdi baud parameter is
>> 1/4 of the equivalent D2XX baud parameter.
> OK.  So this doesn't seem like a libftdi issue then.  Let's assume
> we're talking about D2XX which doesn't multiply baudrates by 4.  Is
> this correct:
>
> - If you request 9600 baud, it sends 0x4138 to the device which means
>    a divisor of 312.5, and the actual bitbang baudrate is 9600 * 16 = 153600
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.

Unfortunately I don't have an RS232 level shifter to be able to use this
device connected to a "real" RS232 port to confirm whether conventional
serial port operation works as expected.
> - If you request 15200 baud, it sends 0x4315 to the device which means
>    a divisor of 789.5, *but* the actual bitbang bitrate is 15200 * 5 = 76000
>
> If that's true then yes, this does seem like it could be a hardware
> issue like a fake chip...
The remaining thing that I'm still not certain on is the eeprom content
I'm using.  It was mostly generated with
> Jim
>  


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

Jim Paris
[hidden email] 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 [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

linux
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:

> [hidden email] 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 [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

linux
In reply to this post by Jim Paris
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:

> [hidden email] 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 [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Baud rate confusion

Alex Scarbro
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, <[hidden email]> 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:
[hidden email] 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 [hidden email]   


libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]


Loading...