2024-01-04 02:23 PM
I am experimenting with the USB HS peripheral on the STM32U5A9NJ Discovery Kit, and noticed that there is a signal called VBUS_SENSE which is routed to PG1 (ADC4 IN8). I've configured ADC4 to sample from this pin, and notice that the sensed voltage is ~0.14V with the USB connected, and 0.0 with the USB disconnected. Is this the expected behavior? I would have expected to see a higher voltage with the USB cable connected. What is the maximum possible voltage for VBUS_SENSE? My ADC resolution is set to 12 bits, sampling time is 814.5, and Vref+ is 1.8.
Solved! Go to Solution.
2024-01-05 05:20 AM
Hello,
>> Is this the expected behavior ?
>> What is the maximum possible voltage for VBUS_SENSE?
Expect around 0.38V when USB is connected.
Try to set PE9 as output to 1 (DBn signal), so the TCPP01 will trigger the Q1 transistor.
Check if you have 5V on the 5V_UCPD net (JP4 Pin 5).
2024-01-05 05:20 AM
Hello,
>> Is this the expected behavior ?
>> What is the maximum possible voltage for VBUS_SENSE?
Expect around 0.38V when USB is connected.
Try to set PE9 as output to 1 (DBn signal), so the TCPP01 will trigger the Q1 transistor.
Check if you have 5V on the 5V_UCPD net (JP4 Pin 5).
2024-01-05 10:40 AM
Hello Mike,
Thanks for your answer. I measure 5.1V on JP4 Pin 5 using a DMM. I still see the same ~0.14V on PG1 with the USBC cable connected when I set PE9 high. Just to make sure I had ADC4 configured correctly, I verified that I was able to accurately measure the 1V8 output by connecting it to PA4 on CN9. Is there anything else which may be causing this discrepancy?
2024-01-08 03:27 AM
2024-01-08 08:48 AM
I wasn't able to see any output from the program defined by the .ioc, looks like maybe the UART pins weren't configured.
However, when I use the voltage divider values implied by R1 and R2 in main.c, I get readings much closer to 1.8V with the cable connected, and 0 with it disconnected. For reference, my (new) formula for calculating voltage using raw ADC readings is
result = (1.8f / 4095) * raw_result * ((27 + 330) / 27);
Maybe there's another divider somewhere upstream.
2024-01-08 11:32 AM - edited 2024-01-08 12:52 PM
My ADC4 was not configured correctly, I missed this note in the data sheet:
Note:
The ADC4 analog block clock frequency must be between 140 kHz and 55 MHz.
After correcting this (applied 8x prescaler in ADC4 CCR), I read ~3.7V (651 / 4095 = ~0.286V) with the USB connected.
Edit 2: Found a second error in my ADC4 configuration which caused my sampling period to be set to 1.5 ADC cycles instead of 814.5. After correcting this I am reading 5V (after adjusting for voltage divider).