I want to establish a UART communication between an FPGA equipped with an FTD2232H chip and a PC, and for that, I am using the Python ftd2xx module. I do not know how to use the setBitMode function of this module to adjust the mode as UART.
I have written the following example code:
import ftd2xx as ftd
device = ftd.open(0)
device.setBaudRate(9600)
device.setBitMode(mask, enable)
device.write("01010101")
device.close()
How should the parameters mask and enable be chosen in order to have a UART communication?
The FT2232H defaults to a mode depending on if an EEPROM is present and the stored setup. If no EEPROM is present UART is the default. Else the setup stored in the EEPROM determins the mode. It can be UART or any other of the allowed modes. You can change the setup using FT_PROG.
If the FT2232H is in UART mode, there is no need to change anything via D2XX. Actually in that case the device can simply be opened as a com port if thethe Virtual Com Port (VCP) is loaded. The py_serial module is an easy solution to open the device in that case.
If you really want (or need) to use the ftd2xx module (note: the project page states "I don’t have time to maintain this project, so I am looking for a maintainer."), you can find the corresponding descripts in "D2XX Programmer's Guide" (Document Reference No.: FT_000071 ). However, you can only enter specific modes using the D2XX driver. If you entered one of them (e.g. to use an alternative protocol for a short time), you can issue a reset using mode = 0x0 to revert the device state to the EEPROM configurated mode. But this is a very specific use case which mostlikely does not apply here.