8000 Interrupts (working in 1.9.2) broken in 1.9.3 · Issue #277 · earlephilhower/arduino-pico · GitHub
[go: up one dir, main page]

Skip to content
Interrupts (working in 1.9.2) broken in 1.9.3 #277
Closed
@gizmo71

Description

@gizmo71

Discussed in #276

This code works with arduino-pico downgraded to 1.9.2, but fails with 1.9.3.

const uint POT_PIN = A0;
const uint SWITCH1_PIN = D14;
const uint SWITCH2_PIN = D15;

volatile int s1, s2, pot;

#define USE_INTERRUPTS 0

#if USE_INTERRUPTS
void switch1() {
  s1 = digitalRead(SWITCH1_PIN) == LOW;
}

void switch2() {
  s2 = digitalRead(SWITCH2_PIN) == LOW;
}
#endif

void setup() {
  pinMode(SWITCH1_PIN, INPUT_PULLUP);
  pinMode(SWITCH2_PIN, INPUT_PULLUP);
#if USE_INTERRUPTS
  switch1();
  attachInterrupt(digitalPinToInterrupt(SWITCH1_PIN), switch1, CHANGE);
  switch2();
  attachInterrupt(digitalPinToInterrupt(SWITCH2_PIN), switch2, CHANGE);
#endif
}

void loop() {
  pot = analogRead(POT_PIN);
#if !USE_INTERRUPTS
  s1 = digitalRead(SWITCH1_PIN) == LOW;
  s2 = digitalRead(SWITCH2_PIN) == LOW;
#endif
  sleep_ms(5);
}

void setup1() {
  Serial.begin(115200);
}

void loop1() {
  sleep_ms(500);
  Serial.print(pot);
  Serial.print(", ");
  Serial.print(s1);
  Serial.print("/");
  Serial.println(s2);
}

I can get interrupts to work under 1.9.3 using gpio_set_irq_enabled_with_callback directly, but obviously that defeats the object of writing a hardware-independent sketch.

I had a quick look at the diffs from 1.9.2 to 1.9.3 but nothing leapt out at me. Then again I only wrote my first sketch two days ago, and it was more than two decades ago I last wrote any embedded software.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0