Skip to content

DAC features and API enhancements #27191

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
martinjaeger opened this issue Jul 28, 2020 · 9 comments
Open

DAC features and API enhancements #27191

martinjaeger opened this issue Jul 28, 2020 · 9 comments
Assignees
Labels
area: API Changes to public APIs area: DAC Digital-to-Analog Converter Enhancement Changes/Updates/Additions to existing features

Comments

@martinjaeger
Copy link
Member

This issue will be used to collect findings from DAC peripheral PRs and issues which could influence a future update of the currently experimental API.

Overview

Supported DACs

  • ST STM32L0
  • NXP Kinetis MCUX

Work in progress

Feature enhancements

Enable/disable analog output buffer

This has been discussed already in the initial PR for the DAC. It was decided to keep this out of the API configuration until we know how common a configurable output buffer is.

Voltage references and gain

Voltage reference selection was kept out of initial API because a common implementation covering every MCU type was not obvious. PR 26649 suggests a way using new enum feature in devicetree.

There are also DACs which support to select different voltage references per channel, e.g. the external TI DACx0508.

Above mentioned DACx0508 series also supports to select a different gain (2, 1 or 0.5) for each channel. At least a gain <1 has a similar result as choosing a different voltage reference, so this might be combined in the API in some way.

Resolution

The resolution is currently not configured via devicetree, but in struct dac_channel_cfg. The reason is that some DACs (e.g. in STM32) support to use lower than max. resolution for increased speed (similar to many ADCs). Only the max. resolution is a hardware feature, but the actual resolution can be configurable by the application.

It could make sense to add the resolution as an additional cell to the io-channels property, which currently only has one cell to select the channel. (see bindings here)

Datasheets

Internal DACs

External DACs (I2C or SPI)

@martinjaeger martinjaeger added Enhancement Changes/Updates/Additions to existing features area: DAC Digital-to-Analog Converter area: API Changes to public APIs Meta A collection of features, enhancements or bugs RFC Request For Comments: want input from the community labels Jul 28, 2020
@nashif nashif removed RFC Request For Comments: want input from the community Meta A collection of features, enhancements or bugs labels Nov 19, 2022
@towen
Copy link

towen commented Nov 21, 2022

Currently, it is not possible to set up a DAC as internally-connected to another peripheral (COMP, OPAMP, for example) because pinctrl-0 is a required property in devicetree.
Also, it would be useful to enable the sawtooth-generation features of the STM32G4 series DACs for power electronics applications
Related issue: #38629

@martinjaeger
Copy link
Member Author

martinjaeger commented Nov 22, 2022

Regarding the sawtooth generation we recently had a discussion to extend the DAC API: #51271 (comment)

This should be fairly straightforward. I will try to come up with a proposal for the API addition in the next days.

Connecting the DAC to other internal peripherals would be more difficult, as we would have to describe this connection in Devicetree in some way. Maybe we could actually use something similar to pinctrl for internal connections.

@jalinei
Copy link

jalinei commented Nov 22, 2022

The elephant in the room IMO is the lack of proper support of the interconnection matrix for STM32 devices. That's a big piece, but it would help a lot, especially for power electronics application, or any other applications that involves having analog routine, or PWM routines independant from the MCU calculation.

@zephyrbot
Copy link
Collaborator

Hi @martinjaeger,

This issue, marked as an Enhancement, was opened a while ago and did not get any traction. It was just assigned to you based on the labels. If you don't consider yourself the right person to address this issue, please re-assing it to the right person.

Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.

Thanks!

@KozhinovAlexander
Copy link
Collaborator

KozhinovAlexander commented Apr 12, 2025

@martinjaeger Is there any progress or solution already?

@martinjaeger
Copy link
Member Author

@martinjaeger Is there any progress or solution already?

Not really. Do you have any specific need?

@KozhinovAlexander
Copy link
Collaborator

KozhinovAlexander commented Apr 14, 2025

@martinjaeger Is there any progress or solution already?

Not really. Do you have any specific need?

Yes, connecting opamp to adc on stm32 for example, if you ask about specific need. Or speaking more general: one peripheral shall pass it's results to the other independently of MCU vendor specific implementation.
I know, it could be solved at the moment for stm32 in particular, but not for all mentioned SoC in the description.

@martinjaeger
Copy link
Member Author

At least for STM32 it's possible to configure the DAC output as "internally connected" (see 834cc98). But it will still require some manual work to define the "consumer" of the DAC output.

@KozhinovAlexander
Copy link
Collaborator

KozhinovAlexander commented Apr 17, 2025

At least for STM32 it's possible to configure the DAC output as "internally connected" (see 834cc98). But it will still require some manual work to define the "consumer" of the DAC output.

Have you thought/heard about interconnect subsystem for zephyr?

Below is the reference for such in Linux Kernel.
https://www.kernel.org/doc/html/v5.2/interconnect/interconnect.html?hl=de-DE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: DAC Digital-to-Analog Converter Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

6 participants