zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.62k stars 6.5k forks source link

DAC features and API enhancements #27191

Open martinjaeger opened 4 years ago

martinjaeger commented 4 years ago

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

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)

towen commented 1 year ago

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 commented 1 year ago

Regarding the sawtooth generation we recently had a discussion to extend the DAC API: https://github.com/zephyrproject-rtos/zephyr/pull/51271#issuecomment-1303061312

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 commented 1 year ago

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 commented 8 months ago

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!