# DAC - poll

Source: [https://docs.qualcomm.com/doc/80-58740-4/topic/dac-poll.html](https://docs.qualcomm.com/doc/80-58740-4/topic/dac-poll.html)

This demo mainly introduces the generation of sine wave based on DAC polling mode.

## Hardware connection

The GPIO used in this demo refers to `board_adc_gpio_init`.

## Software implementation

For more detailed code, refer to
                    examples/peripherals/dac/dac\_polling.

    board_init();Copy to clipboard

- `board_init` turns on the DAC IP clock and select the DAC clock
                    source and frequency division.

    board_dac_gpio_init();Copy to clipboard

- Configure related pins as `DAC` function

    dac = qcc74x_device_get_by_name("dac");
    
    qcc74x_dac_init(dac, DAC_SAMPLING_FREQ_32K);Copy to clipboard

- Get the `dac` handle and initialize the DAC frequency to 32K

    qcc74x_dac_channel_enable(dac, DAC_CHANNEL_A);Copy to clipboard

- Configure DAC channel, currently used A channel

    for (uint16_t i = 0; i < sizeof(SIN_LIST) / sizeof(uint16_t); i++) {
        qcc74x_dac_set_value(dac, DAC_CHANNEL_A, SIN_LIST[i]);
        qcc74x_mtimer_delay_us(100);
    }Copy to clipboard

- Call `qcc74x_dac_set_value(dac, DAC_CHANNEL_A, SIN_LIST[i])` to
                    output the data to be converted through channel A

## Experimental phenomena

The GPIO corresponding to DAC Channel A outputs a sine wave.

**Parent Topic:** [DAC](https://docs.qualcomm.com/doc/80-58740-4/topic/dac.html)

Last Published: Feb 10, 2025

[Previous Topic
DAC](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/dac.md) [Next Topic
DAC - dma](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/dac-dma.md)