Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB serial doesn't open immediately after reset #333

Closed
andrewjherbert opened this issue Apr 11, 2021 · 6 comments
Closed

USB serial doesn't open immediately after reset #333

andrewjherbert opened this issue Apr 11, 2021 · 6 comments

Comments

@andrewjherbert
Copy link

If my program commences output to the USBserial port immediately after reset the initial output is lost.

Putting a 1000ms delay at the start of my program cures the problem.

Another work-around is as follows:

#include "tusb.h"
int main() {
stdio_init_all();
adc_init();
printf("waiting for usb host");
while (!tud_cdc_connected()) {
printf(".");
sleep_ms(500);
}
printf("\nusb host detected!\n");

But this too appears to be time sensitive - if I make the sleep <= 10ms I still lose the first line.

It would be nice to have a helper function that gets this right, or an option on opening the port.

Thanks.

@lurch
Copy link
Contributor

lurch commented Apr 11, 2021

Related to #288 and raspberrypi/pico-examples#60

I know very little about the lowlevels of USB, but I think some of the timing-sensitive delay might be partly due to the USB enumeration-process happening on the host?

@andrewjherbert
Copy link
Author

andrewjherbert commented Apr 12, 2021 via email

@lurch
Copy link
Contributor

lurch commented Apr 12, 2021

Am I correct in understanding that I can connect to any one set of UART GPIO pins for this purpose, I don’t have to use the first set as per the examples, or do I have to do something to point the Pico at the right set?

There's some handy defines in https://github.com/raspberrypi/pico-sdk/blob/master/src/boards/include/boards/pico.h 😃
To override their values, just define them in your own application code before including any pico-sdk headers.

@andrewjherbert
Copy link
Author

andrewjherbert commented Apr 12, 2021 via email

@lurch
Copy link
Contributor

lurch commented Apr 12, 2021

From one Andrew to another, you're welcome! 😁

@kilograham
Copy link
Contributor

having a "wait for connected" method should be a separate issue (there may be one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants