LPC1857 usb host+device msc

Showing results for 
Search instead for 
Did you mean: 

LPC1857 usb host+device msc

Contributor II

Hi everyone!
I've got such a task.
I need to make a double mode working USB0 port.

p.1) If I connect it to the PC windows see a internal flash disk (about 64kB size) - usb device mode.
A working example of it I've already made by modifying the usbd msc example with fat fs lib.

p.2) If I connect it by OTG cable to the Flash Drive(any) I need to automatically copy some file into internal flash disk
(mentioned in p. 1) - usb host mode.
A working example of it I've already made by using a usblib host msc example, also with fat fs.

But now I wanna join this two examples.
And there 're such a questions.
- How can I identify pc/flash mode automatically to switch between usb dev/host modes?
Does it real to make it such way? Maybe somebody has the same and there is some realization of this?
- How can I make two filesystems by Fat FS using two different disk access types(internal flash or external USB flash)?

All my best.

Labels (2)
0 Kudos
2 Replies

Contributor III

Hi Ivan,

What you are trying to do is very much possible. I have done it with Mass storage host & custom device(connected to PC) on the same port.

By default you need to initialize USB in device mode, so when host(PC) is connected communication is done easily. But when another device(USB pen drive) is connected ID pin goes low & then initialize USB host so as to enumerate & communicate with connected device.

For Switching modes you need:-

1) switch for pull downs on D+ & D- lines(15k pull down)

2) switch for pull up on D+(1.5k) for full speed.

3) switch for VBUS(so that when device is connected +5v supply is provided).

4) ID pin connected to GPIO using 100k pull up.(to detect when device is connected).



0 Kudos

NXP Employee
NXP Employee

Hi Ivan,

Have you reviewed the Dual Hi-Speed USB Host/Device Solution examples?

Dual USB solutions for the LPC1837 LPC1830 LPC1800 and LPC4337 LPC4330 LPC4300 NXP microcontrollers.... 

Here is the link to the demo source code and documentation:


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos