I have make an STM32F030F4P6 board for reading analog values. When I connect the analog pin to vcc the value is 4095, instead when I connect the analog pin to GND the value isn't 0. How can I solve the problem?

The schematic project:

enter image description here

  • 1
    \$\begingroup\$ "the value isn't 0" - ok - so what is it? \$\endgroup\$
    – brhans
    Oct 2 '18 at 15:25
  • \$\begingroup\$ the value is between 100 and 300 \$\endgroup\$ Oct 2 '18 at 16:02
  • \$\begingroup\$ Is the system you're integrating this into one where you can "zero" it when it initializes? \$\endgroup\$ Oct 2 '18 at 17:50
  • \$\begingroup\$ I don't know ! I use a STM32F030F4P6 mcu as in the schematic project. \$\endgroup\$ Oct 2 '18 at 18:20
  • \$\begingroup\$ You need to read the data sheet for the device and pay particular attention to the ADC part. Maybe you should cut and paste the section table for the ADC. \$\endgroup\$
    – Andy aka
    Oct 2 '18 at 18:24

You should check out chapter 12.4.1 of the Reference Manual. The STM32 can calibrate its own ADC perhipal! Offset error is a common problem for internal ADCs in microcontrollers I've encountered so far.

The calibration can be done by the following steps:

  1. Ensure that ADEN=0 and DMAEN=0
  2. Set ADCAL=1
  3. Wait until ADCAL=0
  4. The calibration factor can be read from bits 6:0 of ADC_DR

This can be a problem of your layout. Maybe the ground is not routed ideally and you have a slight voltage difference in your system.

Have you measured the voltage difference between the controller ground and your analog pin pulled to ground?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.