Skip to content

avr64ea28: analogReadDiff() throws badArg("Invalid negative pin - valid options are ... PORTA."); for Port A pins #625

@wke67

Description

@wke67

here is the example sketch:

void setup() {
  long w;
  w=analogReadDiff(PIN_PA4, PIN_PA5);
  Serial.printf("%ld \n", w);
}
void loop() {
}

Compiler throws:

In function 'check_valid_negative_pin',
inlined from 'analogReadDiff.constprop' at ~/.arduino15/packages/DxCore/hardware/megaavr/1.6.2/cores/dxcore/wiring_analog.c:630:5,
inlined from 'setup' at ~/Arduino/sketchbook/sketch_apr25b/sketch_apr25b.ino:4:4,
inlined from 'main' at ~/.arduino15/packages/DxCore/hardware/megaavr/1.6.2/cores/dxcore/main.cpp:95:8:
~/.arduino15/packages/DxCore/hardware/megaavr/1.6.2/cores/dxcore/wiring_analog.c:452:9: error: call to 'badArg' declared with attribute error:
badArg("Invalid negative pin - valid options are ADC_GROUND, ADC_VDDDIV10, ADC_DACREF0, or any pin on PORTA.");

I believe in line 630 in wiring_analog.c the call to check_valid_negative_pin(neg) should be check_valid_analog_pin(neg) since there is no difference between muxneg and muxpos in Ex types. I also don't understand the logic in check_valid_negative_pin(neg), is it looking at pins or channels?

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