First we have to start the ADC in the interrupt mode by using the function below HAL_ADC_Start_IT (&hadc1); HAL_ADC_GetValuereads the value from ADC and stores it in the variable adc_val . Also note that if the continuousconversion mode is disabled, ADC will stop here and we have to again start the conversion in interrupt mode
HAL_ADC_Start (&hadc1); // start the adc HAL_ADC_PollForConversion (&hadc1, 100); // poll for conversion adc_val = HAL_ADC_GetValue (&hadc1); // get the adc value HAL_ADC_Stop (&hadc1); // stop adc HAL_Delay (500); // wait for 500ms
ADC PROGRAMMING EXERCISES STM32-based system for monitoring air quality using a gas sensor with analog output. Embedded application using STM32 ADC to measure the output voltage of a solar panel for energy monitoring. STM32-based system for monitoring soil moisture using a capacitive soil moisture sensor. Light-dependent resistor (LDR) to measure ambient light intensity using the STM32 ADC.