Skip to content
Snippets Groups Projects
ring.RP2040.ino 1.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • Neil Gershenfeld's avatar
    Neil Gershenfeld committed
    //
    // 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.
    //
    
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
    #define digitalWriteFast(pin,val) gpio_put(pin, val ? 1 : 0)
    #define digitalReadFast(pin) (gpio_get(pin) ? 1 : 0)
    
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
    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
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       //    12.9 MHz at 250 MHz clock
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       //    9.17 MHz at 133 MHz clock
       //
       uint32_t pin1 = (1 << 1);
       uint32_t pin2 = (1 << 2);
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       /**/
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       while (1) {
          if (pin1 & sio_hw->gpio_in)
             sio_hw->gpio_clr = pin2;
          else
             sio_hw->gpio_set = pin2;
          }
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       /**/
       //
       // Arduino Fast version
       //    8.77 MHz at 250 MHz clock
       //    8.16 MHz at 133 MHz clock
       //
       /*
       while (1) {
          if (digitalReadFast(1))
             digitalWriteFast(2,LOW);
          else
             digitalWriteFast(2,HIGH);
          }
       */
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       //
       // Arduino version
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       //    1.11 MHz at 250 MHz clock
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed
       //    584 kHz at 133 MHz clock
       //
       /*
       while (1) {
          if (digitalRead(1))
             digitalWrite(2,LOW);
          else
             digitalWrite(2,HIGH);
          }
       */
       }
    
    Neil Gershenfeld's avatar
    Neil Gershenfeld committed