From f64a3154daca5a424babcd16bec852235b4d309c Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Sun, 25 Dec 2022 17:11:55 -0500 Subject: [PATCH] add RP2040 --- GPIO/RP2040/ring.RP2040.ino | 56 +++++++++++++++++++++++++++++++++++++ GPIO/RP2040/ring.RP2040.py | 19 +++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 GPIO/RP2040/ring.RP2040.ino create mode 100644 GPIO/RP2040/ring.RP2040.py diff --git a/GPIO/RP2040/ring.RP2040.ino b/GPIO/RP2040/ring.RP2040.ino new file mode 100644 index 0000000..b73dd8d --- /dev/null +++ b/GPIO/RP2040/ring.RP2040.ino @@ -0,0 +1,56 @@ +// +// ring.RP2040.ino +// RP2040 ring oscillator test +// connect P1 and P2 +// +// Neil Gershenfeld 12/26/22 +// +// 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. +// + +void setup() { + // + // nothing to do in first core + // + } + +void loop() { + } + +void setup1() { + // + // use second core to avoid Arduino interrupts + // + pinMode(2,OUTPUT); + } + +void loop1() { + // + // direct port I/O version + // 9.17 MHz at 133 MHz clock + // + uint32_t pin1 = (1 << 1); + uint32_t pin2 = (1 << 2); + while (1) { + if (pin1 & sio_hw->gpio_in) + sio_hw->gpio_clr = pin2; + else + sio_hw->gpio_set = pin2; + } + // + // Arduino version + // 584 kHz at 133 MHz clock + // + /* + while (1) { + if (digitalRead(1)) + digitalWrite(2,LOW); + else + digitalWrite(2,HIGH); + } + */ + } diff --git a/GPIO/RP2040/ring.RP2040.py b/GPIO/RP2040/ring.RP2040.py new file mode 100644 index 0000000..39f2ae4 --- /dev/null +++ b/GPIO/RP2040/ring.RP2040.py @@ -0,0 +1,19 @@ +# +# ring.RP2040.py +# RP2040 ring oscillator test +# connect P1 and P2 +# +# Neil Gershenfeld 12/25/22 +# +# 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 +machine.freq(133000000) +p1 = Pin(1,Pin.IN) +p2 = Pin(2,Pin.OUT) +while (True): + p2.value(1-p1.value()) -- GitLab