AnalogueIn reading inaccurate

Hi community,

I am trying to track the voltage of a backup li-ion battery. Voltage is first divided into half via a resistor ladder and then fed into AnalogueIn on mbed (through 90mm trace on PCB, a bit too long probably). The readings via Bbed seems always 0.25 ~ 0.5V lower than actual readings by multimeter.

The following is my test. I repeatedly measure every 5 seconds. The first reading after downloading firmware is usually very close to actual, but starting from 2nd reading, it will drop and eventually quite lower than actual.

Is there anything I can do? It would be nice to not have readings so off.

AnalogIn Test Started with PoE and AC ADC:
1659344868: Current Voltage = 4156mv
1659344873: Current Voltage = 4127mv
1659344878: Current Voltage = 4043mv
1659344883: Current Voltage = 4045mv
1659344888: Current Voltage = 4050mv
1659344893: Current Voltage = 4045mv
1659344898: Current Voltage = 4051mv
1659344903: Current Voltage = 4043mv
1659344908: Current Voltage = 4047mv
1659344913: Current Voltage = 4048mv
1659344918: Current Voltage = 4045mv

I would say that is very dependent on the used MCU. What is the reference voltage? External or internal?

STM32F767ZI, and VCC/3/3V is used as reference.

I think this is a good point, I didn’t have this problem when I was using STM32F429ZI on pretty much the same PCB. We only moved pin assignment a bit after switching to F767ZI. Is there anything I can do to mitigate this?

The problem was on hardware side. The resistors in the voltage divider exceeded the maxim recommended value by MCU datasheet. Once those resistors are replaced with smaller ones that are within recommended range, measurement is very close to actual values.