Re: Ftdi FT230X based receiver gives incorrect timings for received IR pulses.
Alec Leamas <[email protected]>
| Newsgroups | gmane.comp.hardware.lirc |
|---|---|
| Message-ID | <[email protected]> |
Hi! Thanks for a really qualified message, and sorry for not providing any answer until now. I wanted to see if anyone actually using these chips would show up first. On 15/03/17 14:48, John Penfold wrote: > Hi All, > > I have built a USB infra-red receiver based on ftdi's FT230X chip. > > Comparison between the mode2 outputs when using the ftdi receiver and the > serial port receiver showed that the ftdi receiver pulses were twice the > width. The signal going into the FT230X was the correct width. > > The device was built for receiving only, but I tried sending by connecting the > transmit output pin to an oscilloscope, the pulses were half the width they > should have been (with discontinuities in the modulation pulses). I tried it > with the ftdix driver which gave the correct output. > > Looking through the code in ftdi.c i found in parsesamples() the following > (from line 151) > /* Convert number of samples to us. > * > * The datasheet indicates that the sample rate in > * bitbang mode is 16 times the baud rate but 32 seems > * to be correct. */ > usecs = (rxctr * 1000000LL) / (rx_baud_rate * 32); > I wanted to verify this, and tried using the libftdi python bindings to write > a small python program to do it. I found that if you set the baudrate before > entering bitbang mode, the bitbang clock will be 16 times the baudrate you > set, if you set the baudrate when in bitbang mode the clock will be 64 times > the baudrate you set. > This is caused by libftdi's ftdi_set_baudrate(), when you are in bitbang mode > it multiplies the baudrate by 4 before setting the chip. I could not find any > mention of this "feature" in the documentation.: > > In lirc the baudrate is set while in bitbang mode, the bitbang clock is > therefore 64 times the baudrate you set. This suggests that the 32 in > parsesamples() should be 64, which would halve the number of microseconds of > the pulse, giving the correct result. > > Does the ftdi driver work correctly with any other ftdi chip (e.g. FT232R)? Is > it only the FT230X that causes problems? Until someone shows up with some data on this we just don't know. However, you have verified a patch to apply if the chip actually is FT230X. If you could make a patch which tested this in runtime and applied the correct divisor for FT230X chips only I would be happy to apply this. Doing so would leave an open issue for non-FT230X chips. We would have to live with that until it's tested. An alternative would be to apply the correct divisor unconditionally, but add a driver option which makes it possible for users to reset it to the original value. I would also appreciate if you opened a bug for this - bugs are easier to track, and we definitely need to track this. Again: thanks for valuable input! Cheers, --alec ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot