Calibrating the STM32F334 ADC
class OpenAnalogIn: public AnalogIn { public: OpenAnalogIn(PinName pin) : AnalogIn(pin) { }; analogin_t * getADC() { return &_adc; }; };
OpenAnalogIn firstVoltageADC(A0);
void setup_ADC() {
ADC_HandleTypeDef AdcHandle; Calibrate ADC AdcHandle.Instance = (ADC_TypeDef *)(firstVoltageADC.getADC()->adc); HAL_ADCEx_Calibration_Start(&AdcHandle,ADC_SINGLE_ENDED); }
then use (as usual)
float firstVoltage=firstVoltageADC.read();
Please log in to post comments.