Skip to content

analogRead() followed by pinMode(,OUTPUT) leaves pin muxed to ADC #205

Closed
@kiptonk

Description

@kiptonk

Hi,

The following sequence will leave the pin muxed to the ADC and fail on the digital write:

analogRead(pin);
pinMode(pin,OUTPUT);
digitalWrite(pin,HIGH);

A workaround is to insert a pinMode(pin,INPUT) before the pinMode(pin,OUTPUT).

I think the issue is with commit e431bf7 to wiring_digital.c. It sets the INEN bit without clearing the PMUXEN bit. It is also leaving any PULLEN and DRVSTR setting in place where as the previous revision was clearing the whole register except INEN. Not sure if the best fix is to just clear PMUXEN, or to set the whole register with PORT_PINCFG_INEN so everything else is cleared.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions