Should I enable pull-up of GPIO to detect a floating USB ID-Pin?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Should I enable pull-up of GPIO to detect a floating USB ID-Pin?

4,372 Views
kai_liu
Senior Contributor I

I am designing H/W F/W for USB OTG on KL25Z. Now I know in OTG design, the ID-pin should be floating as device (type B), and ground for host (type A). KLQRUG.pdf

However, I am not sure the result of reading digital input on specific floating GPIO, high, low or uncertain state?

Should I enable pull-up of GPIO (PE/PS in PORTx_PCRn)?

Tags (3)
3 Replies

2,821 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Kai,

In a dual-role USB application, the ID pin is who handles if the MCU will be a Host or a Device. This application is based on connection-disconnection of the USB cable, grounding the ID pin or leaving it floating (with pull up). In this case, the MCU includes both stacks (host and device) and the state of the ID pin during connection is who decides which stack will be called for USB module initialization.

The On-The-Go application is more complex, because it is a complete negotiation protocol for swap the role without unplugging anything. In this case, it is required the external hardware shown on the slides that I have attached (MAX3353). It is the hardware included on Tower Serial module (TWR-SER) allowing Dual-Role and OTG USB communications.

Hope this will be useful for you.

Best regards!

/Carlos

2,821 Views
kai_liu
Senior Contributor I

Hi, Calos,

Very clear explaination. And my design actually is dual-role USB, since I have no idea how to switch USB port of Android device in programmatical way. Additionally, my firmware running on KL25Z only implement USB host and USB device in seperate release.

In device firmware (MSD), the external power switch of VBUS is switched off, regardless of state of ID-pin.

In host firmware (ADB/ADK), the external VBUS switch is switched according to state of ID-pin. Only a floating ID-pin can switch on VBUS power switch to Android.

Now I know, pull up is necessary to measure a floating state.

Your sincerely

Allan K Liu

2,821 Views
kai_liu
Senior Contributor I

I tried it on FRDM-KL25Z this afternoon.

J10 of FRDM-KL25Z has B[0..3]. I measured them, they are all floating and get about 0.7V DC.

After reset, I enable PORTB_PCRx [ MUX = 1 ] (0x00000105), then I read it from GPIOB_PDIR, I got 0x00000000.

Then I enable pull up PORTB_PCR0 [MUX=1,PE=1,PS=1] (0x00000107), suddenly, I got GPIOB_PDIR as 0x0000000F.  If I ground one pin, the result is correct.

Then I disbale pull up PORTB_PCR0, it doesn't matter now.

I got little confuse here for the result:

  1. If the pull up (PE+PS) has not been enabled, the GPIO read is 0.
  2. If I enable pull up of one GPIO, then all GPIOs in one port is enable.
  3. If I disable pull up then, it doesn't matter at all.

It seems to detect ID-pin, the firmware should enable its GPIOx_PCR PE/PS bits. However I have no idea if other GPIO will be effected because all pull up is enabled.