Skip to content

rp2pio.StateMachine valid frequency has changed #10511

@FoamyGuy

Description

@FoamyGuy

The code here: https://github.com/adafruit/Adafruit_CircuitPython_PIOASM/blob/main/examples/pioasm_hello.py#L30 which is embedded in this guide page: https://learn.adafruit.com/intro-to-rp2040-pio-with-circuitpython/using-pio-to-turn-an-led-on-and-off

Creates a StateMachine with frequency 2000. When I run this code on a Pico w/ 10.0.0-beta.0 it raises this error: ValueError: frequency out of range

In testing a few values it seems that 4000 is the minimum accepted value.

I can update the example code to get it back to working if this change was intentional. But I'm not sure if this was intentional or not, so am opening the issue here to get more input on that.

I found information online (https://www.bisonacademy.com/ECE476/Lectures/29%20PIO%20State%20Machines.pdf) indicating the valid range is 2k - 125k which seems to match the lower end value of 2000 originally used by the basic example

Image

I also noticed that if I use frequency=0 the code prints real frequency 252000000 which is basically 2x the 125k listed as the top of end of the valid range. So perhaps there is some multiplier taking effect on the valid range? Maybe this is the tied to RPi specifying the chip was usable at higher CPU frequencies earlier this year?

In any case, if this change is intentional we can close this and I'll update the learn code use 4000 so that it runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rp2Both RP2 microcontrollers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions