Toggling PTE6 on Teensy 3.6 to turn 5V USB host power off and on

Status
Not open for further replies.

Zenbob

Well-known member
Hello, I'm interested in creating a pseudo "standy-by" mode on our T3.6 based widget, which would include turning off the USB Host power. On our widget, PTE6 is connected to a (self powered) USB hub chip's VBUS_Sense pin, so it won't power up until Teensy runs USBhost_T36. This works great. According the the post linked below, this sets PTE6 high which normally enables a current limit switch to provide host power. In our design, it enables the USB hub chip, and we have our own current limit switches (and a polyfuse on 5V for good measure).

https://www.reddit.com/r/Teensy/comments/bo6k10/teensy_36_usb_host_power_issues/

Here's the code referenced in the post above:
Code:
PORTE_PCR6 = PORT_PCR_MUX(1);
GPIOE_PDDR |= (1<<6);
GPIOE_PSOR = (1<<6); // turn on USB host power

Would the Teensy USB host code tolerate switching our hub off and on? I think it will behave like hot plugging. Assuming this is safe to do, could someone in the know provide a brief explanation of how this code works, and how to safely set PTE6 low?

Thanks! We'll give it a shot and see if the hub chip can power off and back on again this way.

Here's a shot of our work in progress:
T36 and hub.jpg
 
Shoot, sorry I think I put this in the wrong area. Maybe admin can move it to Technical support.
 
Redirected - never did that before ... When rediredted the thread can be renamed as well - that might come in handy.

Not sure it matters ... maybe to some - but clicking what was the prior general link - comes here.
 
Would the Teensy USB host code tolerate switching our hub off and on?

Yes, it should work.

Ideally, you should make sure the power remains off for at least 10 ms. It may take time for those large yellow capacitors to discharge, so don't forget to account for those in your code that turns off the power.


how to safely set PTE6 low?

Change this:

Code:
  GPIOE_PSOR = (1<<6); // turn on USB host power

to this:

Code:
  GPIOE_PCOR = (1<<6); // turn off USB host power
 
Also, while not technically an issue about Teensy or the host library, you should consider how that hub chip gets reset.

There are 2 common approaches to generating the reset signal. The high quality way involves a voltage reference and comparator and usually a one-shot timer. Some hub chips have this built in. It can be done externally with chips like MAX809. This way always works very well.

The cheap way uses a resistor and capacitor, and sometimes a protection diode. Some hub chips have the resistor built in, so you supply only the capacitor which delays the hub from coming out of reset until the power is stable. This sort of cheap reset can behave badly if the power turns off for less than the RC delay, or during brown outs or other problems where the power doesn't turn fully on or off much faster than the RC time constant.

If your hub design isn't using a high quality reset, you also need to keep the reset signal in mind when you decide how long to turn on & off the hub's power.
 
Also, while not technically an issue about Teensy or the host library, you should consider how that hub chip gets reset.

There are 2 common approaches to generating the reset signal. The high quality way involves a voltage reference and comparator and usually a one-shot timer. Some hub chips have this built in. It can be done externally with chips like MAX809. This way always works very well.

The cheap way uses a resistor and capacitor, and sometimes a protection diode. Some hub chips have the resistor built in, so you supply only the capacitor which delays the hub from coming out of reset until the power is stable. This sort of cheap reset can behave badly if the power turns off for less than the RC delay, or during brown outs or other problems where the power doesn't turn fully on or off much faster than the RC time constant.

If your hub design isn't using a high quality reset, you also need to keep the reset signal in mind when you decide how long to turn on & off the hub's power.

Thank you Paul! The hub controller is a MaxLinear XR22414CV48TR-F. Its a stand-alone hub designed for embedded applications, with pre-programmed Vendor and Product IDs. Very convenient! The only downside so far is availability. Its got an integrated automatic power-up reset and an external hardware pin reset. While I've got reset hooked up to a GPIO, we've not done a thing with it, so we'll look at how we should manage that.

I'll report back once we've tried to power it off and on.
 
Yes, it should work.

Ideally, you should make sure the power remains off for at least 10 ms. It may take time for those large yellow capacitors to discharge, so don't forget to account for those in your code that turns off the power.




Change this:

Code:
  GPIOE_PSOR = (1<<6); // turn on USB host power

to this:

Code:
  GPIOE_PCOR = (1<<6); // turn off USB host power

Yes, smoke test worked and we could use a keyboard plugged into the hub after toggling it back on. Thank you for the help!
 
Status
Not open for further replies.
Back
Top