Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CedarGroveStudios opened this issue Apr 13, 2023 · 1 comment

Comments

@CedarGroveStudios
Copy link

CedarGroveStudios commented Apr 13, 2023

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

@Strathcona
Copy link

I'm seeing the same behavior in a custom ATSAMD51G19A board. This is unfortunate, as it's causing DC where I'd really there rather not be, when using it for audio generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants