Issue When Calling XferData in a loop >10k times ? | Cypress Semiconductor
Issue When Calling XferData in a loop >10k times ?
I have designed a firmware to execute a few simple commands (toggle simple gpio outputs).
Everything works fine on a single transfer.
I am now trying to load the FPGA image using these commands, and need to loop a high number of times (there's 8Mbits to transfer, using 32bits packets, that is 250k calls to the command).
However, after 13k packets, the cpp application stops and warns me of an issue happenning:
Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\Users\Joe\Desktop\AN84868 - Source files for FX3 Firmware_original\AN84868 - Source files for FX3 Firmware\AN84868_Project_files\FPGA Configuration Utility\bin\Release\Template.vshost.exe'.
Additional Information: The CLR has been unable to transition from COM context 0x1bb4afc0 to COM context 0x1bb4b210 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
I am not sure where to look for more information. I have tried to google the issue but cannot find anything relevant.
I would really appreciate if anybody could lead me in a direction to solve this issue.
------------ below is my code for more information --------------
CtrlEndPt = myDevice.ControlEndPt;
CtrlEndPt.Target = CyConst.TGT_DEVICE;
CtrlEndPt.ReqType = CyConst.REQ_VENDOR;
CtrlEndPt.Direction = CyConst.DIR_TO_DEVICE;
CtrlEndPt.ReqCode = 0xB4;
CtrlEndPt.Value = 0;
CtrlEndPt.Index = 1;
for (loopIndx = 0; loopIndx < file_bytes - len; loopIndx = loopIndx + len)
for (loopIndx2 = 0; loopIndx2 < len; loopIndx2++)
bufimg[loopIndx2] = file_buffer[loopIndx + loopIndx2];
success = CtrlEndPt.XferData(ref bufimg, ref len);//send vendor command to start configuration
if (success == true)
rtConsole.AppendText("Failed to send the Configuration data to FPGA\n");
StatLabel1.Text = "NEXT STEP: Please Repeat the Steps Carefully";
and the vendor command is really simple: toggling GPIO lines. no pauses or anything else there.
WIthout the sleep command on the code above, my vendor command takes 5.25ms to execute, and only 4us of it is actually toggling the lines. I am not sure why it is so slow, but I expect that it is part of the wrappers around it in the firmware. there is no pauses.