Module dac

Module dac 

Source
Expand description

§Digital to Analog Converter (DAC)

§Overview

Espressif devices usually have multiple DAC channels. Each DAC channel can convert the digital value 0~255 to the analog voltage 0~Vref (The reference voltage ‘Vref’ here is input from an input pin)

The DAC peripheral supports outputting analog signal in the multiple ways.

Two 8-bit DAC channels are available.

§Configuration

Developers can choose the DAC channel they want to use based on the GPIO pin assignments for each channel.

§Examples

§Write a value to a DAC channel

let mut dac1 = Dac::new(peripherals.DAC1, peripherals.GPIO25);

let mut delay = Delay::new();

let mut voltage_dac1 = 200u8;

// Change voltage on the pins using write function:
loop {
    voltage_dac1 = voltage_dac1.wrapping_add(1);
    dac1.write(voltage_dac1);

    delay.delay_ms(50u32);
}

Structs§

Dac
Digital-to-Analog Converter (DAC) Channel