Usb client interface slows down application

Hi there,

A very strange phenomena which I read about on this forum earlier ( but cannot find any reference to it).
In case I feed my board via the cerbuino usb-client port, connected to my PC, the application slows down significant, and executes very slow and behaves abnormal.
Connecting the board via an usb-power adapter , the application behaves normally.

Any suggestions?

I wonder if this is tied in with Debug.Print? I now make a point of encapsulating all Debug statements in

Ah…that sounds plausible…I will try this asap. Never had any problems not doing his. But my application grows and grows, and perhaps my processor is running out of memory?
See also https://www.ghielectronics.com/community/forum/topic?id=13412&page=2#msg171500

Unfortunately bad results, the usb-connection with the PC still slows down the execution of the code. A usb-sniffer shows that there is communication on the bus, so I wonder whether the usb-driver of the Cerbuino is in some kind of polling wait-process…?
In my case this phenomena is very anoying because timing is essential for my application…

@ freeck - Can you post a small program that reliably shows the issue?

@ John -

            
Mainboard.SetDebugLED(false);
Debug.Print("Program Started");
Mainboard.SetDebugLED(true);
Thread.Sleep(200);
Mainboard.SetDebugLED(false);
for (int i = 0; i < 500000; )
{
        i = i + 1;
}
Mainboard.SetDebugLED(true);
Thread.Sleep(200);
Mainboard.SetDebugLED(false);

I cannot reproduce the phenomena anymore after I had restarted my PC , probably a clean start of VS is responsible for solving this issue?
…but I notice a significant difference in execution time in case the application is started via the debugger session, without the debugger attached the execution time is 4 to 5 times faster. I can image that the overhead of the debugger is responsible for that?

@ freeck - Yes, the debugger does slow things down quite a bit.

John, a new insight: I can now reproduce the phenomena I described in my post.
In case I switch off the usb-driver for the Cerbuino on my PC, the application runs normally.
Could it be that the usb-communication takes a portion of ram, which may hamper the application? Knowing that my application has only 10-15kbyte of ram left during execution.

@ freeck - What do you mean by switch off the usb driver?

I disabled the usb-driver via the device manager.

Then I started the gadgeteer programme (see example post #5), I observed a 40 seconds delay before the code is actually executed.
A board or firmware issue? I reloaded the loader and the 4.3 firmware, no success, still a delay. Then I reinstalled the SDK , no success, same effect.
Then (I dont know why) , I made a console version of the same testprogramme, and yep!, the code executed normally. Also after detaching the debugger, and the resetting the board, the code executed immidiately, no 40 seconds delays anymore.
Then I reloaded the original Gadgeteer testprogramma, et voila!, the application executed normally.
I have no idea whats happening under the hood of this system…

@ freeck - If the issue comes back, I would try a second computer if possible.

Ok, I will keep you and the forum informed.
For now, I’m relieved that everything is working again. Case closed for the time being