Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5804

General • Re: Error when Running Pico PIO with USB Serial Output

$
0
0
And I also realized that once the state machine of the PIO is running, the main c++ program ends (unless with an extra while(true) loop), and then '/dev/ttyACM0' is lost.
For the '~/pico/pico-examples/pio/hello_pio/hello.c' example; that has an infinite 'while(true)' loop which will repeatedly turn the LED on and off, so should never exit.
I also realize that there is no wonder nobody asks about it because the state machines themselves don't do serial output, so enabling the option does not make sense if only the state machines are running.
The example does only demonstrate PIO operation but it is possible to add code which reports when the LED is turned on and off. It will be best if the time delay between toggling on and off is extended -

Code:

    while (true) {        // Blink        pio_sm_put_blocking(pio, sm, 1);        printf("LED is on\n");        sleep_ms(2000);        // Blonk        pio_sm_put_blocking(pio, sm, 0);        printf("LED is off\n");        sleep_ms(2000);    }
Glad you are making progress.

Statistics: Posted by hippy — Wed Apr 17, 2024 10:53 am



Viewing all articles
Browse latest Browse all 5804

Trending Articles