Use Cases
1388
SPRUH91D – March 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Universal Serial Bus 2.0 (USB) Controller
31.3 Use Cases
The USB supports the following use cases.
31.3.1 User Case 1: Example of How to Initialize the USB Controller
Example 31-1. Initializing the USB2.0 Controller
void usb_init()
{
Uint16 I;
// **************************************************************************
// Configure DRVVBUS Pin to be used for USB
// **************************************************************************
// MAKE SURE WRITE ACCESS KEY IS INITIALIZED PRIOR TO ACCESSING ANY OF THE
// BOOTCFG REGISTERS.
BootCfg->KICK0R = KICK0KEY;
// Write Access Key 0
BootCfg->KICK1R = KICK1KEY;
// Write Access Key 1
/* CONFIGURE THE DRVVBUS PIN HERE.*/
/* See the System Configuration (SYSCFG) Module chapter for more information on how to set up
the pinmux. */
// Reset the USB controller:
usbRegs->CTRLR |= 0x00000001;
//Wait until controller is finished with Reset. When done, it will clear the RESET bit field.
while ((usbRegs->CTRLR & 0x1) == 1);
// RESET: Hold PHY in Reset
BootCfg->CFGCHIP2 |= 0x00008000;
// Hold PHY in Reset
// Drive Reset for few clock cycles
for (I=0; i<50; I++);
// RESET: Release PHY from Reset
BootCfg->CFGCHIP2 &= 0xFFFF7FFF;
// Release PHY from Reset
/* Configure PHY with the Desired Operation */
// OTGMODE
BootCfg->CFGCHIP2 &= 0xFFFF9FFF;
// 00=> Do Not Override PHY Values
// PHYPWDN
BootCfg->CFGCHIP2 &= 0xFFFFFBFF;
// 1/0 => PowerdDown/ NormalOperation
// OTGPWRDN
BootCfg->CFGCHIP2 &= 0xFFFFFDFF;
// 1/0 => PowerDown/ NormalOperation
// DATAPOL
BootCfg->CFGCHIP2 |= 0x00000100;
// 1/0 => Normal/ Reversed
// SESNDEN
BootCfg->CFGCHIP2 |= 0x00000020;
// 1/0 => NormalOperation/ SessionEnd
// VBDTCTEN
BootCfg->CFGCHIP2 |= 0x00000010;
// 1/0 => VBUS Comparator Enable/ Disable
/* Configure PHY PLL use and Select Source */
// REF_FREQ[3:0]
BootCfg->CFGCHIP2 |= 0x00000002;
// 0010b => 24MHz Input Source
// USB2PHYCLKMUX: Select External Source
BootCfg->CFGCHIP2 &= 0xFFFFF7FF;
// 1/0 => Internal/External(Pin)