This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TPS65987DDJ: How to change Power role from Sink to Source dynamically at runtime with an I2C command?

Part Number: TPS65987DDJ
Other Parts Discussed in Thread: TPS65987DJEVM, TPS65987, TPS65987D

Hi,

I'm evaluating TPS65987DDJ capabilities using TPS65987DJEVM evaluation board which is connected to an iPad has a builtin USB-C port.

I want the evaluation board to be configured as a Sink device requires 5V and 100mA only.

And iPad will be forced to be a Host in this case.

I managed to have above configuration using TPS65987_8_HOST Application Customization 6.2.1 and following steps in the pictures:

After that I created a Full Flash Image and burned it into the external Flash memory using TIVA on the eval board. After a power cycle, I observed that new settings are activated and TPS65987DDJ behaves as expected.

So far so good.

Now I want to send some I2C commands to the eval board at runtime to change the behavior of it from Sink device to a source device. I meant that the eval board Data role should remain same as a device but power role should be changed to a Source so that I can see that iPad starts being charged from the eval board without losing existing data communication on the USB data lines.

What I have tried simply is that in the Application Customization Tool -> enabled the Debug mode then Device 1, port1 tab -> Commands tab- > Swap to Source in the listbox, Click Execute SWSr, but nothing changed. (the eval board is still sink?)

How can I achieve my objective?

Regards,

  • Hi Mehmet,

    Please take a look at register 0x29 Port Control and make sure the settings for Process Swap to Sink/Source are enabled. Based on your description, it seems like the EVM is only configured to be a sink role if the 4cc command 'SWSr' is not responding correctly. 

    Thanks and Regards,

    Raymond Lin

  • Hi Raymond,

    I have created a DRP role as well by creating a new project based on DDJ template.

    Here is how 0x29 looks like:

    And 0x28:

    0x38:

    0x33:

    But still nothing changes when I click Execute SWSr.

  • Hi Mehmet, 

    Just to make sure the EVM setup is correct, do you have the barrel jack connected to the EVM? Without system power, the TPS65987 will not be able to swap to source successfully. 

    Thanks and Regards,

    Raymond Lin

  • Hi Raymond,

    I have checked all jumper positions and barrel jack is connected to an external 19.5V adapter like you suggested previously. I believed that the setup is correct. 

    I have noticed that iPad started being charged when I insisted clicking Execute SWSr button a few times and waiting some time like 20secs.

    As I see I can switch the power roles with a lag about 20secs. Is that normal? I was expecting it to be immediate.

    One important issue which can be a blocker for us is that Data connection is being lost and restores automatically while switching between Power roles. The iPad behaves as if I disconnected the cable and connect back with a new power role each time when I switch the roles.

    In our product, this is not acceptable, data communication should not be interrupted during power role switches. Any idea why this can happen?

    Thank you.

  • Hi Mehmet, 

    Let me see if I can replicate it from my end and let you know my findings. 

    Thanks and Regards,

    Raymond Lin

  • Hi Mehmet, 

    Can you try this setup with a different connected device other than the iPad? 

    Thanks and Regards,
    Raymond Lin

  • Hi Raymond,

    I followed the instruction in Power and Data Role Swaps App note and TRM and attached configuration swaps the power roles without any latency which is cool. But loosing the existing data connection during swapping is still persist on both my iPad which has direct USB-C port and also on my Dell XPS 13 Notebook has direct USB-C with Windows 11.

     TEST_UFP_DDJ_Test.zip

    Any idea not to loose existing data communication?

    I think the Application Customization tool initiates a kind of reset command with SWSk (Swap to Sink) and SWSr (Swap to Source) commands which also affects/resets the existing data role. I believed that this should not be necessary because I saw some devices from Samsung which can swap power roles without loosing existing data communication.

  • Hi Mehmet,

    Sorry we missed this.

    Raymond is currently out of office until next week.

    We will try to take a look and get back to you.

    Thanks and Regards,

    Chris

  • Hi Mehmet,

    SWSk and SWSr should not be resetting the data role and is more likely related to how devices are being powered. Can you go into more detail about your test situation and how you are determining that the data communication is lost?

    Thanks and Regards,
    Chris

  • Hi Christopher,

    Sorry I have missed your message here.

    We have an USB-C to ethernet adaptor,  something like this

    When you connect it to a PC, it will be recognized as a new ethernet interface, you can assign an IP and ping it from the network. 

    I isolated the pins CC1, CC2 and VBUS in the ethernet adaptor PCB (simply I cut) and connect their USB-C connector side to TPS65987DJEVM directly including GND. I also powered the ethernet adaptor from an external source which was available during my tests.

    What I did at the end is that when I connect ethernet adaptor to my laptop, Data lines including super speed pins will come directly from ethernet adaptor itself but CC1, CC2 and VBUS will come from the TPS65987DJEVM eval board.

    TPS65987DJEVM is preconfigured as UFP and sink as mentioned above. 

    With the first attempt, this setup worked fine. PD on the TPS65987DJEVM board reported as an UFP and sink device and data lines of the ethernet adaptor did their job and my Linux machine recognized the ethernet interface directly and I started pinging the interface from another machine continuously (every second). 

    Now, while pinging continues, in TPS65987_8_HOST Application Customization 6.2.1 tool, I enabled Debug mode and send a command called "Switch to Source".  TPS65987DJEVM indeed switched to Source mode. But ping started reporting timeout like 10-15 seconds and then continued automatically as normal.

    Then I execute "Switch to Sink" command, again pinging started reporting timeouts and recover automatically after 10-15 seconds.

    I observed same behavior's on iPad and on my Dell notebook.

    Therefore I concluded that, switching power roles affects data roles to be renegotiated or reset somehow.

     

    I'm not sure there would be a easier way to test it. (we can order it if there is any)

    Regards.

  • Hi Mehmet,

    Can you provide a block diagram of your current setup with the ethernet adapter?

    Thanks and Regards,

    Raymond Lin

  • Hi Raymond,

    See below image, I took the 4 pins from evaluation board (green rectangles):

    And connected them to USB-C Ethernet adaptor's pins directly after removing the existing PD (PTN5150AHXMP, U607) on the ethernet adaptor.

    TI EVM Pin Ethernet Adaptor Pin
    CC1 USB_CC1
    CC2 USB_CC2
    VBUS USBC_VBUS
    GND GND

    Then I connected USB-Ethernet adaptor's USB-C port to my laptop.

    Like I mentioned, the ethernet adaptor powered externally (VBUS not used for powering the device), but any glitch on the VBUS while changing from source to sink or opposite could cause same problem. I will verify the VBUS output using an oscilloscope while swapping the power roles.

    Regards

    Mehmet.

  • Hi Raymond,

    I confirm that there is a glitch when I swap power roles.

    See VBUS when I switch power role from Sink to a Source (it is about 10ms):

    And VBUS changing from a Source to a Sink (~500ms)

    Are they expected?

    Thank you.

  • Hi Mehmet,

    If possible can you obtain a PD log of this transaction when you send the 4cc commands? We can then determine why we're observing this behavior. 

    Based on the information provided, there are some possibilities as to why you see this occurring.

    1. There can be additional circuitry/communication happening within the USB-C and Ethernet adapter where the previous PD (PTN5150AHXMP) is communicating with superspeed mux or other ICs. With your current setup, the TPS65987DDJ is not able to communicate with any other parts (if there are any) within the adapter since the only connected lines are VBUS, GND, and CC1/2. While this alone can do PD protocols, if the TPS65987DDJ detects USB data or other Alternate Mode detection, it can't communicate with necessary parts through either GPIOs or I2C since none of those lines are connected to the adapter. 

    2. After taking a look at PTN5150AHXMP, it seems like this is only a USB-C controller, not a PD controller. While similar, there are differences between the two, mainly PD protocols and specification as set by USB-IF (for PD controllers). Integrating a PD controller into the adapter where originally only a USB-C controller can potentially cause some issues but this can't be said for certain (will require to look into the adapter's design). 

    3. When swapping to source, are you expecting the laptop to take in power from the adapter or what is the desired behavior? Can you specify what kind of behavior you expect when the PD (TPS65987DDJ) is in Source and Sink mode? 

    Please do note TI US will be on holiday 24th and 25th and we will be back in office on the 28th! 

    Thanks and Regards,

    Raymond Lin

  • Hi Raymond,

    We don't have a special device to trace the communication between CC pins. Do you have any recommendation for that? We could order one if you have a simple solution.

    1. Well yes there is a mux to control the path of super speed pins which needs to be controlled by PD and it is not the case in my setup since I didn't connect the direction control pin, super speed works only in one direction, other direction works only at USB2.0 speed. This affects only data speed as expected. And it is not a problem for my tests. There is no any other external peripheral needs to be controlled by PD, just multiplexer. 

    2. Yes PTN5150AHXMP was the simple one, I replaced it with TPS65987DDJEVM by connecting VBUS, CC1, CC2 and GND pins only. TPS65987DDJ is far way advanced that PTN one, TPS65987DDJ can easily mimic it like I do on my tests.

    3. When I swap the power role of the TPS65987DDJEVM to a Source, I expect that the laptop starts being charged while keeping the data role as UFP. And I confirm that it behaves also in that way as expected. But the issue here, when I swap the power role, my laptop (or iPad both behave same) looses the existing USB data connection like 10 seconds and acts as if I removed the USB cable and inserted back. I don't want to loose existing data connection while power role swap. And one potential explanation to that why it loses data communication could be that VBUS is going down and up during swapping the power roles. And according to the oscilloscope output that I sent above, I can also say that it is not fast at all even though the feature called as Fast Role Swap in the USB PD 3.0 standard. Here is the whitepaper from TI.

    Thank you and I wish you a happy Thanksgiving!

  • TI offices are on holiday for Thanksgiving. We will respond to this next week when team will be back in office.