cancel
Showing results for 
Search instead for 
Did you mean: 

How to manage fast role swap (FRS) in an STM32

FBL
ST Employee

Introduction

The USB Type-C® and USB PD specifications revolutionized device connectivity by merging data transfer and power delivery for up to 240 W (with EPR in USB PD 3.1). A key feature, fast role swap (FRS), allows a power supplying device quickly switch to a power-consuming role when it is subject to a power outage.

1. Why use fast role swap?

Let us consider a common scenario where a PC is connected to a docking station. The docking station acts as the power source, while the PC is the sink. If the docking station loses power, it must quickly signal an FRS to the laptop, which then becomes the new power source. 

So, FRS is designed to ensure continuous power supply and preventing data loss during unexpected power interruptions. It allows devices to remain powered under different conditions. A device must switch from sinking power to sourcing power quickly enough to avoid any interruption. 

2. Overview of fast role swap specifications

Here is the full sequence extracted from USB PD specifications. The interaction of the policy engine (PE), user application, and PHY layer during a fast role swap involves several steps and timing parameters.USB-IF: USB Power Delivery Specification Revision 3.0, Version 2.0, August 29, 2019, page 296USB-IF: USB Power Delivery Specification Revision 3.0, Version 2.0, August 29, 2019, page 296

According to the specification, the critical point in the diagram is the time between when the source triggers the fast role swap (FRS) and when the sink becomes the source. During this time, the VBUS voltage drops and switches sources. This time interval must be very short to avoid disrupting the connected devices. This transition must happen within 150μs to prevent any disruption.

3. STM32 implementation of fast role swap

UCPD controller in STM32 fully manages standard role swap. Optionally, it can support fast role swap on some dual-role power controllers also called DRPs. FRS signaling and detection is detailed in section 13.4 in AN5225. Below is a summary of the messages involved in the fast role swap process after the source stops sourcing VBUS upon detecting a power outage.

                       Old source                                                                         Old sink

FBL_0-1733132662609.png

 


4. Summary of messages

  1. Fast role swap request: The policy engine sends a fast role swap request. When VBUS < vSafe5V (min), it instructs the device policy manager (DPM) not to draw more than iSnkStdby until the tSnkFRSwap timer elapses.
  2. Fast role swap acknowledgment: The PHY layer acknowledges the swap request with a GOODCRC message.
  3. Power swap answer: The PD stack waits for an answer to the power swap request.
  4. Swap acceptance: The PHY layer confirms the swap acceptance with a GOODCRC message.
  5. Notify swap accepted: The PE notifies the application that the power swap request has been accepted.
  6. Notify state change: The PE notifies the application of the power state change.
  7. Wait for PS_RDY: The core stack waits for a PS_RDY message from the new source. When VBUS < vSafe5V, the new source shall provide power to VBUS within tSrcFRSwap.
  8. PS_RDY confirmation: The PHY layer confirms the readiness with a GOODCRC message.
  9. Assert Rp: The old sink asserts Rp to indicate it is ready to provide power.
  10. PS_RDY confirmation: The PHY layer confirms the readiness with a GOODCRC message.
  11. Power role swap initiation: The PE initiates the power role swap process, changing from sink to source.
  12. Wait swap timer: The PE waits for the swap timer to complete.
  13. Power role swap completion: The power role swap process is completed.
  14. Set data info: The user application sets the data info for the new role of sink/source and stores the received Sink request PDO.
  15. Notify State change: The core stack notifies the application of the power state change and the swap to source is complete.
  16. Source startup.
  17. Send capabilities: The new source sends its power capabilities to the new sink.

According to your application, you need to manage VBUS monitoring properly in your end application.

Note: When operating as a source, you need to manage how to detect the disruption of the power supply and let the source trigger FRS. 

For more details, check section 11.3.5 dual-role power port with FRS in AN5225.

Conclusion

The fast role swap feature is essential for maintaining uninterrupted power supply in USB, especially in scenarios where the primary power source fails. By leveraging the advanced capabilities of STM32, you can implement fast role swap efficiently, ensuring robust and reliable power delivery for your devices.

Related links

Version history
Last update:
‎2024-12-09 07:44 AM
Updated by: