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.
The board’s /zephyr,user node must have dac
,
dac-channel-id
, and dac-resolution
properties set. See the predefined
overlays in samples/drivers/dac/boards for examples.
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 ST Nucleo F767ZI¶
The sample can be built and executed for the ST Nucleo F767ZI as follows:
west build -b nucleo_f767zi samples/drivers/dac
west flash
Building and Running for ST Disco F3¶
The sample can be built and executed for the ST STM32F3 Discovery as follows:
west build -b stm32f3_disco samples/drivers/dac
west flash
Building and Running for ST Nucleo F429ZI¶
The sample can be built and executed for the ST Nucleo F429ZI as follows:
west build -b nucleo_f429zi samples/drivers/dac
west flash
Building and Running for STM32L562E DK¶
The sample can be built and executed for the ST STM32L562E-DK Discovery as follows:
west build -b stm32l562e_dk samples/drivers/dac
west flash
Building and Running for ST Nucleo L552ZE Q¶
The sample can be built and executed for the ST Nucleo L552ZE Q as follows:
west build -b nucleo_l552ze_q 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.
Building and Running for BL652¶
The BL652 DVK PCB contains a footprint for a MCP4725 to use as an external DAC. Note this is not populated by default. The sample can be built and executed for the Laird Connectivity BL652 DVK as follows:
west build -b bl652_dvk samples/drivers/dac
west flash
DAC output is available on pin 1 of the MCP4725.
Building and Running for BL653¶
The BL653 DVK PCB contains a footprint for a MCP4725 to use as an external DAC. Note this is not populated by default. The sample can be built and executed for the Laird Connectivity BL653 DVK as follows:
west build -b bl653_dvk samples/drivers/dac
west flash
DAC output is available on pin 1 of the MCP4725.
Building and Running for BL654¶
The BL654 DVK PCB contains a footprint for a MCP4725 to use as an external DAC. Note this is not populated by default. The sample can be built and executed for the Laird Connectivity BL654 DVK as follows:
west build -b bl654_dvk samples/drivers/dac
west flash
DAC output is available on pin 1 of the MCP4725.
Building and Running for BL5340¶
The BL5340 DVK PCB contains a MCP4725 to use as a DAC. The sample can be built and executed for the Laird Connectivity BL5340 DVK as follows:
west build -b bl5340_dvk_cpuapp samples/drivers/dac
west flash
DAC output is available on pin 1 of the MCP4725.
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.