Skip to content
Snippets Groups Projects
README.md 916 B
Newer Older
  • Learn to ignore specific revisions
  • Quentin Bolsee's avatar
    Quentin Bolsee committed
    # Ring oscillator with RP2040 PIO
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    This is a demonstration of the RP2040's PIO system, which let you run several state machines independently of the CPU. There's exactly 0 overhead and the state machines run a custom assembly language with simplified instructions.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    In this example implementation of a [ring oscillator](https://pub.pages.cba.mit.edu/ring/), pin 1 is configured as a PIO input, and pin 2 as an output. Reading, inverting and writing is as simple as:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    ```
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    mov pins, !pins
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ```
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    Where `pins` is a meta keyword, with a different meaning in the first and second operand (output VS input, respectively).
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ## Results
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    | CPU Freq | Ring Freq  |
    | -------- | ---------- |
    | 133 MHz  | 16.667 MHz |
    | 250 MHz  | 25 MHz     |
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ## C implementation
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    The original C implementation can be found [here](./c).
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ## MicroPython implementation
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    A MicroPython version with the same performance can be found [here](./py).