Digital-to-Analog Converter (DAC)

Overview

This sample demonstrates how to use the DAC driver API.

Building and Running

The DAC output is defined in the board’s devicetree and pinmux file.

Building and Running for ST Nucleo L073RZ

The sample can be built and executed for the ST Nucleo L073RZ as follows:

west build -b nucleo_l073rz samples/drivers/dac
west flash

Building and Running for ST Nucleo L152RE

The sample can be built and executed for the ST Nucleo L152RE as follows:

west build -b nucleo_l152re samples/drivers/dac
west flash

Building and Running for NXP TWR-KE18F

The sample can be built and executed for the NXP TWR-KE18F as follows:

west build -b twr_ke18f samples/drivers/dac
west flash

DAC output is available on pin A32 of the primary TWR elevator connector.

Building and Running for NXP FRDM-K64F

The sample can be built and executed for the NXP FRDM-K64F as follows:

west build -b frdm_k64f samples/drivers/dac
west flash

DAC output is available on connector J4 pin 11.

Sample output

You should see a sawtooth signal with an amplitude of the DAC reference voltage and a period of approx. 4 seconds at the DAC output pin specified by the board.

The following output is printed:

Generating sawtooth signal at DAC channel 1.

Note

If the DAC is not supported, the output will be an error message.