2.4USBPHYInitialization
2.5DynamicFIFOSizing
3USBControllerHostandPeripheralModesOperation
USBControllerHostandPeripheralModesOperation
www.ti.com
ThefollowingbitsinUSBPHY_CTLmustbeclearedtoenabletheUSBcontroller:OSCPDWNand
PHYPDWN.ThefollowingbitsinUSBPHY_CTLmustbesettoenablethelevelcomparators:VBDTCTEN
andVBUSENS.Afterthisconfigurationisinplace,waituntilthePLLclockisgoodpriortocontinuing,i.e.,
waituntilUSBPHY_CTL.PHYCLKGDbitisset.
TheUSBcontrollersupportsatotalof4KRAMtodynamicallyallocateFIFOtoallendpoints.The
allocationofFIFOspacetothedifferentendpointsrequiresthespecificationforeachTxandRxendpoint
of:
•ThestartaddressoftheFIFOwithintheRAMblock
•Themaximumsizeofpackettobesupported
•Whetherdouble-bufferingisrequired.
Thesedetailsarespecifiedthroughfourregisters,whichareaddedtotheindexedareaofthememory
map.Thatis,theregistersforthedesiredendpointareaccessedafterprogrammingtheINDEXregister
withthedesiredendpointvalue.Section4.79,Section4.80,Section4.81,andSection4.82providedetails
oftheseregisters.
Note:TheoptionofsettingFIFOsizesdynamicallyonlyappliestoEndpoints1…4.Endpoint0
FIFOhasafixedsize(64bytes)andafixedlocation(startaddress0).
ItistheresponsibilityofthefirmwaretoensurethatalltheTxandRxendpointsthatare
activeinthecurrentUSBconfigurationhaveablockofRAMassignedexclusivelytothat
endpointthatisatleastaslargeasthemaximumpacketsizesetforthatendpoint.
TheUSBcontrollercanbeusedinarangeofdifferentenvironments.Itcanbeusedaseithera
high-speedorafull-speedUSBperipheraldeviceattachedtoaconventionalUSBhost(suchasaPC).It
canbeusedaseitherhostorperipheraldeviceinpoint-to-pointdatatransferswithanotherperipheral
device-or,iftheotherdevicealsocontainsaDual-RoleController,thetwodevicescanswitchrolesas
required.(Thisseconddevicemaybeeitherahigh-speed,full-speedorlow-speedUSBfunction.)Orthe
controllercanbeusedasthehosttoarangeofsuchperipheraldevicesinamulti-pointsetup.
Whetherthecontrollerexpectstobehaveasahostorasaperipheraldevicedependsonthewaythe
devicesarecabledtogether.EachUSBcablehasanAendandaBend.IftheAendofthecableis
pluggedintothecontroller,itwilltaketheroleoftheHostdeviceandgointohostmode.IftheBendof
thecableispluggedin,thecontrollerwillgoinsteadintoperipheralmode.
TheUSBcontrollerinterruptstheARMoncompletionofthedatatransferonanyoftheendpointsoron
detectingreset,resume,suspend,connect,disconnect,orSOFonthebus.
WhentheARMisinterruptedwithaUSBinterrupt,itneedstoreadtheinterruptstatusregisterto
determinetheendpointsthathavecausedtheinterruptandjumptotheappropriateroutine.Ifmultiple
endpointshavecausedtheinterrupt,endpoint0shouldbeservicedfirst,followedbytheotherendpoints.
Thesuspendinterruptshouldbeservicedlast.
TheflowchartinFigure2describestheinterruptserviceroutinefortheUSBmodule.
ThefollowingsectionsdescribetheprogrammingofUSBcontrollerinPeripheralmodeandHostmode.
DMAOperationsandInterruptHandlermechanismsarecommontobothperipheralandhostmode
operationsandarediscussedaftertheprogramminginPeripheralandHostMode.
24UniversalSerialBus(USB)ControllerSPRUGH3–November2008
SubmitDocumentationFeedback