From a5153ef10b6988f2de3c6abd4facf77ac3e494c6 Mon Sep 17 00:00:00 2001 From: Quentin Bolsee <quentin.bolsee@cba.mit.edu> Date: Tue, 26 Mar 2024 01:50:18 +0000 Subject: [PATCH] Update file ring.RP2040PIO_NO_SYNC.py --- py/ring.RP2040PIO_NO_SYNC.py | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 py/ring.RP2040PIO_NO_SYNC.py diff --git a/py/ring.RP2040PIO_NO_SYNC.py b/py/ring.RP2040PIO_NO_SYNC.py new file mode 100644 index 0000000..6735117 --- /dev/null +++ b/py/ring.RP2040PIO_NO_SYNC.py @@ -0,0 +1,39 @@ +# +# ring.RP2040PIO_NO_SYNC.py +# RP2040 ring oscillator with PIO + bypass synchronizer +# connect P1 and P2 +# +# Quentin Bolsee 2024-03-25 +# +# This work may be reproduced, modified, distributed, +# performed, and displayed for any purpose, but must +# acknowledge this project. Copyright is retained and +# must be preserved. The work is provided as is; no +# warranty is provided, and users accept all liability. +# + +from machine import Pin, freq, mem32 +import rp2 + + +@rp2.asm_pio(out_init=rp2.PIO.OUT_LOW) +def ring(): + mov(pins, invert(pins)) + + +# clock speed +# freq(133000000) +freq(250000000) + +# IO pins +pin_in = Pin(1, Pin.IN) +pin_out = Pin(2, Pin.OUT) + +# bypass PIO input synchronizer on pin 1 +PIO0 = const(0x50200000) +INPUT_SYNC_BYPASS = const(0x038) +mem32[PIO0 + INPUT_SYNC_BYPASS] |= 1 << 1 + +# create and launch state machine +sm = rp2.StateMachine(0, ring, in_base=pin_in, out_base=pin_out) +sm.active(1) -- GitLab