Skip to main content
Graduate
April 3, 2024
Solved

STM32L072 USB

  • April 3, 2024
  • 5 replies
  • 1887 views

Hi all,

A USB device should pull up DP when it detects VBUS power only. This is described in the USB standards and ST AN4879 factsheet. Question 1. Is there any other (smarter) way with the STM32L072 than to monitor VBUS power on a GPIO yourself (via resistor voltage devider or active cirquit) and then toggle DPPU bit of USB_BCDR register yourself when input value of GPIO changes to implement this function? Question 2. Or is it normal to just set + leave DPPU bit high always (which implies that the device you are making is not really USB complient)? My bigger question off course is: how do I implement a complient USB device with a STML072?

Greetz & thanks,

Jan

    This topic has been closed for replies.
    Best answer by Pavel A.

    Yes looks so. You can also use this to detect surprise-removal or unplug of USB cable and act accordingly (for example if you have pending data to send to the host)

     

    5 replies

    Super User
    April 3, 2024

    Bus-powered devices do not need to detect VBUS.

     

     

    JanAtzeAuthor
    Graduate
    April 3, 2024

    It’s a self-powered device, sorry for not mentioning.

    My question remains.

    Kind regards,

    Jan

    Super User
    April 3, 2024

    Why it is so hard to just follow the standard requirement?

    JanAtzeAuthor
    Graduate
    April 3, 2024

    So I have to measure VBUS with a GPIO (in a loop, with a timer, interrupt on change) and set DPPU bit according?

    Pavel A.Answer
    Super User
    April 4, 2024

    Yes looks so. You can also use this to detect surprise-removal or unplug of USB cable and act accordingly (for example if you have pending data to send to the host)

     

    JanAtzeAuthor
    Graduate
    April 4, 2024

    Okay, thanks, and one more question. If I leave DP+ high (DPPU bit = 1) all the time (read: don't sync DP+ pull-up with VBUS 5V). What will be the troubles that I face in my (self-powered) USB (device) solution?

    Super User
    April 4, 2024

    I don't know but usb.org has some procedures for testing device compliance. You can run your device & firmware thru their test.