Photon 2 performance between USB and VUSB pin / power

I am migrating a project from an Argon to a Photon 2. I was careful to make sure the various pins I used aligned to the updated Photon 2 spec.

At first, I thought I had a power issue, as in not delivering enough power to the Photon2, maybe that the new chip draws more than the Argon in some way. But that is not the case.

What I am seeing is that when powering directly via USB, chip is running blazing fast. When I power it via the VUSB pin, it is running very slow. Slow enough that it was actually tripping my Watchdog on boot, causing it to reboot (was a 5 second timeout)

I am driving some animations via the Photon 2 with LEDs. They are choppy with the USB unplugged, plugging it in, poof, they run at full speed.

I must be missing a setting somewhere. I'm running 5.5.0, how do I tell it just to go full speed? or what else may be wrong?

I measured the voltages, when plugged in via the USB cable I get about 5.06v, when powered by the board it is 5.1v. I believe the Photon2 is safe for 5V, I wouldn't expect the in .1v to be causing the problem (I hope).

1 Like

I don't think it's a power issue. The MCU does not slow down based on voltage, at least until brownout voltage. And it's a 3.3V chip, so there's quite a bit of margin.

Are you using Serial extensively? I'd look in that direction first. I'd guess that there is some case where a function is blocking until timeout when trying to access the USB CDC port when there is no connection. This is only a guess and I have no idea whether it's that, but I'd consider that to be much more likely than voltage.


I use the logger quite a bit.

I will see if I have an errant Serial call somewhere.

With the photon2, is there any change with how Log works that might cause this?

Logging should be fine, but since the USB CDC subsystem is different and in some versions of Device OS, significantly slower, that seemed like a reasonable place to look.

You could try turning off USB logging by commenting out the SerialLogHandler as a quick test, just in case. It should be fine, but just to exclude that as a cause.

Interestingly, if I connect the USB just to power, the slowness occurs, it does need a true USB connection to speed it up (though I did NOT need to have serial monitor up).

I have rather extensive logging, it will take some time to comment that all out.

You don't need to comment out every logging command, just SerialLogHandler because that's the only connection between logging and USB serial.

Well, that did it. Commenting out the SerialLogHandler everything works fine.

Any thoughts on what I should do or might this be a bug in DeviceOS?

That seems like it might be a bug in Device OS.

This looks suspicious to me. HAL_USB_USART_Available_Data_For_Write() returns -1 if the USB serial is not connected. If USB serial is not connected, every write will delay for 1 millisecond before breaking out of the loop.

Yeah, that does seem a bit off. I think this explains a lot of the behavior I am seeing.

I even noticed that the Serial Monitor itself is printing data slower than with the Argon, you can literally watch it spit out letters at times.

Do I need to do anything here, like submit a bug? I did send in a support ticket over the weekend. My solution now is just to disable logging which isn't the best :slight_smile:

Engineering is aware of the issue and plans to fix it. Also make sure you are using Device OS 5.5.0 or later. This bug was fixed in 5.5.0-rc.1 and speeds up USB CDC serial on the P2 and Photon 2.

1 Like

Thank you!

I am using 5.5.0.