arduino / arduino/ArduinoCore-mbed
using digitalWrite() with a boolean instead of LOW/HIGH causes a affects a completely unrelated pin instead of the intended
- Dominant language
- C
- Stars
- 411
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Calling `digitalWrite()` for `PC_2` with a boolean `true`/`false` causes `PA_8` to be toggled instead.
Calling `digitalWrite()` for `PC_2` with a `LOW`/`HIGH` works as intended.
## Hardware
Board: Portenta H7
Core Version: Arduino-Mbed 4.4.1
Arduino IDE Version: 2.3.7
Arduino IDE CLI Version: 1.3.1
## Steps to reproduce
Attach an oscilloscope or logic analyzer to the following pins:
* PA_8 / D6 / PWM_0
* PC2_C / A2 / ADC A2
* PC2 / A4 / ADC A4
* PC2 / D10 / SPI1_CIPO
and run the following code
```cpp
void setup()
{
pinMode(PC_2, OUTPUT);
}
void loop() {
digitalWrite(PC_2, false);
delay(1000);
digitalWrite(PC_2, true);
delay(1000);
}
```
My logic analyzer gives the following output:
Compare this to the following functional code:
```cpp
void setup ()
{
pinMode(PC_2, OUTPUT);
}
void loop ()
{
digitalWrite(PC_2, LOW);
delay(1000);
digitalWrite(PC_2, HIGH);
delay(1000);
}
```
Which gives the following output
## Expected Behavior
Using `true`/`false` instead of `LOW`/`HIGH` should be equivalent.
MOST IMPORTANTLY: doing so should absolutely not affect a different pin number on a different GPIO port altogether.
## Actual Behavior
Using `true`/`false` instead of `LOW`/`HIGH` on one port + pin has no effect on the intended port + pin but does have an effect on a different GPIO port + pin.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue on a Portenta H7 using the supplied digitalWrite() examples, then trace the digitalWrite() entry point and compare the boolean and LOW/HIGH paths. Done means PC_2 responds correctly to true/false without toggling PA_8 or any other listed pin, verified with the oscilloscope or logic analyzer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100