# ADC - poll\_diff\_mode Source: [https://docs.qualcomm.com/doc/80-58740-4/topic/adc-poll-diff-mode.html](https://docs.qualcomm.com/doc/80-58740-4/topic/adc-poll-diff-mode.html) This demo mainly demonstrates reading the voltage values of channel 2 and channel 3 in ADC poll differential 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/adc/adc\_poll\_diff\_mode. board_init();Copy to clipboard - The ADC IP clock is turned on in `board_init`, and the ADC clock source and frequency division will be selected (the ADC clock must be less than or equal to 500K). board_adc_gpio_init();Copy to clipboard - Configure related pins as `ADC` function adc = qcc74x_device_get_by_name("adc"); /* adc clock = XCLK / 2 / 32 */ struct qcc74x_adc_config_s cfg; cfg.clk_div = ADC_CLK_DIV_32; cfg.scan_conv_mode = true; cfg.continuous_conv_mode = false; cfg.differential_mode = true; cfg.resolution = ADC_RESOLUTION_16B; cfg.vref = ADC_VREF_3P2V; qcc74x_adc_init(adc, &cfg);Copy to clipboard - Get the `adc` handle, initialize the ADC configuration, and set the ADC sampling frequency to 500K qcc74x_adc_channel_config(adc, chan, TEST_ADC_CHANNELS);Copy to clipboard - Configure channel 2 and channel 3 for (uint32_t i = 0; i < TEST_COUNT; i++) { qcc74x_adc_start_conversion(adc); while (qcc74x_adc_get_count(adc) < TEST_ADC_CHANNELS) { qcc74x_mtimer_delay_ms(1); } for (size_t j = 0; j < TEST_ADC_CHANNELS; j++) { struct qcc74x_adc_result_s result; uint32_t raw_data = qcc74x_adc_read_raw(adc); printf("raw data:%08x\r\n", raw_data); qcc74x_adc_parse_result(adc, &raw_data, &result, 1); printf("pos chan %d,neg chan %d,%d mv \r\n", result.pos_chan, result.neg_chan, result.millivolt); } qcc74x_adc_stop_conversion(adc); qcc74x_mtimer_delay_ms(100); }Copy to clipboard - Call `qcc74x_adc_start_conversion(adc)` to enable conversion of ADC - Call `qcc74x_adc_get_count(adc)` to read the number of completed conversions - Call `qcc74x_adc_read_raw(adc)` to read the conversion value of ADC once - Call `qcc74x_adc_parse_result(adc, &raw_data, &result, 1)` to parse the conversion result of ADC, and save the parsed value to the `result` structure - Call `qcc74x_adc_stop_conversion(adc)` to stop ADC conversion ## Experimental phenomena Print raw data, positive and negative channel numbers and corresponding voltage differences. **Parent Topic:** [ADC](https://docs.qualcomm.com/doc/80-58740-4/topic/adc.html) Last Published: Feb 10, 2025 [Previous Topic ADC - int](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/adc-int.md) [Next Topic ADC - tsen](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/adc-tsen.md)