Hi NXP support,
We realize the LPC546xx doesn't support USB OTG, can we use an GPIO to detect the USBID and switch between host and device mode?
The SDK only support either host or device, need support regarding on how to switch between host and device.
Hello, Terence.
I´m currently working on your question. As soon I get a useful answer I´ll let you know.
Regards, Diego
Sorry for my late reply.
You can use a GPIO pin with a pull-up resistor in order to detect If the cable that you
are using sets the LPC54xx as a host or a B device.
In terms of software, you can take as a starting point our examples for HOST or DEVICE. You will need to do your own implementation to switch the role from HOST to DEVICE.
Additionally, take into account that your design must change to provide VBUS as a host and receive VBUS power as a device.
Best regards, Diego
Ok will try that out, thanks
Please let me know if I can help you further.
Best regards, Diego.
another question, how to read the value from the USB1_ID pin? seems that is not a standard GPIO
I will take a look at this. Please provide time to investigate.
Best regards!
Any idea how to read the value from the USB1_ID pin?
Hi Terence!
I apologize for the delay! I missed the track of your inquirie due my workload.
You can check the value of the USB1_ID pin!
Altougth this pin does not have a GPIO alternative like USB0_ID.
To do this please, refer to the register PortMode of the LPC546 UM
This is the small code that I made to test the USB1_ID pin :
#include "fsl_power.h"
int main( void )
{
/* Init FSL debug console. */
BOARD_InitDebugConsole(); POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /*< Turn on USB Phy */
CLOCK_EnableClock(kCLOCK_Usbh1 );
CLOCK_EnableUsbfs0HostClock(kCLOCK_UsbSrcUsbPll, 48000000U); while (1)
{
USBHSH->PORTMODE |= 1<<8;// enabling pull up resistor on USB1_ID pin
if(USBHSH->PORTMODE & (0x01))
{
//The pin is pulled up
PRINTF(" A device connected /n");
}
else
{ // the pin is pulled down
PRINTF("B device connected /n");
}
}
}
Additional comments:
This was tested using the LPCxpress54628 EVK. I can guarantee that this example code will work as intended on all situations!
To pull down the USB1_ID line I used to connect a OTG adapter to the high speed USB connector, since has the ID pin grounded.
I hope this helps!
-------------------------------------------------------------------------------
Note:
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Apparently no, thanks for your information