Uncategorized

Pico Serial Noise

(vvv) USB serial connection having noise?

Ask Question

Asked today

Modified today

Viewed 9 times

0

vvvIn 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);
        }vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

    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 �

usbuartpi-picoserial-console

Share

EditFollowClose 1Flag

asked 3 hours ago

user avatar

Francisco Ayrolo

2133 bronze badges

 New contributor

Add a comment

2 Answers

Sorted by:

Reset to default                                              Highest score (default)                                                                   Date modified (newest first)                                                                   Date created (oldest first)                              

1

Fixed! The problem was that I was storing the return of the getchar_timeout_us function as a char instead of int.

Share

EditFollowFlag

answered 2 hours ago

user avatar

Francisco Ayrolo

2133 bronze badges

 New contributor

Add a comment

1

Make sure the baud rate in your serial terminal is set to 115200. Also, try a different cable, and if that fails, try a different computer.

Share

EditFollowFlag

answered 3 hours ago

user avatar

oli2

1

 New contributor

  • 1Yep, I’m calling minicom with minicom -b 115200 -o -D /dev/ttyACM0  And the cable works fine, since it’s reading and transmitting just fine. – Francisco Ayrolo 3 hours ago 
  • 1Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – CommunityBot 2 hours ago

Add a commentvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.