
NUC126
Aug. 08, 2018
Page
707
of 943
Rev 1.03
NUC12
6 S
E
RI
E
S
T
E
CH
NI
CA
L R
E
F
E
RE
NCE
MA
NUA
L
Setup Token Buffer: 8 bytes
EP0 SRAM Buffer: 64 bytes
EP1 SRAM Buffer: 64 bytes
EP2 SRAM Buffer
EP3 SRAM Buffer
USB SRAM Start Address
EP0 SA = U 0x0108
MXPLD0 = 0x40
USBD_SRAM = U 0x0100
EP1 SA = U 0x0148
MXPLD1 = 0x40
EP2 SA = U 0x0188
EP3 SA = U 0x0200
512
Bytes
BUFSEG0 = 0x008
BUFSEG1 = 0x048
BUFSEG2 = 0x088
BUFSEG3 = 0x100
Figure 6.18-3 Endpoint SRAM Structure
6.18.5.8 Handling Transactions with USB Device Peripheral
The interrupt or polling USBD_INTSTS can be used to monitor the USB transactions. When
transactions occur, USBD_INTSTS will be set by hardware and send an interrupt request to CPU (if
related interrupt enabled), or user can polling USBD_INTSTS to get these events without interrupt.
The following is the control flow with interrupt enabled.
When USB host has requested data from a device controller, user needs to prepare related data in the
specified endpoint buffer in advance. After buffering the required data, user needs to write the actual
data length in the specified USBD_MXPLDx register. Once this register is written, the internal signal
“In_Rdy” will be asserted and the buffering data will be transmitted immediately after receiving
associated IN token from Host. Note that after transferring the specifi
ed data, the signal “In_Rdy” will
de-assert automatically by hardware.
USB_IRQ
In_Rdy
Data In
SETUP PID Data Setup
ACK PID
IN PID
NAK PID
IN PID
Data 0/1
ACK PID
USB
Bus Packets
Setup Received
Setup Handled by Firmware
Set by Hardware
Clear by Firmware
Set by writing
USBD_MXPLDx
register
Clear by Hardware
Figure 6.18-4 Setup Transaction Followed by Data IN Transaction
Alternatively, when USB host wants to transmit data to the OUT endpoint in the device controller,
hardware will buffer these data to the specified endpoint buffer. After this transaction is completed,
hardware will record the data length in specified USBD_MXPLDx register and de-assert the internal
signal “Out_Rdy”. This will avoid hardware accepting next transaction until user moves out the current
data in the related endpoint buffer. Once users have processed this transaction, the specified