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.
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
ftStatus = myFtdiDevice.OpenByIndex(0);
to
ftStatus = myFtdiDeviceCHB.OpenByIndex(1);
However, when it runs, it crashes at the bottom line when it goes to enable MPSSE mode:
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
************** 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.