Microcontrollers with USB interface are common nowadays. Manufacturers provide source codes for USB device classes like CDC, HID, Mass storage and DFU. . Even in this case, programming USB communications may not be a trivial task. If it is only required to replace RS232 serial interface to USB, is worth considering using of FTDI TF-X series USB to serial bridge.
Advantages:
● Entire USB protocol handled on the chip. No USB specific firmware programming required.
● Detection of connection to DCP (Dedicated Charging Port) USB port.
● Lower requirements for microcontroller resources. Communication through UART, I2C or SPI is less resource demanding than implementation of USB CDC device class
● Drivers for Windows, Mac OS-X, Linux and Android for free.
● Microcontroller pins are connected to USB connector through USB/serial bridge. ESD or overvoltage spikes on USB bus can damage bridge instead of microcontroller. Replacement of small bridge chip is simpler than replacement of microcontroller.
Disadvantages:
● USB/serial bridge chip requires PCB space and increases cost.
For more detail: Microcontrollers with USB interface are common, but…