arduino / arduino/ArduinoCore-mbed

attachInterrupt forces pin high

Open
#757 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
411
Forks
225
PR merge metrics
No merged PRs in 30d

Description

Hi, There appears to be a bug in attachInterrupt() call.

If pinMode is called on a pin before attachInterrupt is called with 'CHANGE' parameter the pin is forced high.

Minimal example. Tested with Arduino Nano 33 BLE and Mbed OS Nano board 4.0.8.

```
void dummy() {} // dummy interrupt handler

void setup() {
pinMode(2, INPUT);
attachInterrupt(2, dummy, CHANGE);
}

void loop()
{}

```
Steps to reproduce.
1. Load the sketch above
2. Measure voltage on pin 2. It's 3.3V. Expected result is that pin would be floating.

If call to pinMode is commented out, the pin works correctly and does not have a pull-up.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the minimal sketch on an Arduino Nano 33 BLE with Mbed OS Nano board 4.0.8, focusing on the interaction between pinMode(2, INPUT) and attachInterrupt(2, dummy, CHANGE). Done means pin 2 remains floating rather than measuring 3.3V, while commenting out pinMode continues to behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.