Skip to content

ports/samd/machine_dac.c: Fix SAMD51 DAC for two channels. #15890

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

Conversation

graeme-winter
Copy link
Contributor

Summary

Improvements to DAC support for SAMD51 in ports/samd as previously discussed with @robert-hh

  • correctly use dac_init flag, as a 2-ple for A0, A1 channels
  • initialise vref in table
  • disable DAC before adjusting settings see SAMD5x data sheet §47.6.2.3

Cherry-picked commit from PR which is adding Grand Central support: #15889 which I will rebase onto this branch.

Testing

Vanilla code in main locks up when initialising and de-initialising e.g.

from machine import DAC

dac0 = DAC(0)
dac1 = DAC(1)

for j in range(0, 0x1000, 0x10):
    dac0.write(j)
    dac1.write(j)

del(dac0)
del(dac1)

dac0 = DAC(0)
dac1 = DAC(1)

for j in range(0, 0x1000, 0x10):
    dac0.write(j)
    dac1.write(j)

del(dac0)
del(dac1)

Trade-offs and Alternatives

Minute increase in the compiled code size for correct behaviour

- correctly use dac_init flag, as a 2-ple for A0, A1 channels
- initialise vref in table
- disable DAC before adjusting settings see SAMD5x data sheet §47.6.2.3

Co-authored-by: robert-hh <robert@hammelrath.com>
Signed-off-by: Graeme Winter <graeme.winter@gmail.com>
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:   +52 +0.019% ADAFRUIT_ITSYBITSY_M4_EXPRESS[incl +4(bss)]

@dpgeorge
Copy link
Member

Thanks for the contribution.

It looks like this was discussed and tested quite extensively in #11104.

@dpgeorge
Copy link
Member

Rebased and merged in 70b95d8

@dpgeorge dpgeorge closed this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy