BUG and solution in STM32F0 multi-channel ADC sampling

Publisher:kappa20Latest update time:2018-05-14 Source: eefocusKeywords:STM32F0  BUG Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

uint32_t ADC_Detect(uint32_t  AD_Channel)  

{  

  

    hadc.Instance->CHSELR = 0;  

    ADC_ChannelConfTypeDef sConfig;  

    sConfig.Channel = AD_Channel;  

        sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;  

        sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;  

        HAL_ADC_ConfigChannel(&hadc, &sConfig);  

    

    uint32_t ADC_result;  

    /*ADC START*/  

        if(HAL_ADC_Start(&hadc)!=HAL_OK)  

    {  

        while(1)  

        {  

        }  

    }  

    /*Wait for ADC completed*/  

    if (HAL_ADC_PollForConversion(&hadc, 10) != HAL_OK)  

  {  

     while(1)  

      {  

      }  

  }  

  else  

  {  

    /*Get the converted value of regular channel*/  

    ADC_result = HAL_ADC_GetValue(&hadc);  

        HAL_ADC_Stop(&hadc);  

        //ADC_result =((ADC_result*3300)>>8);  

        return ADC_result;  

  }  

}  

The ADC produced by CUBE cannot be configured with multi-channel sampling, and the multi-channel sampling acquisition value is incorrect. After research, it was found that the underlying function did not clear the CHANNEL.


Just add hadc.Instance->CHSELR = 0; in the function to manually clear the register. 


Keywords:STM32F0  BUG Reference address:BUG and solution in STM32F0 multi-channel ADC sampling

Previous article:STM32F0 ADC learning
Next article:Conclusion of using STM32F030 WWDG

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号