EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

FT2232D USB VB interface

Started by Thomas Magma August 7, 2007
Hello,
I'm trying to interface to a FT2232D USB chip using VB and the FTD2XX.DLL. I 
can program the part description using MProg3.0a and then get what appears 
to be a valid handle to the device using FT_OpenEx, but when I try writing 
some bytes out using FT_Write I do not see any pin stimulation from the 
chip. Anyone have any experience with this? I have the EEPROM set to 245 
FIFO mode. Here is my simplified code;


Module Module1
    Public Declare Function FT_OpenEx Lib "FTD2XX.DLL" (ByVal arg1 As 
String, ByVal arg2 As Integer, ByRef lngHandle As Integer) As Integer
    Public Declare Function FT_Write Lib "FTD2XX.DLL" (ByVal lngHandle As 
Integer, ByVal lpszBuffer As String, ByVal lngBufferSize As Integer, ByRef 
lngBytesWritten As Integer) As Integer
    Public Const FT_OK As Short = 0
    Public FT_Result As Integer
    Public FT_HANDLE As Integer
    Public Sub OpenWriteDevice()
        Dim temp
        FT_Result = FT_OpenEx("Device A", FT_OPEN_BY_DESCRIPTION, FT_HANDLE)
        If FT_Result <> FT_OK Then
            Form1.lblStatus.Text = "Couldn't find Device A"
        Else
            Form1.lblStatus.Text = "Device A found and opened. Handle " & 
FT_HANDLE
        End If
        temp = FT_Write(FT_HANDLE, Chr(15), 1, FT_Result)
    End Sub
End Module

Thanks in advance.
Thomas Magma 


Thomas Magma wrote:
> Hello, > I'm trying to interface to a FT2232D USB chip using VB and the FTD2XX.DLL. I > can program the part description using MProg3.0a and then get what appears > to be a valid handle to the device using FT_OpenEx, but when I try writing > some bytes out using FT_Write I do not see any pin stimulation from the > chip. Anyone have any experience with this? I have the EEPROM set to 245 > FIFO mode. Here is my simplified code; > > > Module Module1 > Public Declare Function FT_OpenEx Lib "FTD2XX.DLL" (ByVal arg1 As > String, ByVal arg2 As Integer, ByRef lngHandle As Integer) As Integer > Public Declare Function FT_Write Lib "FTD2XX.DLL" (ByVal lngHandle As > Integer, ByVal lpszBuffer As String, ByVal lngBufferSize As Integer, ByRef > lngBytesWritten As Integer) As Integer > Public Const FT_OK As Short = 0 > Public FT_Result As Integer > Public FT_HANDLE As Integer > Public Sub OpenWriteDevice() > Dim temp > FT_Result = FT_OpenEx("Device A", FT_OPEN_BY_DESCRIPTION, FT_HANDLE) > If FT_Result <> FT_OK Then > Form1.lblStatus.Text = "Couldn't find Device A" > Else > Form1.lblStatus.Text = "Device A found and opened. Handle " & > FT_HANDLE > End If > temp = FT_Write(FT_HANDLE, Chr(15), 1, FT_Result) > End Sub > End Module >
I have only worked with 'true' FTDI '245 but ... before write something to the pins I must switch the pins to output mode with the specific command ( see the library docs )
> Thanks in advance. > Thomas Magma > >
On Tuesday, in article <l56ui.39263$_d2.1551@pd7urf3no>
     somewhere@overtherainbow.com "Thomas Magma" wrote:

>Hello, >I'm trying to interface to a FT2232D USB chip using VB and the FTD2XX.DLL. I >can program the part description using MProg3.0a and then get what appears >to be a valid handle to the device using FT_OpenEx, but when I try writing >some bytes out using FT_Write I do not see any pin stimulation from the >chip. Anyone have any experience with this? I have the EEPROM set to 245 >FIFO mode. Here is my simplified code;
You might find this a helpful link <http://www.pcserviceselectronics.co.uk/ftdi/> A simple VB6 application that will talk to a FT2232D with one port as SPI, and the other as 245 mode FIFO doing reads, but still useful to you.
>Module Module1 > Public Declare Function FT_OpenEx Lib "FTD2XX.DLL" (ByVal arg1 As >String, ByVal arg2 As Integer, ByRef lngHandle As Integer) As Integer > Public Declare Function FT_Write Lib "FTD2XX.DLL" (ByVal lngHandle As >Integer, ByVal lpszBuffer As String, ByVal lngBufferSize As Integer, ByRef >lngBytesWritten As Integer) As Integer > Public Const FT_OK As Short = 0 > Public FT_Result As Integer > Public FT_HANDLE As Integer > Public Sub OpenWriteDevice() > Dim temp > FT_Result = FT_OpenEx("Device A", FT_OPEN_BY_DESCRIPTION, FT_HANDLE) > If FT_Result <> FT_OK Then > Form1.lblStatus.Text = "Couldn't find Device A" > Else > Form1.lblStatus.Text = "Device A found and opened. Handle " & >FT_HANDLE > End If > temp = FT_Write(FT_HANDLE, Chr(15), 1, FT_Result) > End Sub >End Module
Your description for the open looks wrong to me I would expect something like "USB serial converter". I normally use FT_Open have found the number of devices and checked which one is being used etc... I would also expect to see FT_SetTimeouts FT_SetBitMode BEFORE attempting any read or write to a 245 mode FIFO Follwo the app example code to see if that helps.
>Thanks in advance. >Thomas Magma > > >
-- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.gnuh8.org.uk/> GNU H8 & mailing list info <http://www.badweb.org.uk/> For those web sites you hate
On Wed, 08 Aug 2007 13:18:38 +0100 (BST), paul$@pcserviceselectronics.co.uk (Paul Carpenter) wrote:

>On Tuesday, in article <l56ui.39263$_d2.1551@pd7urf3no> > somewhere@overtherainbow.com "Thomas Magma" wrote: > >>Hello, >>I'm trying to interface to a FT2232D USB chip using VB and the FTD2XX.DLL. I >>can program the part description using MProg3.0a and then get what appears >>to be a valid handle to the device using FT_OpenEx, but when I try writing >>some bytes out using FT_Write I do not see any pin stimulation from the >>chip. Anyone have any experience with this? I have the EEPROM set to 245 >>FIFO mode. Here is my simplified code; > >You might find this a helpful link > > <http://www.pcserviceselectronics.co.uk/ftdi/> > >A simple VB6 application that will talk to a FT2232D with one port as >SPI, and the other as 245 mode FIFO doing reads, but still useful to you. > >>Module Module1 >> Public Declare Function FT_OpenEx Lib "FTD2XX.DLL" (ByVal arg1 As >>String, ByVal arg2 As Integer, ByRef lngHandle As Integer) As Integer >> Public Declare Function FT_Write Lib "FTD2XX.DLL" (ByVal lngHandle As >>Integer, ByVal lpszBuffer As String, ByVal lngBufferSize As Integer, ByRef >>lngBytesWritten As Integer) As Integer >> Public Const FT_OK As Short = 0 >> Public FT_Result As Integer >> Public FT_HANDLE As Integer >> Public Sub OpenWriteDevice() >> Dim temp >> FT_Result = FT_OpenEx("Device A", FT_OPEN_BY_DESCRIPTION, FT_HANDLE) >> If FT_Result <> FT_OK Then >> Form1.lblStatus.Text = "Couldn't find Device A" >> Else >> Form1.lblStatus.Text = "Device A found and opened. Handle " & >>FT_HANDLE >> End If >> temp = FT_Write(FT_HANDLE, Chr(15), 1, FT_Result) >> End Sub >>End Module > >Your description for the open looks wrong to me I would expect something >like "USB serial converter".
This would work if you had programmed the device description to "Device A" using mprog
>I normally use FT_Open have found the number of devices and checked >which one is being used etc... > >I would also expect to see > > FT_SetTimeouts > FT_SetBitMode > >BEFORE attempting any read or write to a 245 mode FIFO > >Follwo the app example code to see if that helps. > > >>Thanks in advance. >>Thomas Magma >> >> >>
">
> You might find this a helpful link > > <http://www.pcserviceselectronics.co.uk/ftdi/> >
Hi Paul, Thanks I did find that useful, but I'm still having problems. I configured the EEPROM back to serial port A and FIFO port b using MProg and even change the device description back to 'USB <-> Serial Cable' like the example.log report. I am still getting a 'Expected Read 5 bytes - Actually 0' error when I run the usb_mpsse_spi_test.exe application. Here is the log report: 10:06:25 Programme start 10:06:36 Path = Z:\BLD\Receiver\software\MPSSE-SPIV104 10:06:36 Checking number of devices..... 10:06:36 Number devices found = 2 10:06:36 Library Version = 30112 10:06:36 Create list of info for FTxx devices 10:06:36 Getting FT device info and checking 10:06:36 Device Index =0 10:06:36 FT device type = 4 - FT2232C 10:06:36 FT device description = USB <-> Serial Cable A 10:06:36 FT serial number = 00001001A 10:06:36 FT deviceID = 67330064 10:06:36 Location ID =289 10:06:36 Device Index =1 10:06:36 FT device type = 4 - FT2232C 10:06:36 FT device description = USB <-> Serial Cable B 10:06:36 FT serial number = 00001001B 10:06:36 FT deviceID = 67330064 10:06:36 Location ID =290 10:06:36 Open Port A 10:06:36 Driver Version = 40000 10:06:36 Reading EEPROM 10:06:37 IfAIsFifo = 0 10:06:37 IfAIsFifoTar = 0 10:06:37 IfAIsFastSer = 0 10:06:37 AIsVCP = 0 10:06:37 IfBIsFifo = 1 10:06:37 IfBIsFifoTar = 0 10:06:37 IfBIsFastSer = 0 10:06:37 BIsVCP = 0 10:06:37 Open Port B 10:06:37 Reset Port A 10:06:37 Reset Port B 10:06:37 Set Timeouts Port A 10:06:37 Set I/O Mask and mode Port A 10:06:37 Set MPSSE mode Port A 10:06:37 Empty 1 bytes from MPSSE RX queue 10:06:37 Send Sync command to MPSSE 10:06:37 Set SPI default state Port A 10:06:37 Set MPSSE SPI clock rate Port A 10:06:37 Check MPSSE RX queue length 10:06:37 Set Baud Rate Port B 10:06:37 Set Timeouts Port B 10:06:37 Set I/O Mask and mode Port B 10:06:37 Read 8 bits at CS decode 1 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 18 FB 10:06:37 Set Chip select decode and CS_STATE to0 10:06:37 Command Sent = 80 10 FB 10:06:37 Send full bytes read/write command to MPSSE 10:06:37 Command Sent = 20 0 0 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 18 FB 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 8 FB 10:06:37 Read bytes from MPSSE 10:06:37 Data Read = 0 10:06:37 Queue = 1 10:06:37 Write 8 bits at CS decode 1 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 18 FB 10:06:37 Set Chip select decode and CS_STATE to0 10:06:37 Command Sent = 80 10 FB 10:06:37 Send full bytes read/write command to MPSSE 10:06:37 Command Sent = 11 0 0 10:06:37 Send full bytes write data to MPSSE 10:06:37 Data Sent = 40 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 18 FB 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 8 FB 10:06:37 Read & Write 8 bits at CS decode 1 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 18 FB 10:06:37 Set Chip select decode and CS_STATE to0 10:06:37 Command Sent = 80 10 FB 10:06:37 Send full bytes read/write command to MPSSE 10:06:37 Command Sent = 31 0 0 10:06:37 Send full bytes write data to MPSSE 10:06:37 Data Sent = 40 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 18 FB 10:06:37 Set Chip select decode and CS_STATE to8 10:06:37 Command Sent = 80 8 FB 10:06:37 Read bytes from MPSSE 10:06:37 Data Read = 0 10:06:37 Queue = 1 10:06:37 Purge TX buffer Port B 10:06:37 Write 5 data bytes to Port B 10:06:37 Data sent = 50 A0 50 A0 50 10:06:37 Purge RX buffer Port B 10:06:37 Read data bytes from Port B 10:06:37 Read data bytes from Port B 10:06:37 Expected Read 5 bytes - Actually 0 10:06:37 Please correct error and retry 10:06:44 Data received = 0 0 0 0 0 The hardware I have is a DLP2232M eval board, I removed the FT2232C and replaced it with the FT2232D. Do I have hardware problems? Is it a Windows thing? I have the latest version of FTDI drivers installed. Any ideas would be greatly appreciated. Thomas
>>Your description for the open looks wrong to me I would expect something >>like "USB serial converter". > > This would work if you had programmed the device description to "Device A" > using mprog >
Yes I did. Thomas
On Wednesday, in article <yZmui.43753$rX4.41828@pd7urf2no>
     somewhere@overtherainbow.com "Thomas Magma" wrote:

>"> >> You might find this a helpful link >> >> <http://www.pcserviceselectronics.co.uk/ftdi/> >> > >Hi Paul, > >Thanks I did find that useful, but I'm still having problems. I configured >the EEPROM back to serial port A and FIFO port b using MProg and even change >the device description back to 'USB <-> Serial Cable' like the example.log
Description does not matter as the programme uses FT_Open.
>report. I am still getting a 'Expected Read 5 bytes - Actually 0' error when >I run the usb_mpsse_spi_test.exe application. Here is the log report:
The error is the same as Example.log and as per the help file (USBTEST.TXT) extract below A message box with error of Read data bytes from Port B Expected Read 5 bytes - Actually 0 Is an expected error if you have not clocked any data into Port B FIFO after the programme has started. FIFO is set to read mode on four bits, by the example, so if data is not clocked in it cannot be read back to PC. You will need to change the programme to do writes by FT_SetBitModes and FT_Write of an array of bytes or single byte.
>The hardware I have is a DLP2232M eval board, I removed the FT2232C and >replaced it with the FT2232D.
That should make no difference
>Do I have hardware problems? Is it a Windows thing? I have the latest >version of FTDI drivers installed. Any ideas would be greatly appreciated.
The code shows it is possible to talk to the device and the FIFO, you need to do the changes to work with your application and how the data is to be clocked out of the FIFO. -- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.gnuh8.org.uk/> GNU H8 & mailing list info <http://www.badweb.org.uk/> For those web sites you hate
>>Do I have hardware problems? Is it a Windows thing? I have the latest >>version of FTDI drivers installed. Any ideas would be greatly appreciated.
Thanks for your help, I found the problem. I'm using the DLP2232M and I didn't realize that I had to jumper some pins on it so the IO pins were powered. OOPS Oh well, hopefully someone reads this and can learn from my mistake. Thomas

The 2024 Embedded Online Conference