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.
Previous article:STM32F0 ADC learning
Next article:Conclusion of using STM32F030 WWDG
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- Purgatory Legend-Battle of Doubler Circuits
- 29 "Wanli" Raspberry Pi car - straight-driving deviation problem and new control mode
- Bluetooth remote control serial port problem
- How to test the performance parameters of op amps, such as bandwidth, noise and slew rate?
- Application of Dacai UART screen in air detector
- [Serial] [Starlight Lightning STM32F407 Development Board] Chapter 13 FLASH Data Storage Experiment
- How do different power supplies affect the dynamic performance of the op amp?
- DSP28335 serial port interruption problem
- How to make an echo on atmel/AVR microcontroller Atmega 128? Is there any relevant information?
- I would like to ask about the error in the CD4093 schematic symbol in AD.