FTDI Community

General Category => Discussion - Software => Topic started by: G40 on September 24, 2019, 02:04:14 PM

Title: FT232H 245 FIFO problems (edited)
Post by: G40 on September 24, 2019, 02:04:14 PM
Greetings. Am using an FTDI UM232H module to test FIFO modes. Application is a very simple bit of C++ code (x64/MSVC2019 Pro/Windows 10 Pro/D2XX v2.12.28 WHQL drivers).

The board has been programmed (via Prog) such that Port A Hardware is set to '245 FIFO'. It is not entirely clear that this requirement holds for the FT232H, though it is documented as such for the FT232H in the D2XX programmers reference.

Before any writes occur, FT_SetBitMode is called with FT_BITMODE_RESET, then

1. using FT_BITMODE_SYNC_FIFO the FT_Write call blocks after 2 writes
2. using FT_BITMODE_SYNC_BITBANG then FT_Write blocks after 2 writes
3. using FT_BITMODE_ASYNC_BITBANG then FT_Write succeeds and data appears as expected on the I/O pins, this runs to completion over ~512K loops

For cases 1 and 2, a software USB sniffer shows the 2 packets on the wire before the 3rd write blocks. The driver in this case is reading from the device and is getting a stream of 2 bytes (always 0x32,0x00) from the IN bulk endpoint.

What am I missing here? Can the synchronous modes be set up to loop-back? If so via which pins? The IO control pins are set as shown below but they always appear to be in tri-state (according to the 'scope)

I've looked at https://www.ftdichip.com/Support/Documents/AppNotes/AN_165_Establishing_Synchronous_245_FIFO_Communications_using_a_Morph-IC-II.pdf (https://www.ftdichip.com/Support/Documents/AppNotes/AN_165_Establishing_Synchronous_245_FIFO_Communications_using_a_Morph-IC-II.pdf) for some inspiration but none found.

TIA for any help.

    <IO_Controls>
      <C0>Tristate</C0>
      <C1>Tristate</C1>
      <C2>Tristate</C2>
      <C3>Tristate</C3>
      <C4>Tristate</C4>
      <C5>Tristate</C5>
      <C6>Tristate</C6>
      <C7>Tristate</C7>
      <C8>PWREN#</C8>
      <C9>TX&amp;RXLED#</C9>
    </IO_Controls>


Very slightly elided C++ code below.

try {
// read EEPROM to check settings.
char Manufacturer[32] = { 0 };
char ManufacturerId[16] = { 0 };
char Description[64] = { 0 };
char SerialNumber[16] = { 0 };
FT_PROGRAM_DATA program_data = { 0 };
program_data.Signature2 = 0xffffffff;
program_data.Version = 5;
program_data.Manufacturer = Manufacturer;
program_data.ManufacturerId = ManufacturerId;
program_data.Description = Description;
program_data.SerialNumber = SerialNumber;

// device_index obtained via FT_ListDevices.
ftStatus = FT_Open(device_index, &ftHandle);
if (ftStatus != FT_OK)
   throw "FT_Open";
ftStatus = FT_ResetDevice(ftHandle);
if (ftStatus != FT_OK)
   throw "FT_ResetDevice";
// returns 0xFF ??
ftStatus = FT_GetBitMode(ftHandle, &mode);
if (ftStatus != FT_OK)
   throw "FT_GetBitMode";
printf("FT_GetBitMode => 0x%x\n", mode);
// check EEPROM content.
ftStatus = FT_EE_Read(ftHandle, &program_data);
if (ftStatus != FT_OK)
   throw "FT_EE_Read";
// reset MPSSE
ftStatus = FT_SetBitMode(ftHandle, Mask, FT_BITMODE_RESET);
if (ftStatus != FT_OK)
   throw "FT_SetBitMode";
// configure FT2232H into Sync FIFO mode (FT_BITMODE_SYNC_FIFO).
// Prog applied CPU FIFO option
ftStatus = FT_SetBitMode(ftHandle, Mask, FT_BITMODE_SYNC_FIFO);
if (ftStatus != FT_OK)
   throw "FT_SetBitMode";
// returns 0xFF ??
ftStatus = FT_GetBitMode(ftHandle, &mode);
if (ftStatus != FT_OK)
   throw "FT_GetBitMode";
printf("FT_GetBitMode => 0x%x\n", mode);
// any more and FT_Write blocks hard.
loops = 2;
for (loop = 0; loop < loops; loop++)
{
   // write 16 byte toggling pattern to FT232H
   ftStatus = FT_Write(ftHandle, &data_buf, sizeof(data_buf), &data_written);
   if (ftStatus != FT_OK)
      throw "FT_Write";
   if ((loop % 16) == 0)
      printf("[%d]:%d\n", loop, data_written);
}
}
catch (...)      
Title: Re: FT232H 245 FIFO problems (edited)
Post by: FTDI Community on September 25, 2019, 03:51:10 PM
Hello,

Please see the following App Note which should make things a bit clearer for you:

TN_167 FTDI FIFO Basics (https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_167_FIFO_Basics.pdf)

It includes some simple software examples.

Best Regards,
FTDI Community