STMicroelectronics / x-cube-tcpp

STM32 expansion package providing an integrated solution for a robust protection of MCU-based USB Type-C applications
https://www.st.com/content/st_com/en/stm32-usb-c.html
Other
25 stars 9 forks source link

Isense and Vbus ADC measurement inaccuracies #8

Open Erlkoenig90 opened 7 months ago

Erlkoenig90 commented 7 months ago

Describe the set-up

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:

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.

HFISTM commented 6 months ago

ST Internal Reference: 173465