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 ?

Committer:
foggyfish
Date:
Mon May 01 18:15:24 2017 +0000
Revision:
2:d6c44780c91b
Parent:
0:101a12a915c6
FIX: start calibration on stm32F3 ADC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:101a12a915c6 1
sam_grove 0:101a12a915c6 2 #include "mbed.h"
sam_grove 0:101a12a915c6 3
foggyfish 2:d6c44780c91b 4
foggyfish 2:d6c44780c91b 5 AnalogIn ain(A5);
foggyfish 2:d6c44780c91b 6 Serial pc(USBTX, USBRX);
foggyfish 2:d6c44780c91b 7
sam_grove 0:101a12a915c6 8
sam_grove 0:101a12a915c6 9 int main(void)
sam_grove 0:101a12a915c6 10 {
foggyfish 2:d6c44780c91b 11 //Starts ADC Calibration
foggyfish 2:d6c44780c91b 12 //Correct's bug in mbed for F303K8 and F334R8.
foggyfish 2:d6c44780c91b 13 //mbed do not start adc calibration for STM32F3 mcu's ?
foggyfish 2:d6c44780c91b 14 extern ADC_HandleTypeDef AdcHandle;
foggyfish 2:d6c44780c91b 15 HAL_ADCEx_Calibration_Start(&AdcHandle, ADC_SINGLE_ENDED);
foggyfish 2:d6c44780c91b 16
foggyfish 2:d6c44780c91b 17 int nr = 0;
sam_grove 0:101a12a915c6 18 while (1) {
foggyfish 2:d6c44780c91b 19 nr++;
foggyfish 2:d6c44780c91b 20 pc.printf("nr : %d\n", nr);
foggyfish 2:d6c44780c91b 21 pc.printf("normalized: %d \n", ain.read_u16());
foggyfish 2:d6c44780c91b 22 pc.printf("volt: %3.3f\n\n", ain.read()*3.3 );
foggyfish 2:d6c44780c91b 23 wait(1);
sam_grove 0:101a12a915c6 24 }
sam_grove 0:101a12a915c6 25 }