Electronic – Is it possible to use a Microchip PIC32 as a USB host and device at the same time

microchipmicrocontrollerusbusb deviceusb-host

I'm designing a system and maybe (if I don't find better alternatives) I will need to use a PIC32 as a handler in between two USB devices and a host. My plan is to use the PIC32 to hide the devices, so the PIC has certain protocols downstream and another protocol upstream. I've been reading a lot about the USB specification and about the support of USB on Microchip PIC32 micro controller series. But still, I have one fundamental doubt: is it possible to connect two devices downstream of the PIC and to connect the PIC upstream to a host at the same time? In other words, is it possible for the PIC32 to act as a host and device at the same time?

I would really appreciate any hint or suggestion about this

Thanks in advance.

Best Answer

The USB can either be in device mode or in OTG mode. You cannot have OTG on the same USB bus as a host like a computer.

Multiple OTG devices can switch between host & device mode using "HNP" (Host negotiation protocol) but you can't do that with a pure host.

You would need two separate USB busses - one between the PC and the PIC, and one between the PIC and the devices. I don't think there is any PIC device that has 2 distinct USB interfaces.

I would suggest using a second device along side the PIC32 to act as a USB device to connect to the PC, and use the PIC32's USB in OTG mode to talk to the devices. This other device could be as simple as a FTDI chip to talk to the PIC32 through RS232, or something more powerful like another PIC (maybe a PIC18 with USB support) so you can talk through other protocols like I²C or SPI.