I'm having some trouble trying to make a simple USB IO demo to test the Pico. Apparently, the USB serial connection seems to be noisy, and always puts something into the UART buffer even though I am not sending anything from my end.
In the following code, I simply try to read something with getchar_timeout, which should return PICO_ERROR_TIMEOUT if nothing was sent through serial, but it's instead just printing random characters (even ilegible ones). What could be the cause of this?
int main() {
stdio_init_all();
char PC_input;
while (1) {
sleep_ms(1000);
PC_input = getchar_timeout_us(1000);
if (PC_input == PICO_ERROR_TIMEOUT) {
printf("Timeour error!\n");
} else {
printf("input was %c\n", PC_input);
}
}
return 0;
}
The output I get looks like this (I only typed in 'asd123'):
input was �
input was �
input was a
input was s
input was d
input was 1
input was 2
input was 3
input was �
input was �
input was �
input was �