FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: FT4232H using MPSSE for I2C on channel B  (Read 255 times)

Timbo

  • Newbie
  • *
  • Posts: 3
    • View Profile
FT4232H using MPSSE for I2C on channel B
« on: January 24, 2019, 11:24:15 PM »

I am trying to modify the AN_411 example project to talk to some I2C power monitors using Channel B of FT4232H. In the app note, it briefly talks about how to modify the code to use Channel B instead.

Code: [Select]
7.1.4 Multiple Channels
Note that the functions Send_Data, Receive_Data and FlushBuffer are hard-coded to an FTDI device
instance opened at the beginning of the program as the code assumes the use of only one MPSSE
channel.
e.g. ftStatus = myFtdiDevice.Write(MPSSEbuffer, NumBytesToSend, ref NumBytesSent);
If the code requires multiple MPSSE channels (e.g. if implementing two I2C Masters on an FT2232H
device from the same application) then each channel would be opened with a different instance and this
example code would either require a Send_Data function per device or to pass in the device reference to
Send_Data.
Open: ftStatus = myFtdiDeviceCHA.OpenByIndex(0);
ftStatus = myFtdiDeviceCHB.OpenByIndex(1);
Example of writing data to channel A:
ftStatus = myFtdiDeviceCHA.Write(MPSSEbuffer, NumBytesToSend, ref NumBytesSent);

So in the source code, I did a search and replace for "myFtdiDevice." and replaced with "myFtdiDeviceCHB." and changed the

Code: [Select]
ftStatus = myFtdiDevice.OpenByIndex(0);
to

Code: [Select]
ftStatus = myFtdiDeviceCHB.OpenByIndex(1);
However, when it runs, it crashes at the bottom line when it goes to enable MPSSE mode:

Code: [Select]
            ftStatus = FTDI.FT_STATUS.FT_OK;
            ftStatus |= myFtdiDeviceCHB.SetTimeouts(5000, 5000);
            ftStatus |= myFtdiDeviceCHB.SetLatency(16);
            ftStatus |= myFtdiDeviceCHB.SetFlowControl(FTDI.FT_FLOW_CONTROL.FT_FLOW_RTS_CTS, 0x00,0x00);
            ftStatus |= myFtdiDeviceCHB.SetBitMode(0x00, 0x00);
            ftStatus |= myFtdiDeviceCHB.SetBitMode(0x00, 0x02);         // MPSSE mode     

Code: [Select]
************** Exception Text **************
FTD2XX_NET.FTDI+FT_EXCEPTION: An unexpected error has occurred when trying to communicate with the FTDI device.
   at FTD2XX_NET.FTDI.ErrorHandler(FT_STATUS ftStatus, FT_ERROR ftErrorCondition)
   at FTD2XX_NET.FTDI.SetBitMode(Byte Mask, Byte BitMode)
   at SensorDemo.Form1.I2C_ConfigureMpsse() in D:\AN_411\Power_monitoring\AN_411_Source\FT4232H\MPSSE Sensor Demo.cs:line 815
   at SensorDemo.Form1.button1_Click(Object sender, EventArgs e) in D:\AN_411\Power_monitoring\AN_411_Source\FT4232H\MPSSE Sensor Demo.cs:line 232
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8937 (WinRelRS4.050727-8900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
SensorDemo
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///D:/AN_411/Power_monitoring/AN_411_Source/FT4232H/bin/Release/SensorDemo.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8922 (WinRelRS4.050727-8900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8938 (WinRelRS4.050727-8900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8922 (WinRelRS4.050727-8900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
FTD2XX_NET
    Assembly Version: 1.1.0.0
    Win32 Version: 1.1.0.0
    CodeBase: file:///D:/AN_411/Power_monitoring/AN_411_Source/FT4232H/bin/Release/FTD2XX_NET.DLL
----------------------------------------

*********


Any suggestion on what the problem could be or how to resolve this? Really need channel B to be working, channel A will be wired to something else for SWD to MCU.

Thanks in advance for any help or suggestions.
Logged

FTDI Community

  • Administrator
  • Full Member
  • *****
  • Posts: 228
    • View Profile
Re: FT4232H using MPSSE for I2C on channel B
« Reply #1 on: January 25, 2019, 03:25:05 PM »

Hi,

Could you send your code in as a zip file (re-named to .zi_ ) to us at our support address support1@ftdichip.com. We got port B working on a copy here and so can check your code.

It is also worth checking that you only have one FTDI chip connected as the index values are across all FTDI chips connected. You could try opening by description and appending a B (replace FT4232H Module with your own modules description which can be checked with USBview or FT_Prog).

            ftStatus = myFtdiDeviceB.OpenByDescription("FT4232H Module B"); 
            //ftStatus = myFtdiDeviceB.OpenByIndex(1);

Best Regards,
FTDI Community

Logged

Timbo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: FT4232H using MPSSE for I2C on channel B
« Reply #2 on: January 25, 2019, 11:21:21 PM »

Hi,

Could you send your code in as a zip file (re-named to .zi_ ) to us at our support address support1@ftdichip.com. We got port B working on a copy here and so can check your code.

It is also worth checking that you only have one FTDI chip connected as the index values are across all FTDI chips connected. You could try opening by description and appending a B (replace FT4232H Module with your own modules description which can be checked with USBview or FT_Prog).

            ftStatus = myFtdiDeviceB.OpenByDescription("FT4232H Module B"); 
            //ftStatus = myFtdiDeviceB.OpenByIndex(1);

Best Regards,
FTDI Community

Thanks! Even though this is the only FTDI device plugged in, and the FT2322H didn't have the issue, I was not successful in opening by Index or Description, but I did have success using SerialNumber.
Code: [Select]
ftStatus = myFtdiDeviceCHB.OpenBySerialNumber("FT3Q5SRXB");
But I figured I was missing something. So I took the description from FT_PROG, ie, "Acme Serial Debug", and then used:
Code: [Select]
ftStatus = myFtdiDeviceCHB.OpenByDescription("Acme Serial Debug B");
I think finding by index would have been better so we didn't rely on EEPROM. I bought two of the same breakout boards bought from Digikey. One came with an EEPROM programmed and one didn't. So they had different descriptions. But for our actual debug board, they should all be the same, either default blank or programmed to our chosen description. So I won't worry about it and will go by name. Though it would be good to be able to check a couple of descriptions without needing a recompile.

p.s. for anyone else, in the snippet above, it would be myFtdiDeviceCHB.OpenByDescription. I got compile errors on just myFtdiDeviceB.

Thanks again!
Logged