Skip to content

M4 Express A0 DAC drifts when either DAC is initialized or A1 is deinitialized #7860

Open
@CedarGroveStudios

Description

@CedarGroveStudios

CircuitPython version

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Feather M4 Express with samd51j19

and also tested on ItsyBitsy M4 8.0.5 with same results.

Tested with the Feather M4 on versions as far back as 6.3.0 with same results.

Code/REPL

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Feather M4 Express with samd51j19
>>> import analogio
>>> import board
>>> a = analogio.AnalogOut(board.A0)  # A0 slowly climbs to 3.3v and holds
>>> a.value=0  # A0 output returns to 0v and holds
>>> b = analogio.AnalogOut(board.A1)  # A0 slowly climbs to 3.3v and holds; A1 holds at near 0v
>>> b.value = 0  # A1 holds at 0v
>>> a.value = 0  # A0 holds at 0v
>>> b.value = 21000  # A1 holds at ~1v; A0 holds at 0v
>>> a.value = 21000  # A0 holds at ~1v; A1 holds at ~1v
>>> b.deinit()  # A0 slowly climbs to 3.3v and holds; A1 floats
>>> a.value = 21000  # A0 holds at ~1v

Behavior

When initializing the A0 DAC (before applying a value), the A0 voltage slowly increases to 3.3v over the course of about 5 seconds. Applying a value to the A0 DAC sets the voltage output correctly and the voltage holds.

If the A1 DAC is then initialized, the A0 voltage slowly begins to climb again, holding at 3.3v. Setting the A0 DAC value again sets and holds the output voltage correctly.

Deinitializing the A1 DAC causes the A0 DAC to drift upwards again until its value is set.

This behavior is identical to that described in #1991.

The temporary workaround is to set the A0 DAC value after instantiating both DACs:

# Define the A0 DAC
first_dac = analogio.AnalogOut(board.A0)

 # Define the A1 DAC and set to 0
second_dac = analogio.AnalogOut(board.A1)
second_dac.value = 0

 # Set the A0 DAC to zero
"""Because of a CircuitPython bug, the A0 DAC value has to be set after
the A1 DAC is initialized."""
first_dac.value = 0

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions