871
Discussion - Software / Re: Interfacing to FT232H
« on: January 29, 2018, 11:52:51 AM »
Hello Randy,
The sync procedure allows you to check that the device is definitely in MPSSE mode and is ready to accept the next command. If for example the device was still in UART or 245 FIFO mode, you would not get this response back as these modes would assume your command is just normal data.
After opening the device and doing SetBitMode, you can flush out the buffer using a routine similar to the one below. This might help to avoid those extra bytes at the start.
You can find some C# example code in AN_411 which is for an I2C Master but could be edited to create an SPI Master instead by changing the series of GPIO and clocking commands within the I2C functions. This would allow you to implement the chip select and data operations.
http://www.ftdichip.com/Support/Documents/AppNotes/AN_411_FTx232H%20MPSSE%20I2C%20Master%20Example%20in%20Csharp.pdf
You can find the description of the commands used by this code in AN_108 below:
http://www.ftdichip.com/Support/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf
Thanks,
FTDI Community
The sync procedure allows you to check that the device is definitely in MPSSE mode and is ready to accept the next command. If for example the device was still in UART or 245 FIFO mode, you would not get this response back as these modes would assume your command is just normal data.
After opening the device and doing SetBitMode, you can flush out the buffer using a routine similar to the one below. This might help to avoid those extra bytes at the start.
Code: [Select]
private byte FlushBuffer()
{
ftStatus = myFtdiDevice.GetRxBytesAvailable(ref BytesAvailable); // Get the number of bytes in the receive buffer
if (ftStatus != FTDI.FT_STATUS.FT_OK)
return 1;
if(BytesAvailable > 0)
{
ftStatus = myFtdiDevice.Read(InputBuffer, BytesAvailable, ref NumBytesRead); //Read out the data from receive buffer
if (ftStatus != FTDI.FT_STATUS.FT_OK)
return 1; // error
else
return 0; // all bytes successfully read
}
else
{
return 0; // there were no bytes to read
}
}
You can find some C# example code in AN_411 which is for an I2C Master but could be edited to create an SPI Master instead by changing the series of GPIO and clocking commands within the I2C functions. This would allow you to implement the chip select and data operations.
http://www.ftdichip.com/Support/Documents/AppNotes/AN_411_FTx232H%20MPSSE%20I2C%20Master%20Example%20in%20Csharp.pdf
You can find the description of the commands used by this code in AN_108 below:
http://www.ftdichip.com/Support/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf
Thanks,
FTDI Community