Skip to main content
Explorer
January 4, 2024
Solved

USB VBUS_SENSE on STM32U5A9NJ Discovery Kit

  • January 4, 2024
  • 3 replies
  • 2914 views

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.

    This topic has been closed for replies.
    Best answer by Mike_ST

    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).

    3 replies

    Mike_STAnswer
    Technical Moderator
    January 5, 2024

    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).

    jcmoreauAuthor
    Explorer
    January 5, 2024

    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? 

    Technical Moderator
    January 8, 2024

    Hello,

    I attached a .ioc file and a main.c file  to open with the STM32CubeIDE.

    Please compile the project, and check whether you get a value close to the expected one.

    If it's working, it can help to compare the settings.

    jcmoreauAuthor
    Explorer
    January 8, 2024

    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.

     
     
     
     

     

    jcmoreauAuthor
    Explorer
    January 8, 2024

    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).