Skip to content

using digitalWrite() with a boolean instead of LOW/HIGH causes a affects a completely unrelated pin instead of the intended #1107

Description

@kdinev-IEC

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

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:

Image

Compare this to the following functional code:

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
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions