FTDI Community

General Category => Discussion - Drivers => Topic started by: seo on March 25, 2021, 10:57:04 AM

Title: FT_SetBitmode: what pins are configured for FT232H
Post by: seo on March 25, 2021, 10:57:04 AM
Hello,

I use the FTDI cable C232HM-DDHSL-0 that has the FTDI chip FT232H. I use D2XX driver for Linux.

In D2XX Programmer's Guide (in its latest version 1.4) the description of the function FT_SetBitmode states:
"ucMask  Required value for bit mode mask. This sets up which bits are inputs and outputs. A bit value of 0 sets the corresponding pin to an input, a bit value of 1 sets the corresponding pin to an output".

I would like to know what pins of FT232H chip are configured in accordance with ucMask when the function FT_SetBitmode is called? I assume that these are pins ADBUS0..ADBUS7, but I cannot find the confirmation of it in FTDI documentation: I have looked for it in the datasheet for FT232H chip, in D2XX Programmer's Guide, and in FTDI Application Notes 108, 129, 135.

Please advise if this information is covered somewhere in FTDI documentation?

Do I understand correctly that after the call FT_SetBitmode(ftHandle, 0x0, 0x0) all the pins ADBUS0..ADBUS7 of FT232H chip (and the corresponding wires of the C232HM cable) will be configured as inputs?

P.S. I would like to know it because I am going to configure all FT232H pins as inputs until my target device (which I am going to debug with JTAG) is initialized and ready for JTAG communication. It would allow to avoid a possible short circuit in the case if some pins of my target device are configured as outputs in the timeframe after the device is powered on and before it is initialized for JTAG communication. After the target device is ready for JTAG communication I am going to switch FT232H chip to MPSSE mode and then configure pins directions for JTAG communication by means of MPSSE commands.

Thank you in advance!
Title: Re: FT_SetBitmode: what pins are configured for FT232H
Post by: FTDI Community on March 26, 2021, 03:53:50 PM
Hello,

Yes that is correct the ucMask variable addresses the ADBUS0 -> ADBUS7 pins on the IC.

Please note the FT_SetBitmode(ftHandle, 0x0, 0x0) command resets the MPSSE, so you would issue a second command to enable MPSSE with 0x0 as the mask value:
Code: [Select]
ftStatus |= FT_SetBitMode(ftHandle, 0x0, 0x00);
//Reset controller
ftStatus |= FT_SetBitMode(ftHandle, 0x0, 0x02);
//Enable MPSSE mode with all pins as input

Please have a look at the following application note:
MPSSE Basics (http://www.ftdichip.com/Support/Documents/AppNotes/AN_135_MPSSE_Basics.pdf)

And please also be aware of the initial pin states of the device:
FTDI Device Input Output pin States (https://ftdichip.com/wp-content/uploads/2020/08/AN_184-FTDI-Device-Input-Output-Pin-States.pdf)

Best Regards,
FTDI Community
Title: Re: FT_SetBitmode: what pins are configured for FT232H
Post by: seo on March 28, 2021, 03:28:45 PM
Thank you for your reply!

Application Note 135 "FTDI MPSSE Basics" suggests to make the following call before exiting the program:
FT_SetBitMode(ftHandle, 0x0, 0x00); // Reset the port to disable MPSSE

Do I understand correctly that after this call all the pins ADBUS0-ADBUS7 remain configured as inputs even after the process (that made this call) is terminated? And the pins remain configured as inputs until a new process calls D2XX functions (unless the FTDI USB device is unplugged/plugged or powered-off/powered-on, e.g. when the host computer goes to/from sleep mode)?

Table 7.1 "Default External EEPROM Configuration" of FT232H Datasheet states that the parameter "Pull down I/O Pins in USB Suspend" is Disabled. Table 4.1 "FT232H I/O States" of Application Note 184 "FTDI Device Input Output Pin States" gives the value "Function" for pins ADBUS0-ADBUS7 in the column "SUSPEND (Pull Down IO Pins in USB Suspend - Not Set)". This is why I think that the pins ADBUS0-ADBUS7 should preserve their configuration as inputs even when the host computer puts the FTDI USB device into suspend (after some period of inactivity).
Title: Re: FT_SetBitmode: what pins are configured for FT232H
Post by: FTDI Community on March 29, 2021, 02:28:28 PM
Hello,

Yes, that is correct the ucMask variable in the FT_SetBitMode() call will control which pins are input and which are outputs. If this is the last call you execute to the IC using a ucMask value = 0x0 should ensure that all of the pins remains inputs, at least until a subsequent call which will alter their state.

It is also correct that if "Pull down I/O Pins in USB Suspend" is not set when the IC gets placed into suspend mode by the USB host controller the ADBUS pins will maintain their last previous configuration, such as defining these pins as inputs with FT_SetBitMode().

Best Regards,
FTDI Community
Title: Re: FT_SetBitmode: what pins are configured for FT232H
Post by: seo on March 30, 2021, 10:45:20 AM
Thank you for your reply!