libftdi Archives

Subject: Re: Synchronous Baud Rate Change

From: benjamin maddocks <bm16ton@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sat, 3 Sep 2022 08:29:31 -0400
i was curious about the similiar situation with i2c clock and the hardwares ability/requirements to switch clocks on the fly. I want to test 3.4m on i2c but with the magic number having to be sent at 400k then immediatly need to jump to 3.4m without pin state change, leaves me wondering if the ftdi chips can even do that. Im currently using kernel driver for i2c/spi (so awesome) but if i get around to testing it and it works ill do what i can for patches on libftdi. But i cant find any docs that specifically state anything about it. Guess trial and error like the rest of my drivers have been:) 

On Tue, 30 Aug 2022, 12:56 pm Ori Idan, <ori@xxxxxxxxxxxxxxxxx> wrote:
On Tue, Aug 30, 2022 at 6:39 PM Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> wrote:
Hi Parker,

You wrote on Fri, Apr 22, 2022 at 05:22:41PM +0000:
> I am trying to synchronously change the baud rate of one of the ports on the FT4232 chip. What I am trying to do is send out a string of bytes over the UART at baud rate 115200 and then immediately after the string has finished sending change the baud rate to 921600 and start listening. However, the first string of bytes isn't getting sent all the way... What it seems like is happening is the baud rate is changing before the first string is sent all of the way. How do I guarantee the string has been sent fully before the baud rate changes?
>
> Here is some sample code of what I am trying to do:
>
> ftdi_set_baudrate(ftdi, 115200);
> ftdi_write_data(ftdi, outBuf, size); // fails to send fully before baud rate changes to 921600.
> ftdi_set_baudrate(ftdi, 921600);
> numBytesRead = ftdi_read_data(ftdi, inBuf, size);
>
>
> Any ideas on how to fix this?

It's been a while since I last used FTDI but from what I understand libftdi_write_data initiates the transfer and returns, it does not block until all bytes are written.
You have to check if all bytes are written or wait for the time it takes to transfer, the time will be at least size / (baud / 10) seconds.
I don't think there is a function to check if a transfer is completed (at least I did not find such a function.)

-- 
Ori Idan CEO Helicon Books

 


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