Skip to content

analogio refuse to change the value #3962

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

Closed
dglaude opened this issue Jan 10, 2021 · 3 comments · Fixed by #3966
Closed

analogio refuse to change the value #3962

dglaude opened this issue Jan 10, 2021 · 3 comments · Fixed by #3966
Assignees
Milestone

Comments

@dglaude
Copy link

dglaude commented Jan 10, 2021

Testing on

Adafruit CircuitPython 6.1.0-rc.0 on 2021-01-06; Adafruit Feather M0 Express with samd21g18

analogio seems to fail when I try to change the value:

import board
from analogio import AnalogOut
analog_out = AnalogOut(board.A0)
analog_out.value = 1000
analog_out.value = 2000

The result is and error on the line that set the value to 2000:

main.py output:
Traceback (most recent call last):
File "main.py", line 5, in
ValueError: Object has been deinitialized and can no longer be used. Create a new object.

When trying the guide code from https://learn.adafruit.com/circuitpython-essentials/circuitpython-analog-out it fail on the line: analog_out.value = i

@dhalbert
Copy link
Collaborator

dhalbert commented Jan 10, 2021

Reproduced on SAMD21, but SAMD51 is OK.

6.0.1 is OK on SAMD21.

@dhalbert
Copy link
Collaborator

@jepler I bisected this to fb768df

What I see when debugging is that the AnalogOut object is getting smashed between the first and second call to common_hal_analogio_analogout_set_value(). It seems to be OK immediately after the dac_sync_write().

OK:

$2 = {base = {type = 0x35cc0 <analogio_analogout_type>}, descriptor = {device = {hw = 0x42004800}, sel_ch = {{
        buffer = 0x0, length = 0}}}, channel = 1 '\001', deinited = false}

later:

$4 = {base = {type = 0x35cc0 <analogio_analogout_type>}, descriptor = {device = {hw = 0x42004800}, sel_ch = {{
        buffer = 0x0, length = 0}}}, channel = 224 '\340', deinited = 125}

@dhalbert dhalbert added this to the 6.1.0 milestone Jan 10, 2021
@dhalbert
Copy link
Collaborator

Channel number is getting set wrong; will fix.

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

Successfully merging a pull request may close this issue.

2 participants