cancel
Showing results for 
Search instead for 
Did you mean: 

VBUS Sensing on STM32N6

Panda
Associate III

Hello,

I have a question regarding VBUS sensing on STM32N6.

First off, I found the

Guide to USB development resources on STM32

https://community.st.com/t5/stm32-mcus/guide-to-usb-development-resources-on-stm32/ta-p/790803

I also read AN 4879.

 

I want to use OTG1 of my MCU to establish a USB connection to my PC. The MCU is a self-powered device.

Since it's a self-powered device, VBUS sensing becomes mandatory.

In all ressources it is written that PA9 (or PB13) are used for VBUS sensing and are 5V tolerant.

 

However, on the STM32N6, it seems that:

- PA9 is not 5V tolerant

- there is no mentioning of VBUS sensing functionality to this pin.

 

The datasheet returns nothing if I search for VBUS.

The Ref Manual 0486,Rev2 has a chapter 72.2.6 about VBUS detection but it doesn't help me much.

 

But page 3750 states the following:

If needed, VBUS detection must be managed by an ADC channel or an external
comparator. It cannot be managed by OTGPHY1 since it is forced in external comparator mode and not connected to VBUS.

VBUS comparison with Vsafe0v and Vsafe5v thresholds is performed by an ADC. An
external resistor bridge is required to scale down VBUS to the 1V8 range of the ADC channel input.

 

So from this I understand that there is no dedicated Pin for this functionality on my MCU and it must be implemented trough the ADC (and for this brought down to 1,8V)

But why "if needed" - Does this imply I don't need it?

 

I would greatly appreciate if someone could take a minute to help me understand this.

 

Thanks!

Lucas

3 REPLIES 3
TDK
Super User

> But why "if needed" - Does this imply I don't need it?

"If needed" related to whether your device is bus powered or self powered.

If your device is bus powered, you don't need to monitor VBUS.

In your case, since your device is self-powered, you need to monitor VBUS.

If you feel a post has answered your question, please click "Accept as Solution".
Panda
Associate III

Okay, thank you for clarifying.

So I have to handle the monitoring myself? And If yes, what does this mean in terms of implementation?

 

Is it an extra piece of code to monitor VUSB and connect the internal Pullup to D+ or is there more to it?

 

Thanks

Lucas

Run something like this every 5ms or so. The USB spec may have a requirement on the timeline. If this is a commercial device, I would consult that.

if vbus_present:
  initialize usb if not initialized
else:
  de-initialize usb if initialized

 

If you feel a post has answered your question, please click "Accept as Solution".