x-cube-tcpp icon indicating copy to clipboard operation
x-cube-tcpp copied to clipboard

Isense and Vbus ADC measurement inaccuracies

Open Erlkoenig90 opened this issue 1 year ago • 1 comments

Describe the set-up

  • NUCLEO-G474RE + X-NUCLEO-SRC1M1
  • STM32CubeIDE Version: 1.14.1

Describe the bug The measured Isense current and Vbus voltages are somewhat inaccurate (significantly too low) when compared to multimeter measurements.

How To Reproduce

  1. Compile & Run the project Projects\NUCLEO-G474RE\Applications\USB_PD\SNK1M1_Sink.

  2. Provide a power supply to CN3 and measure the current.

  3. Run STM32CubeMonitor-UCPD.

  4. Compare the displayed Ibus with the manual measurement.

Additional context The ADC calibration is disabled for the STM32G474. This results in a significant offset of the ADC values. In a simple test project, using the ADC without calibration yields similar offsets. Performing the calibration as shown eliminates this issue:

LL_ADC_StartCalibration(VISENSE_ADC_INSTANCE, LL_ADC_SINGLE_ENDED);

Additionally, the two conversion formulas (voltage, current) use VDD_VALUE to calculate the actual voltage:

vadc = (ADCData * VDD_VALUE) / ADC_FULL_SCALE;

However, when jumper JP8 on the NUCLEO board is set to position 1-2, the external reference voltage with value 3.25V is used. This is the default. The two solutions would be:

  • Replace VDD_VALUE by 3250
  • The documentation for the X-NUCLEO-SRC1M1 or for x-cube-tcpp should indicate that JP8 needs to be set to 2-3

Since the measurements are not ratiometric, and the absolute values of both voltages are of interest, it would be desirable to keep using the fixed reference of 3.25V, and adjust the code accordingly.

Erlkoenig90 avatar Feb 08 '24 16:02 Erlkoenig90

ST Internal Reference: 173465

HFISTM avatar Feb 29 '24 08:02 HFISTM