I have PIC32 MCU. It supports USB OTG functionality. I searched a lot on google about the applications regarding OTG but didn't find many results. I was wondering if any one can explain what can be done with OTG in MCU. Can we store some data via OTG in flash drives. ?
USB OTG is basically like a mini-host and can connect to flash drives, keyboards, printers, hubs - basically anything you want. The key differences between a USB OTG host and a regular USB host (such as your PC) are:
- A USB OTG product can also act as a regular USB device. There is an special connector (Micro/Mini A-B) that supports both A and B types of plugs and includes an ID pin which tells your product whether it should act as a host or device (based on the type of plug end connected). Note that the new USB 3.1 spec and type C connector work a bit differently but the concept is the same.
- A USB OTG host is not required to support all types of USB devices. You supply a list of devices that your OTG host supports with your product. For example you could list a particular make of flash drive and if anything else is connected your product can just display a message saying it is not supported. Normal USB hosts need to support the full range of product types to be 'USB compliant' (it's actually a bit more complex than this, but that is the general idea).
- The OTG spec provides a special protocol to allow two OTG devices connected to each other to reverse roles. This could be useful if, for example, your product is connected to a mobile phone (another OTG device) but with the cable the wrong way around. The Host Negotiation Protocol (HNP) lets the devices change roles without the user having to physically swap the cable around (note this is all changed with the new type C connector).
So yes, you can most certainly use the OTG functionality to store data into a flash drive, and this is quite a common usage. However you will have to write a lot of software to achieve this functionality. The limited resources in the PIC32 may also prevent you from supporting too many devices at the same time or running more complex peripherals.
Also, if your product doesn't need to act as a device it is not an OTG product but simply an embedded host. In that case you don't need to worry about items 1 and 3 that I've listed above.