AD channel interference problem in STM32

Source: Internet
Author: User

Today Debug stm32f103 ADC, using the ADC1 single conversion mode for two-channel ad sampling, found that there are two channels of annoyance. The relevant ad operation code is as follows:

voidadc_start_convert (uint8_t ch) {ADC1->SMPR2 = (ADC1->SMPR2 &0xfffffff8) |7; ADC1->SQR3 = (ADC1->SQR3 &0xffffffe0) |ch; Adc_softwarestartconvcmd (ADC1, ENABLE);} uint8_t Adc_is_convert_finish (void){    if((adc1->sr&0x02) ==0)        return 0; Else        return 1;} uint16_t Adc_get_value (void){    returnADC1DR;}

After many times of debugging, the final solution is as follows:

1. Modify the ADC clock frequency

Rcc_adcclkconfig (RCC_PCLK2_DIV8);

2. Modify the ADC start conversion function

void adc_start_convert (uint8_t ch) {    1, adc_sampletime_13cycles5); //      adc1->smpr2 = (adc1->smpr2 & 0XFFFFFFF8) | 7; //      ADC1->SQR3 = (ADC1->SQR3 & 0xffffffe0) | ch;     adc_softwarestartconvcmd (ADC1, ENABLE);}

For the Solution Step (2), the method of using the STM32 official library and the way of the direct operation register should be consistent in theory, but the measured results show that there is still interference in the way of using the direct operation register. The problem failed to find the cause.

AD channel interference problem in STM32

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.