Fix: start calibration on STM32F3

Dependencies:   mbed

Fork of AnalogIn-HelloWorld by Mbed

The AnalogIn reading for STM32F303K8 and STM334R8 is too low. However after adding call on HAL_ADCEx_Calibration_Start the reading is correct.

mbed do not start adc calibration for STM32F3 mcu's ?

main.cpp

Committer:
foggyfish
Date:
2017-05-01
Revision:
2:d6c44780c91b
Parent:
0:101a12a915c6

File content as of revision 2:d6c44780c91b:

 
#include "mbed.h"


AnalogIn   ain(A5);
Serial pc(USBTX, USBRX); 


int main(void)
{
    //Starts ADC Calibration
    //Correct's bug in mbed for F303K8 and F334R8. 
    //mbed do not start adc calibration for STM32F3 mcu's ?
    extern ADC_HandleTypeDef AdcHandle;
    HAL_ADCEx_Calibration_Start(&AdcHandle, ADC_SINGLE_ENDED); 
    
    int nr = 0;           
    while (1) {
        nr++;
        pc.printf("nr  : %d\n", nr);
        pc.printf("normalized: %d \n", ain.read_u16());
        pc.printf("volt: %3.3f\n\n", ain.read()*3.3 );
        wait(1);
    }
}