12.7. USB

12.7.1. Overview

NOTE

Prerequisite knowledge required

This section requires knowledge of the USB protocol. If you aren't yet familiar with the USB protocol, we recommend the archive of the very useful USB Made Simple website. For formal definitions of the terminology used in this section, see the USB 2.0 Specification .

RP2350 contains a USB 2.0 controller that can operate as either:

There is an integrated USB 1.1 PHY which interfaces the USB controller with the DP and DM pins of the chip. You may use this as 3.3 V GPIO when the USB controller is not in use.

12.7.2.1. Errata fixes

RP2350 fixes all RP2040 USB errata. This includes fixes for the following RP2040B0 and B1 errata which are also fixed by RP2040B2:

For more information about RP2040B2, see the RP2040 datasheet.

RP2350 fixes the following RP2040B2 errata, which require software workarounds on RP2040B2:

12.7.2.2. New features

12.7.2.2.1. General

12.7.2.2.2. Host

12.7.2.2.3. Device

12.7.2.2.4. Device error handling

12.7.3. Architecture

12.7.3.1. Clock speed

This controller requires clk_usb to be running at 48MHz.

i NOTE

clk_sys must also be running at > 48MHz. See RP2350-E12 .

12.7.3.2. Overview

Figure 124. A simplified overview of the USB controller architecture.

A block diagram showing the simplified overview of the USB controller architecture. On the left, a 'Host Controller' and a 'Device Controller' are connected to a central 'Device / Host Mode?' block. This block has three bidirectional connections to a 'DPSRAM' block: 'Control / Data input from DPSRAM', 'Control / Data output from DPSRAM', and 'Read / Write Addresses'. The 'DPSRAM' block is part of an 'AHBL slave' block that also contains 'Control Registers'. To the right of the 'DPSRAM' block, there are two bidirectional connections: 'Write to DPSRAM' and 'Read from DPSRAM'. The 'Read from DPSRAM' connection leads to a 'Serial TX Engine', which then connects to a 'USB PHY'. The 'Serial RX Engine' also connects to the 'USB PHY'. The 'USB PHY' has a bidirectional connection to a 'Line State Detection' block.
A block diagram showing the simplified overview of the USB controller architecture. On the left, a 'Host Controller' and a 'Device Controller' are connected to a central 'Device / Host Mode?' block. This block has three bidirectional connections to a 'DPSRAM' block: 'Control / Data input from DPSRAM', 'Control / Data output from DPSRAM', and 'Read / Write Addresses'. The 'DPSRAM' block is part of an 'AHBL slave' block that also contains 'Control Registers'. To the right of the 'DPSRAM' block, there are two bidirectional connections: 'Write to DPSRAM' and 'Read from DPSRAM'. The 'Read from DPSRAM' connection leads to a 'Serial TX Engine', which then connects to a 'USB PHY'. The 'Serial RX Engine' also connects to the 'USB PHY'. The 'USB PHY' has a bidirectional connection to a 'Line State Detection' block.

The USB controller is an area-efficient design that muxes a device controller or host controller onto a common set of components. Each component is detailed below.

12.7.3.3. USB PHY

The USB PHY provides the electrical interface between the USB DP and DM pins and the digital logic of the controller. The DP and DM pins are a differential pair, meaning the values are always the inverse of each other, except to encode a specific line state (e.g. SE0 ). The USB PHY drives the DP and DM pins to transmit data and performs a differential receive of any incoming data. The USB PHY provides both single-ended and differential receive data to the line state detection module.

The USB PHY has built in pull-up and pull-down resistors. When the controller acts as a Full Speed device, the DP pin is pulled up to indicate to the host that a Full Speed device has been connected. In host mode, a weak pull-down is applied to DP and DM so that the lines are pulled to a logical zero until the device pulls up DP for Full Speed or DM for Low Speed.

12.7.3.4. Line state detection

The USB 2.0 Specification defines several line states (Bus Reset, Connected, Suspend, Resume, Data 1, Data 0, etc.) that need to be detected. The line state detection module has several state machines to detect these states and signal events to the other hardware components. There is no shared clock signal in USB, so the RX data must be sampled by an internal clock. The maximum data rate of USB Full Speed is 12 Mb/s. The RX data is sampled at 48MHz, giving 4 clock cycles to capture and filter the bus state. The line state detection module distributes the filtered RX data to the Serial RX Engine.

12.7.3.5. Serial RX engine

The serial receive (RX) engine decodes receive data captured by the line state detection module. It produces the following information:

The serial receive engine also detects errors in RX data by performing a CRC check on the incoming data. Any errors are signalled to the other hardware blocks and can raise an interrupt.

NOTE

If you disconnect the USB cable during packet transfer in either host or device mode, the hardware will raise errors. Software must account for this scenario if you enable error interrupts.

12.7.3.6. Serial TX engine

The serial transmit (TX) engine is a mirror of the serial receive engine. It is connected to the currently active controller (either device or host). It creates TOKEN and DATA packets, calculates the CRC, and transmits them on the bus.

12.7.3.7. DPSRAM

The USB controller uses 4 kB (4096 bytes) of Dual Port SRAM (DPSRAM) to store control registers and data buffers. The DPSRAM is accessible as a 32-bit wide memory at address 0 of the USB controller ( 0x50100000 ).

The DPSRAM has the following characteristics, which differ from most registers on RP2350:

Data Buffers are typically 64 bytes long, as this is the maximum normal packet size for most Full Speed packets. Isochronous endpoints support a maximum buffer size of 1023 bytes. For other packet types, the maximum size is 64 bytes per buffer.

12.7.3.7.1. Concurrent access

The DPSRAM in the USB controller is asynchronous. The dual port part of the name indicates that both the processor and the USB controller have ports to read and write, and these two ports are in different clock domains. As a result, the processor and USB controller can access the same memory address at the same time. One could write and one could read simultaneously. This could result in inconsistent data reads. You can avoid this scenario by following the rules outlined in this section.

The AVAILABLE bit in the buffer control register indicates who has ownership of a buffer. Set this bit to 1 from the processor to give the controller ownership of the buffer. When it has finished using the buffer, the controller sets the bit back to 0. Set the AVAILABLE bit separately from the rest of the data in the buffer control register so that the rest of the data in the buffer control register is accurate when the AVAILABLE bit is set.

This is necessary because the processor clock clk_sys can run several times faster than the clk_usb clock. Therefore clk_sys can update the data during a USB controller read on a slower clock. The correct process is:

  1. 1. Write buffer information (length, etc.) to the buffer control register.
  2. 2. nop for some clk_sys cycles to ensure that at least one clk_usb cycle passes. Consider a scenario where clk_sys runs at 125MHz and clk_usb runs at 48MHz. Because \( \lceil \frac{125}{48} \rceil = 3 \) , you should issue 3 nop instructions between the writes to guarantee that at least one clk_usb cycle has passed.
  3. 3. Set the AVAILABLE bit.

If clk_sys and clk_usb run at the same frequency, then it is not necessary to set the AVAILABLE bit separately.

NOTE

When the USB controller writes the status back to the DPSRAM, it does a 16-bit write to the lower 2 bytes for buffer 0 and the upper 2 bytes for buffer 1. When using double-buffered mode, always treat the buffer control register as two 16-bit registers when updating it in software.

12.7.3.7.2. Layout

Addresses 0x0→ 0xff are used for control registers containing configuration data. The remaining space, addresses 0x100→ 0xffff(3840 bytes) can be used for data buffers. The controller has control registers that start at address 0x10000.

The memory layout depends on the USB controller mode:

Table 1192. DPSRAM layout

OffsetDevice FunctionHost Function
0x0Setup packet (8 bytes)
0x8EP1 in controlInterrupt endpoint control 1
0xcEP1 out controlSpare
0x10EP2 in controlInterrupt endpoint control 2
0x14EP2 out controlSpare
0x18EP3 in controlInterrupt endpoint control 3
0x1cEP3 out controlSpare
0x20EP4 in controlInterrupt endpoint control 4
0x24EP4 out controlSpare
0x28EP5 in controlInterrupt endpoint control 5
0x2cEP5 out controlSpare
0x30EP6 in controlInterrupt endpoint control 6
0x34EP6 out controlSpare
0x38EP7 in controlInterrupt endpoint control 7
0x3cEP7 out controlSpare
0x40EP8 in controlInterrupt endpoint control 8
0x44EP8 out controlSpare
0x48EP9 in controlInterrupt endpoint control 9
0x4cEP9 out controlSpare
0x50EP10 in controlInterrupt endpoint control 10
0x54EP10 out controlSpare
0x58EP11 in controlInterrupt endpoint control 11
OffsetDevice FunctionHost Function
0x5cEP11 out controlSpare
0x60EP12 in controlInterrupt endpoint control 12
0x64EP12 out controlSpare
0x68EP13 in controlInterrupt endpoint control 13
0x6cEP13 out controlSpare
0x70EP14 in controlInterrupt endpoint control 14
0x74EP14 out controlSpare
0x78EP15 in controlInterrupt endpoint control 15
0x7cEP15 out controlSpare
0x80EP0 in buffer controlEPx buffer control
0x84EP0 out buffer controlSpare
0x88EP1 in buffer controlInterrupt endpoint buffer control 1
0x8cEP1 out buffer controlSpare
0x90EP2 in buffer controlInterrupt endpoint buffer control 2
0x94EP2 out buffer controlSpare
0x98EP3 in buffer controlInterrupt endpoint buffer control 3
0x9cEP3 out buffer controlSpare
0xa0EP4 in buffer controlInterrupt endpoint buffer control 4
0xa4EP4 out buffer controlSpare
0xa8EP5 in buffer controlInterrupt endpoint buffer control 5
0xacEP5 out buffer controlSpare
0xb0EP6 in buffer controlInterrupt endpoint buffer control 6
0xb4EP6 out buffer controlSpare
0xb8EP7 in buffer controlInterrupt endpoint buffer control 7
0xbcEP7 out buffer controlSpare
0xc0EP8 in buffer controlInterrupt endpoint buffer control 8
0xc4EP8 out buffer controlSpare
0xc8EP9 in buffer controlInterrupt endpoint buffer control 9
0xccEP9 out buffer controlSpare
0xd0EP10 in buffer controlInterrupt endpoint buffer control 10
0xd4EP10 out buffer controlSpare
0xd8EP11 in buffer controlInterrupt endpoint buffer control 11
0xdcEP11 out buffer controlSpare
0xe0EP12 in buffer controlInterrupt endpoint buffer control 12
0xe4EP12 out buffer controlSpare
0xe8EP13 in buffer controlInterrupt endpoint buffer control 13
OffsetDevice FunctionHost FunctionColumn 3
0xecEP13out buffer controlSpare
0xf0EP14in buffer controlInterrupt endpoint buffer control 14
0xf4EP14out buffer controlSpare
0xf8EP15in buffer controlInterrupt endpoint buffer control 15
0xfcEP15out buffer controlSpare
0x100EP0buffer 0 (shared between in and out)EPx control
0x140Optional EP0buffer 1Spare
0x180 0x180Data buffers
• A device must support Endpoint 0 so that it can reply toSETUPpackets and be enumerated. As a result, there is no
endpoint control register forEP0 . Its buffers begin at0x100 . All other endpoints can have either single or dual buffers and
are mapped at the base address programmed. AsEP0 has no endpoint control register, the interrupt enable controls for
EP0 come from SIE_CTRL. Table 1193. Endpoint
Bit(s) control register layoutDevice FunctionHost Function
31Endpoint enable Endpoint enable
30Single buffered (64 bytes) = 0, Double buffered (64 bytes× 2) = 1
29Enable interrupt for every transferred buffer
28Enable interrupt for every 2 transferred buffers (valid for double-buffered only)
27:26 27:26Endpoint Type: Control = 0, Isochronous = 1, Bulk = 2, Interrupt = 3
25:18N/AThe interval the host controller should poll this endpoint. Only applicable for interrupt
17Interrupt on STALL
16Interrupt on NAKvalue of 9 would poll the endpoint every 10ms.
15:6 15:6Address base offset in DPSRAM of data buffer(s)

12.7.3.7.3. Endpoint control register

The endpoint control register is used to configure an endpoint. It defines:

A device must support Endpoint 0 so that it can reply to SETUP packets and be enumerated. As a result, there is no endpoint control register for EP0 . Its buffers begin at 0x100 . All other endpoints can have either single or dual buffers and are mapped at the base address programmed. As EP0 has no endpoint control register, the interrupt enable controls for EP0 come from SIE_CTRL .

Table 1193. Endpoint control register layout

NOTE

The data buffer base address must be 64-byte aligned, since bits 0 through 5 are ignored.

12.7.3.7.4. Buffer control register

The buffer control register contains information about the state of the data buffers for that endpoint. It is shared between the processor and the controller. If the endpoint is configured to be single-buffered, only the first half (bits 0 through 15) of the buffer are used.

If double buffering, the buffer select starts at buffer 0. From then on, the buffer select flips between buffer 0 and 1

unless the reset buffer select bit is set (which resets the buffer select to buffer 0). The value of the buffer select is internal to the controller and not accessible by the processor.

For host interrupt and isochronous packets on EPx , the buffer full bit will be set on completion even if the transfer was unsuccessful. To determine the error, read the error bits in the SIE_STATUS register.

Table 1194. Buffer control register layout

Bit(s)Function
31Buffer 1 full. Should be set to 1 by the processor for an IN transaction and 0 for an OUT transaction. The controller sets this to 1 for an OUT transaction because it has filled the buffer. The controller sets it to 0 for an IN transaction because it has emptied the buffer. Only valid when double buffering.
30Last buffer of transfer for buffer 1. Only valid when double buffering.
29Data PID for buffer 1 - DATA0 = 0, DATA1 = 1. Only valid when double buffering.
27:28Double buffer offset for isochronous mode (0 = 128, 1 = 256, 2 = 512, 3 = 1024).
26Buffer 1 available. Whether the buffer can be used by the controller for a transfer. The processor sets this to 1 when the buffer is configured. The controller sets this to 0 after it has sent the data to the host for an IN transaction, or filled the buffer with data from the host for an OUT transaction. Only valid when double buffering.
25:16Buffer 1 transfer length. Only valid when double buffering.
15Buffer 0 full. Should be set to 1 by the processor for an IN transaction and 0 for an OUT transaction. The controller sets this to 1 for an OUT transaction because it has filled the buffer. The controller sets it to 0 for an IN transaction because it has emptied the buffer.
14Last buffer of transfer for buffer 0.
13Data PID for buffer 0 - DATA0 = 0, DATA1 = 1.
12Reset buffer select to buffer 0 - cleared at end of transfer. For device only .
11Send STALL for device, STALL received for host.
10Buffer 0 available. Indicates whether the buffer can be used by the controller for a transfer. The processor sets this to 1 when the buffer is configured. The controller sets this to 0 after it has sent the data to the host for an IN transaction or filled the buffer with data from the host for an OUT transaction.
9:0Buffer 0 transfer length.

Warning icon WARNING

If you run clk_sys and clk_usb at different speeds, set the available and stall bits after the other data in the buffer control register. Otherwise, the controller may initiate a transaction with data from a previous packet. The controller could see the available bit set, but get the data PID or length from the previous packet.

12.7.3.8. Device controller

This section details how the device controller operates when it receives various packet types from the host.

12.7.3.8.1. SETUP

The device controller MUST always accept a SETUP packet from the host. DPSRAM dedicates its first 8 bytes to the setup packet.

The USB 2.0 Specification states that receiving a setup packet also clears any stall bits on EP0 . For this reason, the stall

bits for EP0 are gated with two bits in the EP_STALL_ARM register. These bits are cleared when a setup packet is received. This means that to send a stall on EP0 , you must set both the stall bit in the buffer control register and the appropriate bit in EP_STALL_ARM .

Barring any errors, the setup packet will be put into the setup packet buffer at DPSRAM offset 0x0 . The device controller will then reply with an ACK .

Finally, SIE_STATUS.SETUP_REC is set to indicate that a setup packet has been received. This will trigger an interrupt if the programmer has enabled the SETUP_REC interrupt (see INTE ).

12.7.3.8.2. IN

From the device's point of view, an IN transfer means transferring data into the host. When an IN token is received from the host, the request is handled as follows:

TOKEN phase:

  1. 1. If STALL is set in the buffer control register (and if EP0 , the appropriate EP_STALL_ARM bit is set), send a STALL response and go to idle.
  2. 2. If AVAILABLE and FULL bits are set in buffer control, go to the DATA phase.
  3. 3. If this is an isochronous endpoint, go to idle.
    • ◦ Otherwise, send NAK and go to the DATA phase.

DATA phase:

  1. 1. Send data.
  2. 2. If this is an isochronous endpoint, go to idle.
    • ◦ Otherwise, go to the ACK phase.

ACK phase:

  1. 1. Wait for ACK packet from host.
  2. 2. If there is a timeout, raise a timeout error.
  3. 3. If ACK is received, the packet is done, so go to STATUS phase.

STATUS phase:

  1. 1. If this was the last buffer in the transfer (i.e. if the LAST_BUFFER bit in the buffer control register was set), set SIE_STATUS.TRANS_COMPLETE .
  2. 2. If the endpoint is double buffered, flip the buffer select to the other buffer.
  3. 3. Set a bit in BUFF_STATUS to indicate the buffer is done. When handling this event, the programmer should read BUFF_CPU_SHOULD_HANDLE to see if it is buffer 0 or buffer 1 that is finished. If the endpoint is double-buffered, both buffers could be done. The cleared BUFF_STATUS bit will be set again, and BUFF_CPU_SHOULD_HANDLE will change in this instance.
  4. 4. Update status in the appropriate half of the buffer control register: length , pid , and last_buff are set. Everything else is written to zero.

If the host receives a NAK , the host will retry again later.

12.7.3.8.3. OUT

When an OUT token is received from the host, the request is handled as follows:

TOKEN phase:

  1. 1. If this is not an Isochronous endpoint and the data PID does not match the buffer control register, raise

SIE_STATUS.DATA_SEQ_ERROR (isochronous data is always sent with a DATA0 pid).

  1. 2. If the AVAILABLE bit is set and the FULL bit is clear, go to the DATA phase, unless the STALL bit is set in which case the device controller will reply with a STALL .

DATA phase:

  1. 1. Store received data in buffer. If this is an isochronous endpoint, go to the STATUS phase. Otherwise, go to the ACK phase.

ACK phase:

  1. 1. Send ACK . Go to the STATUS phase.

STATUS phase:

See IN STATUS phase: [usb-device-in-status-phase] . There is one difference: the FULL bit is set in the buffer control register to indicate that data has been received. In the IN phase, the FULL bit is cleared to indicate that data has been sent.

12.7.3.8.4. Suspend and resume

The USB device controller supports suspend, resume, and device-initiated remote resume (triggered with SIE_CTRL.RESUME ). There is an interrupt / status bit in SIE_STATUS . It is not necessary to enable the suspend and resume interrupts, since suspend and resume are irrelevant to most devices.

The device goes into suspend when it does not see any start of frame packets (transmitted every 1ms) from the host.

i NOTE

If you enable the suspend interrupt, it is likely you will see a suspend interrupt when the device first connects, but the bus is idle. The bus can be idle for a few milliseconds before the host begins sending start of frame packets. If you do not have a VBUS detect circuit connected, you will also see a suspend interrupt when the device disconnects. Without VBUS detection, it is impossible to tell the difference between being disconnected and suspended.

12.7.3.9. Host controller

The host controller design is similar to the device controller. The host starts all transactions, so the host always deals with transactions it has started. For this reason, there is only one set of endpoint control and endpoint buffer control registers. The host controller also contains additional hardware to poll interrupt endpoints in the background when there are no software controlled transactions taking place.

The host needs to send keep-alive packets to the device every 1ms to keep the device from suspending. Full Speed mode uses a SOF (start of frame) packet. Low Speed mode uses an EOP (end of packet) instead. Set SIE_CTRL.KEEP_ALIVE_EN and SIE_CTRL.SOF_EN to enable these packets.

Several bits in SIE_CTRL are used to begin a host transaction:

packets, software is responsible for preventing collisions. To prevent collisions in software, use SOF_SYNC and limit the number of packets sent in one frame. If a transaction is set up with multiple packets, SOF_SYNC only applies to the first packet.

The START_TRANS bit is synchronised separately from other control bits in the SIE_CTRL register because the processor clock clk_sys can be asynchronous to the clk_usb clock. Always set the START_TRANS bit separately from the rest of the data in the SIE_CTRL register. Always ensure that at least two clk_usb cycles pass between writing to START_TRANS and other bits in SIE_CTRL. This ensures that the register contents are stable when the controller is prompted to start a transfer.

Consider a scenario where clk_sys runs at 125MHz and clk_usb runs at 48MHz. Because \( \lceil \frac{125}{48} \rceil \times 2 = 6 \) , you should issue 6 nop instructions between the writes to guarantee that at least two clk_usb cycles have passed.

12.7.3.9.1. SETUP

The SETUP packet sent from the host always comes from the dedicated 8 bytes of space at offset 0x0 of the DPSRAM. Like the device controller, there are no control registers associated with the setup packet. The parameters are hard-coded and loaded into the hardware when you write to START_TRANS with the SEND_SETUP bit set. Once the setup packet has been sent, the host state machine waits for an ACK from the device. If there is a timeout, an RX_TIMEOUT error will be raised. If the SEND_TRANS bit is set, the host state machine will move to the OUT phase. Typically, the SEND_SETUP packet is used with the RECEIVE_TRANS bit, so the controller moves to the IN phase after sending a setup packet.

12.7.3.9.2. IN

An IN transfer is triggered with the RECEIVE_TRANS bit set when the START_TRANS bit is set. If the SEND_SETUP bit was set, this may be preceded by a SETUP packet.

CONTROL phase:

  1. 1. Read the EPx control register located at 0x80 to get the following endpoint information:
    • ◦ Is it double buffered?
    • ◦ What interrupts are enabled?
    • ◦ Base address of the data buffer (data buffers if in double-buffered mode)
    • ◦ What is the endpoint type?
  2. 2. Read the EPx buffer control register at 0x100 to get endpoint buffer information, such as transfer length and data PID.
  3. 3. Set the AVAILABLE bit (the host state machine checks for it).
  4. 4. Clear the FULL bit.

TOKEN phase:

  1. 1. Send the IN token packet to the device. The target device address and endpoint come from the ADDR_ENDP register.

DATA phase:

  1. 1. Receive the first data packet from the device.
  2. 2. Raise RX timeout error if the device doesn't reply.
  3. 3. If this is not an Isochronous endpoint and the data PID does not match the buffer control register, raise SIE_STATUS.DATA_SEQ_ERROR(isochronous data is always sent with a DATA0 pid).

ACK phase:

  1. 1. Send ACK to device.

STATUS phase:

  1. 1. Set the BUFF_STATUS bit and update the buffer control register.
  2. 2. Set FULL , DATA_PID , WR_LEN , and LAST_BUFF if applicable.
  3. 3. If this is the last buffer in the transfer, set TRANS_COMPLETE .

CONTROL phase (continued):

The host state machine performs IN transactions until LAST_BUFF is seen in the buffer_control register.

If the host is in double buffered mode, the host controller toggles between the BUF0 and BUF1 sections of the buffer control register.

Otherwise, the controller reads the buffer control register for buffer 0, then waits for FULL to be clear and AVAILABLE to be set before starting the next IN transaction, waiting in the CONTROL phase.

If the host receives a zero length packet, the device has no more data. The host state machine stops listening for more data regardless of if the LAST_BUFF flag was set or not. To detect this from host software, check BUFF_DONE for a data length of 0 in the buffer control register.

12.7.3.9.3. OUT

An OUT transfer is triggered with the SEND_TRANS bit set when the START_TRANS bit is set. This may be preceded by a SETUP packet if the SEND_SETUP bit was set.

CONTROL phase:

  1. 1. Read the EPx control register to get endpoint information (same as Section 12.7.3.9.2 ).
  2. 2. Read the EPx buffer control register to get the transfer length and data PID. AVAILABLE and FULL must be set before the transfer can start.

TOKEN phase

  1. 1. Send an OUT packet to the device. The target device address and endpoint come from the ADDR_ENDP register.

DATA phase:

  1. 1. Send the first data packet to the device. If the endpoint type is isochronous, there is no ACK phase, so the host controller goes straight to status phase. If ACK is received, go to status phase. Otherwise:
    • ◦ If the host receives no reply, raise SIE_STATUS.RX_TIMEOUT .
    • ◦ If the host receives NAK , raise SIE_STATUS.NAK_REC and send the data packet again.
    • ◦ If the host receives STALL , raise SIE_STATUS.STALL_REC and go to idle.

STATUS phase:

  1. 1. Set the BUFF_STATUS bit and update the buffer control register. FULL will be set to 0. TRANS_COMPLETE will be set if this is the last buffer in the transfer.

CONTROL phase (continued):

  1. 1. If this isn't the last buffer in the transfer, wait for FULL and AVAILABLE to be set in the EPx buffer control register again.

12.7.3.9.4. Interrupt endpoints

The host controller can poll interrupt endpoints on a maximum of 15 endpoints. To enable interrupt endpoints, the programmer must:

If the device is Low Speed but attached to a Full Speed hub, the preamble bit should be set. The endpoint direction bit should also be set.

Typically, interrupt endpoints use an IN transfer. The host might poll a USB hub to see if the state of any of its ports have changed. If there is no change, the hub replies with a NAK to the controller, and nothing happens. Similarly, a mouse replies with a NAK unless the mouse has been moved since the last time the interrupt endpoint was polled.

Interrupt endpoints are polled by the controller once a SOF packet has been sent by the host controller.

The controller loops from 1 to 15 and attempts to poll any interrupt endpoint with the EP_ACTIVE bit set to 1 in INT_EP_CTRL . The controller will then read the endpoint control register and the buffer control register to see if there is an available buffer (i.e. FULL + AVAILABLE if an OUT transfer and NOT FULL + AVAILABLE for an IN transfer). If not, the controller will move onto the next interrupt endpoint slot.

If there is an available buffer, the transfer is dealt with the same as a normal IN or OUT transfer and the BUFF_DONE flag in BUFF_STATUS will be set when the interrupt endpoint has a valid buffer.

12.7.3.10. VBUS control

The USB controller can be connected to GPIO pins (see Chapter 9 ) for the following VBUS controls:

It is not necessary to connect up any of these pins to GPIO. The host can permanently supply VBUS and detect a device being connected when either the DP or DM pin is pulled high. VBUS detect can be forced in USB_PWR .

12.7.4. Programmer's model

12.7.4.1. TinyUSB

The RP2350 TinyUSB port is the reference implementation for this USB controller. This port can be found in the following files of the pico-sdk GitHub repository:

dcd_rp2040.c

hcd_rp2040.c

rp2040_usb.h

12.7.4.2. Standalone device example

A standalone USB device example, dev_lowlevel , makes it easier to understand how to interact with the USB controller without needing to understand the TinyUSB abstractions. In addition to endpoint 0, the standalone device has two bulk endpoints: EP1 OUT and EP2 IN . The device is designed to send whatever data it receives on EP1 to EP2 . The example comes with a small Python script that writes "Hello World" into EP1 and checks that it is correctly received on EP2 .

The code included in this section explains setting up the USB device controller to receive. It also shows how software responds to a setup packet received from the host.

Figure 125. USB analyser trace of the dev_lowlevel USB device example. The control transfers are the device enumeration. The first bulk OUT (out from the host) transfer, highlighted in blue, is the host sending "Hello World" to the device. The second bulk transfer IN (in to the host), is the device returning "Hello World" to the host.

Ch0Packet
522
H ↓Reset
15.006 ms
Transfer 0F
S
Control
GET
ADDR
0
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
DEVICE type
wIndex
0x0000
Descriptors
DEVICE Descriptor
Ch0Packet
646
H ↓Reset
15.006 ms
Transfer 1F
S
Control
SET
ADDR
0
ENDP
0
bRequest
SET_ADDRESS
wValue
New address 7
wIndex
0x0000
wLength
0
Transfer 2F
S
Control
GET
ADDR
7
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
DEVICE type
wIndex
0x0000
Descriptors
DEVICE Descriptor
Transfer 3F
S
Control
GET
ADDR
7
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
CONFIGURATION type, Index 0
wIndex
0x0000
Descriptors
CONFIGURATION Descriptor
Transfer 4F
S
Control
GET
ADDR
7
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
CONFIGURATION type, Index 0
wIndex
0x0000
Descriptors
4 Descriptors
Transfer 5F
S
Control
GET
ADDR
7
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
STRING type, LANGID codes requested
wIndex
Language ID 0x0000
Descriptors
Lang Supported
Transfer 6F
S
Control
GET
ADDR
7
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
STRING type, Index 2
wIndex
Language ID 0x0409
Descriptors
Pico Test Device
Transfer 7F
S
Control
GET
ADDR
7
ENDP
0
bRequest
GET_DESCRIPTOR
wValue
STRING type, Index 1
wIndex
Language ID 0x0409
Descriptors
Raspberry Pi
Transfer 8F
S
Control
SET
ADDR
7
ENDP
0
bRequest
SET_CONFIGURATION
wValue
New Configuration 1
wIndex
0x0000
wLength
0
Transfer 9F
S
Bulk
OUT
ADDR
7
ENDP
1
Bytes Transferred
12
Transfer 10F
S
Bulk
IN
ADDR
7
ENDP
2
Bytes Transferred
12

12.7.4.2.1. Device controller initialisation

The following code initialises the USB device:

Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 183 - 217

183 void usb_device_init() {
184     // Reset usb controller
185     reset_unreset_block_num_wait_blocking(RESET_USBCTRL);
186
187     // Clear any previous state in dpram just in case
188     memset(usb_dpram, 0, sizeof(*usb_dpram)); ①
189
190     // Enable USB interrupt at processor
191     irq_set_enabled(USBCTRL_IRQ, true);
192
193     // Mux the controller to the onboard usb phy
194     usb_hw->muxing = USB_USB_MUXING_TO_PHY_BITS | USB_USB_MUXING_SOFTCON_BITS;
195
196     // Force VBUS detect so the device thinks it is plugged into a host
197     usb_hw->pwr = USB_USB_PWR_VBUS_DETECT_BITS | USB_USB_PWR_VBUS_DETECT_OVERRIDE_EN_BITS;
198
199     // Enable the USB controller in device mode.
200     usb_hw->main_ctrl = USB_MAIN_CTRL_CONTROLLER_EN_BITS;
201
202     // Enable an interrupt per EP0 transaction
203     usb_hw->sie_ctrl = USB_SIE_CTRL_EP0_INT_1BUF_BITS; ②
204
205     // Enable interrupts for when a buffer is done, when the bus is reset,
206     // and when a setup packet is received
207     usb_hw->inte = USB_INTS_BUFF_STATUS_BITS |
208                   USB_INTS_BUS_RESET_BITS |
209                   USB_INTS_SETUP_REQ_BITS;
210
211     // Set up endpoints (endpoint control registers)
212     // described by device configuration
213     usb_setup_endpoints();
214
215     // Present full speed device by enabling pull up on DP
216     usb_hw_set->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS;
217 }

12.7.4.2.2. Configuring the endpoint control registers for EP1 and EP2

The function usb_configure_endpoints loops through each endpoint defined in the device configuration (including EP0 in and EP0 out, which don't have an endpoint control register defined) and calls the usb_configure_endpoint function. This sets up the endpoint control register for that endpoint:

Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 149 - 164

149 void usb_setup_endpoint(const struct usb_endpoint_configuration *ep) {
150     printf("Set up endpoint 0x%x with buffer address 0x%p\n", ep->descriptor-
        >bEndpointAddress, ep->data_buffer);
151
152     // EP0 doesn't have one so return if that is the case
153     if (!ep->endpoint_control) {
154         return;
155     }
156
157     // Get the data buffer as an offset of the USB controller's DPRAM
158     uint32_t dpram_offset = usb_buffer_offset(ep->data_buffer);
159     uint32_t reg = EP_CTRL_ENABLE_BITS
160                 | EP_CTRL_INTERRUPT_PER_BUFFER
161                 | (ep->descriptor->bmAttributes << EP_CTRL_BUFFER_TYPE_LSB)
162                 | dpram_offset;
163     *ep->endpoint_control = reg;
164 }

12.7.4.2.3. Receiving a setup packet

An interrupt is raised when a setup packet is received, so the interrupt handler must handle this event:

Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 494 - 504

494 void isr_usbctrl(void) {
495     // USB interrupt handler
496     uint32_t status = usb_hw->ints;
497     uint32_t handled = 0;
498
499     // Setup packet received
500     if (status & USB_INTS_SETUP_REQ_BITS) {
501         handled |= USB_INTS_SETUP_REQ_BITS;
502         usb_hw_clear->sie_status = USB_SIE_STATUS_SETUP_REC_BITS;
503         usb_handle_setup_packet();
504     }

The controller writes the SETUP packet to the first 8 bytes of the DPSRAM, so the setup packet handler casts that area of memory to struct usb_setup_packet *:

Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 383 - 427

383 void usb_handle_setup_packet(void) {
384     volatile struct usb_setup_packet *pkt = (volatile struct usb_setup_packet *) &usb_dpram
        ->setup_packet;
385     uint8_t req_direction = pkt->bmRequestType;
386     uint8_t req = pkt->bRequest;
387
388     // Reset PID to 1 for EP0 IN
389     usb_get_endpoint_configuration(EP0_IN_ADDR)->next_pid = 1u;
390
391     if (req_direction == USB_DIR_OUT) {
392         if (req == USB_REQUEST_SET_ADDRESS) {
393             usb_set_device_address(pkt);
394         } else if (req == USB_REQUEST_SET_CONFIGURATION) {
395             usb_set_device_configuration(pkt);
396         } else {
397             usb_acknowledge_out_request();
398             printf("Other OUT request (0x%x)\r\n", pkt->bRequest);
399         }
400     } else if (req_direction == USB_DIR_IN) {
401         if (req == USB_REQUEST_GET_DESCRIPTOR) {
402             uint16_t descriptor_type = pkt->wValue >> 8;
403
404             switch (descriptor_type) {
405                 case USB_DT_DEVICE:
406                     usb_handle_device_descriptor(pkt);
407                     printf("GET DEVICE DESCRIPTOR\r\n");
408                     break;
409
410                 case USB_DT_CONFIG:
411                     usb_handle_config_descriptor(pkt);
412                     printf("GET CONFIG DESCRIPTOR\r\n");
413                     break;
414
415                 case USB_DT_STRING:
416                     usb_handle_string_descriptor(pkt);
417                     printf("GET STRING DESCRIPTOR\r\n");
418                     break;
419
420                 default:
421                     printf("Unhandled GET_DESCRIPTOR type 0x%x\r\n", descriptor_type);
422             }
423         } else {
424             printf("Other IN request (0x%x)\r\n", pkt->bRequest);
425         }
426     }
427 }

12.7.4.2.4. Replying to a setup packet on EP0 IN

The host first requests the device descriptor. The following code handles that setup request:

Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 266 - 273

266 void usb_handle_device_descriptor(volatile struct usb_setup_packet *pkt) {
267     const struct usb_device_descriptor *d = dev_config.device_descriptor;
268     // EP0 in
269     struct usb_endpoint_configuration *ep = usb_get_endpoint_configuration(EP0_IN_ADDR);
270     // Always respond with pid 1
271     ep->next_pid = 1;
272     usb_start_transfer(ep, (uint8_t *) d, MIN(sizeof(struct usb_device_descriptor), pkt->wLength));
273 }

The usb_start_transfer function copies data to be sent into the appropriate hardware buffer and configures the buffer

control register. Once the buffer control register has been written to, the device controller responds to the host with the data. Before this point, the device replies with a NAK :

Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 238 - 260

238 void usb_start_transfer(struct usb_endpoint_configuration *ep, uint8_t *buf, uint16_t len) {
239     // We are asserting that the length is <= 64 bytes for simplicity of the example.
240     // For multi packet transfers see the tinyusb port.
241     assert(len <= 64);
242
243     printf("Start transfer of len %d on ep addr 0x%x\n", len, ep->descriptor-
>bEndpointAddress);
244
245     // Prepare buffer control register value
246     uint32_t val = len | USB_BUF_CTRL_AVAIL;
247
248     if (ep_is_tx(ep)) {
249         // Need to copy the data from the user buffer to the usb memory
250         memcpy((void *) ep->data_buffer, (void *) buf, len);
251         // Mark as full
252         val |= USB_BUF_CTRL_FULL;
253     }
254
255     // Set pid and flip for next transfer
256     val |= ep->next_pid ? USB_BUF_CTRL_DATA1_PID : USB_BUF_CTRL_DATA0_PID;
257     ep->next_pid ^= 1u;
258
259     *ep->buffer_control = val;
260 }

12.7.5. List of registers

The USB registers start at a base address of 0x50110000 (defined as USBCTRL_REGS_BASE in SDK).

Table 1195. List of USB registers

Offset 0x42fc8 0x42fcc 0x42fd0 0x42fd4 0x42fd8Name DEVID DEVTYPE PIDR4 PIDR5 PIDR6Info Device Configuration register Device Type Identifier register CoreSight Periperal ID4 CoreSight Periperal ID5 CoreSight Periperal ID6
Pico Examples:https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 238 - 260
241assert(len <= 64);
243printf("Start transfer of len %d on ep addr 0x%x\n", len, ep->descriptor-
246uint32_t// Prepare buffer control register value val = len | USB_BUF_CTRL_AVAIL;
248if (ep_is_tx(ep)) {
250memcpy((void*) ep->data_buffer, (void *) buf, len);
251// Mark as full
252// Mark as full val|= USB_BUF_CTRL_FULL;
253}
255} // Set pid and flip for next transfer
256// Set pid and flip for next transfer val|= ep->next_pid ? USB_BUF_CTRL_DATA1_PID : USB_BUF_CTRL_DATA0_PID;
257ep->next_pid ^= 1u;
259 260 }*ep->buffer_control= val;
12.7.5. List of registers The USB registers start at a base address of0x50110000 (defined as USBCTRL_REGS_BASE in SDK).
Table 1195. List of OffsetNameInfo
USB registers 0x000ADDR_ENDPDevice address and endpoint control
0x004ADDR_ENDP1Interrupt endpoint 1. Only valid for HOST mode.
0x008ADDR_ENDP2Interrupt endpoint 2. Only valid for HOST mode.
0x00cADDR_ENDP3Interrupt endpoint 3. Only valid for HOST mode.
0x010ADDR_ENDP4Interrupt endpoint 4. Only valid for HOST mode.
0x014ADDR_ENDP5Interrupt endpoint 5. Only valid for HOST mode.
0x018ADDR_ENDP6Interrupt endpoint 6. Only valid for HOST mode.
0x01cADDR_ENDP7Interrupt endpoint 7. Only valid for HOST mode.
0x020ADDR_ENDP8Interrupt endpoint 8. Only valid for HOST mode.
0x024ADDR_ENDP9Interrupt endpoint 9. Only valid for HOST mode.
0x028ADDR_ENDP10Interrupt endpoint 10. Only valid for HOST mode.
0x02cADDR_ENDP11Interrupt endpoint 11. Only valid for HOST mode.
0x030ADDR_ENDP12Interrupt endpoint 12. Only valid for HOST mode.
0x034ADDR_ENDP13Interrupt endpoint 13. Only valid for HOST mode.
OffsetNameInfo
0x038ADDR_ENDP14Interrupt endpoint 14. Only valid for HOST mode.
0x03cADDR_ENDP15Interrupt endpoint 15. Only valid for HOST mode.
0x040MAIN_CTRLMain control register
0x044SOF_WRSet the SOF (Start of Frame) frame number in the host controller. The SOF packet is sent every 1ms and the host will increment the frame number by 1 each time.
0x048SOF_RDRead the last SOF (Start of Frame) frame number seen. In device mode the last SOF received from the host. In host mode the last SOF sent by the host.
0x04cSIE_CTRLSIE control register
0x050SIE_STATUSSIE status register
0x054INT_EP_CTRLinterrupt endpoint control register
0x058BUFF_STATUSBuffer status register. A bit set here indicates that a buffer has completed on the endpoint (if the buffer interrupt is enabled). It is possible for 2 buffers to be completed, so clearing the buffer status bit may instantly re set it on the next clock cycle.
0x05cBUFF_CPU_SHOULD_HANDLEWhich of the double buffers should be handled. Only valid if using an interrupt per buffer (i.e. not per 2 buffers). Not valid for host interrupt endpoint polling because they are only single buffered.
0x060EP_ABORTDevice only: Can be set to ignore the buffer control register for this endpoint in case you would like to revoke a buffer. A NAK will be sent for every access to the endpoint until this bit is cleared. A corresponding bit in EP_ABORT_DONE is set when it is safe to modify the buffer control register.
0x064EP_ABORT_DONEDevice only: Used in conjunction with EP_ABORT . Set once an endpoint is idle so the programmer knows it is safe to modify the buffer control register.
0x068EP_STALL_ARMDevice: this bit must be set in conjunction with the STALL bit in the buffer control register to send a STALL on EP0. The device controller clears these bits when a SETUP packet is received because the USB spec requires that a STALL condition is cleared when a SETUP packet is received.
0x06cNAK_POLLUsed by the host controller. Sets the wait time in microseconds before trying again if the device replies with a NAK.
0x070EP_STATUS_STALL_NAKDevice: bits are set when the IRQ_ON_NAK or IRQ_ON_STALL bits are set. For EP0 this comes from SIE_CTRL . For all other endpoints it comes from the endpoint control register.
0x074USB_MUXINGWhere to connect the USB controller. Should be to_phy by default.
0x078USB_PWROverrides for the power signals in the event that the VBUS signals are not hooked up to GPIO. Set the value of the override and then the override enable to switch over to the override value.
OffsetNameInfo
0x07cUSBPHY_DIRECTThis register allows for direct control of the USB phy. Use in conjunction with usbphy_direct_override register to enable each override bit.
0x080USBPHY_DIRECT_OVERRIDEOverride enable for each control in usbphy_direct
0x084USBPHY_TRIMUsed to adjust trim values of USB phy pull down resistors.
0x088LINESTATE_TUNINGUsed for debug only.
0x08cINTRRaw Interrupts
0x090INTEInterrupt Enable
0x094INTFInterrupt Force
0x098INTSInterrupt status after masking & forcing
0x100SOF_TIMESTAMP_RAWDevice only. Raw value of free-running PHY clock counter @48MHz. Used to calculate time between SOF events.
0x104SOF_TIMESTAMP_LASTDevice only. Value of free-running PHY clock counter @48MHz when last SOF event occurred.
0x108SM_STATE
0x10cEP_TX_ERRORTX error count for each endpoint. Write to each field to reset the counter to 0.
0x110EP_RX_ERRORRX error count for each endpoint. Write to each field to reset the counter to 0.
0x114DEV_SM_WATCHDOGWatchdog that forces the device state machine to idle and raises an interrupt if the device stays in a state that isn't idle for the configured limit. The counter is reset on every state transition. Set limit while enable is low and then set the enable.
USB: ADDR_ENDP Register

Offset: 0x000

Description

Device address and endpoint control

Table 1196.
ADDR_ENDP Register

BitsDescriptionTypeReset
31:20Reserved.--
19:16ENDPOINT: Device endpoint to send data to. Only valid for HOST mode.RW0x0
15:7Reserved.--
6:0ADDRESS: In device mode, the address that the device should respond to. Set in response to a SET_ADDR setup packet from the host. In host mode set to the address of the device to communicate with.RW0x00
USB: ADDR_ENDP1, ADDR_ENDP2, ..., ADDR_ENDP14, ADDR_ENDP15 Registers

Offsets: 0x004, 0x008, ..., 0x038, 0x03c

Description

Interrupt endpoint N . Only valid for HOST mode.

Table 1197.
ADDR_ENDP1,
ADDR_ENDP2, ...,
ADDR_ENDP14,
ADDR_ENDP15
Registers

BitsDescriptionTypeReset
31:27Reserved.--
26INTEP_PREAMBLE : Interrupt EP requires preamble (is a low speed device on a full speed hub)RW0x0
25INTEP_DIR : Direction of the interrupt endpoint. In=0, Out=1RW0x0
24:20Reserved.--
19:16ENDPOINT : Endpoint number of the interrupt endpointRW0x0
15:7Reserved.--
6:0ADDRESS : Device addressRW0x00
USB: MAIN_CTRL Register

Offset: 0x040

Description

Main control register

Table 1198.
MAIN_CTRL Register

BitsDescriptionTypeReset
31SIM_TIMING : Reduced timings for simulationRW0x0
30:3Reserved.--
2PHY_ISO : Isolates USB phy after controller power-up
Remove isolation once software has configured the controller
Not isolated = 0, Isolated = 1
RW0x1
1HOST_NDEVICE : Device mode = 0, Host mode = 1RW0x0
0CONTROLLER_EN : Enable controllerRW0x0
USB: SOF_WR Register

Offset: 0x044

Description

Set the SOF (Start of Frame) frame number in the host controller. The SOF packet is sent every 1ms and the host will increment the frame number by 1 each time.

Table 1199. SOF_WR
Register

BitsDescriptionTypeReset
31:11Reserved.--
10:0COUNTWF0x000
USB: SOF_RD Register

Offset: 0x048

Description

Read the last SOF (Start of Frame) frame number seen. In device mode the last SOF received from the host. In host mode the last SOF sent by the host.

Table 1200. SOF_RD Register
BitsDescriptionTypeReset
31:11Reserved.--
10:0COUNTRO0x000
USB: SIE_CTRL Register

Offset: 0x04c

Description

SIE control register

Table 1201. SIE_CTRL Register
BitsDescriptionTypeReset
31EP0_INT_STALL : Device: Set bit in EP_STATUS_STALL_NAK when EP0 sends a STALLRW0x0
30EP0_DOUBLE_BUF : Device: EP0 single buffered = 0, double buffered = 1RW0x0
29EP0_INT_1BUF : Device: Set bit in BUFF_STATUS for every buffer completed on EP0RW0x0
28EP0_INT_2BUF : Device: Set bit in BUFF_STATUS for every 2 buffers completed on EP0RW0x0
27EP0_INT_NAK : Device: Set bit in EP_STATUS_STALL_NAK when EP0 sends a NAKRW0x0
26DIRECT_EN : Direct bus drive enableRW0x0
25DIRECT_DP : Direct control of DPRW0x0
24DIRECT_DM : Direct control of DMRW0x0
23:20Reserved.--
19EP0_STOP_ON_SHORT_PACKET : Device: Stop EP0 on a short packet.RW0x0
18TRANSCEIVER_PD : Power down bus transceiverRW0x0
17RPU_OPT : Device: Pull-up strength (0=1K2, 1=2k3)RW0x0
16PULLUP_EN : Device: Enable pull up resistorRW0x0
15PULLDOWN_EN : Host: Enable pull down resistorsRW0x1
14Reserved.--
13RESET_BUS : Host: Reset busSC0x0
12RESUME : Device: Remote wakeup. Device can initiate its own resume after suspend.SC0x0
11VBUS_EN : Host: Enable VBUSRW0x0
10KEEP_ALIVE_EN : Host: Enable keep alive packet (for low speed bus)RW0x0
9SOF_EN : Host: Enable SOF generation (for full speed bus)RW0x0
8SOF_SYNC : Host: Delay packet(s) until after SOFRW0x0
7Reserved.--
6PREAMBLE_EN : Host: Preable enable for LS device on FS hubRW0x0
5Reserved.--
4STOP_TRANS : Host: Stop transactionSC0x0
BitsDescriptionTypeReset
3RECEIVE_DATA : Host: Receive transaction (IN to host)RW0x0
2SEND_DATA : Host: Send transaction (OUT from host)RW0x0
1SEND_SETUP : Host: Send Setup packetRW0x0
0START_TRANS : Host: Start transactionSC0x0
USB: SIE_STATUS Register

Offset: 0x050

Description

SIE status register

Table 1202.
SIE_STATUS Register

BitsDescriptionTypeReset
31DATA_SEQ_ERROR : Data Sequence Error.

The device can raise a sequence error in the following conditions:

* A SETUP packet is received followed by a DATA1 packet (data phase should always be DATA0) * An OUT packet is received from the host but doesn't match the data pid in the buffer control register read from DPSRAM

The host can raise a data sequence error in the following conditions:

* An IN packet from the device has the wrong data PID
WC0x0
30ACK_REC : ACK received. Raised by both host and device.WC0x0
29STALL_REC : Host: STALL receivedWC0x0
28NAK_REC : Host: NAK receivedWC0x0
27RX_TIMEOUT : RX timeout is raised by both the host and device if an ACK is not received in the maximum time specified by the USB spec.WC0x0
26RX_OVERFLOW : RX overflow is raised by the Serial RX engine if the incoming data is too fast.WC0x0
25BIT_STUFF_ERROR : Bit Stuff Error. Raised by the Serial RX engine.WC0x0
24CRC_ERROR : CRC Error. Raised by the Serial RX engine.WC0x0
23ENDPOINT_ERROR : An endpoint has encountered an error. Read the ep_rx_error and ep_tx_error registers to find out which endpoint had an error.WC0x0
22:20Reserved.--
19BUS_RESET : Device: bus reset receivedWC0x0
Bits 14:10 9:5 4:0 BitsDescription SHIFT DescriptionMASK_MSB : The most-significant bit allowed to pass by the mask (inclusive) MASK_LSB : The least-significant bit allowed to pass by the mask (inclusive) : Right-rotate applied to accumulator before masking. By appropriatelyType RW RW RW TypeReset 0x00 0x00 0x00 Reset
15:13Reserved.--
12RX_SHORT_PACKET: Device or Host has received a short packet. This is whenWC0x0
11RESUMEregisters. Host: the current transfer will be stopped early. : Host: Device has initiated a remote resume. Device: host hasWC0x0
10VBUS_OVER_CURRinitiated a resume. : VBUS over current detectedRO0x0
9:8SPEED: Host: device speed. Disconnected = 00, LS = 01, FS = 10RO0x0
7:5Reserved.--
4SUSPENDED: Bus in suspended state. Valid for device and host. Host andRO0x0
3:2LINE_STATEdevice will go into suspend if neither Keep Alive / SOF frames are enabled. : USB bus line stateRO0x0
1Reserved.--
0VBUS_DETECTED: Device: VBUS DetectedRO0x0
Table 1203. BitsDescriptionTypeReset
INT_EP_CTRL Register 31:16Reserved.--
15:1INT_EP_ACTIVE: Host: Enable interrupt endpoint 1→ 15 RW0x0000
0Reserved.--
USB: INT_EP_CTRL Register

Offset: 0x054

Description

interrupt endpoint control register

Table 1203.
INT_EP_CTRL Register

USB: BUFF_STATUS Register
Offset: 0x058 Description

Buffer status register. A bit set here indicates that a buffer has completed on the endpoint (if the buffer interrupt is enabled). It is possible for 2 buffers to be completed, so clearing the buffer status bit may instantly re set it on the next clock cycle.

Table 1204.
BUFF_STATUS
Register

BitsDescriptionTypeReset
31EP15_OUTWC0x0
30EP15_INWC0x0
29EP14_OUTWC0x0
28EP14_INWC0x0
27EP13_OUTWC0x0
26EP13_INWC0x0
25EP12_OUTWC0x0
24EP12_INWC0x0
23EP11_OUTWC0x0
22EP11_INWC0x0
21EP10_OUTWC0x0
20EP10_INWC0x0
19EP9_OUTWC0x0
18EP9_INWC0x0
17EP8_OUTWC0x0
16EP8_INWC0x0
15EP7_OUTWC0x0
14EP7_INWC0x0
13EP6_OUTWC0x0
12EP6_INWC0x0
11EP5_OUTWC0x0
10EP5_INWC0x0
9EP4_OUTWC0x0
8EP4_INWC0x0
7EP3_OUTWC0x0
6EP3_INWC0x0
5EP2_OUTWC0x0
4EP2_INWC0x0
3EP1_OUTWC0x0
2EP1_INWC0x0
1EP0_OUTWC0x0
0EP0_INWC0x0
USB: BUFF_CPU_SHOULD_HANDLE Register

Offset: 0x05c

Description

Which of the double buffers should be handled. Only valid if using an interrupt per buffer (i.e. not per 2 buffers). Not valid for host interrupt endpoint polling because they are only single buffered.

Table 1205.
BUFF_CPU_SHOULD_H
ANDLE Register

BitsDescriptionTypeReset
31EP15_OUTRO0x0
30EP15_INRO0x0
29EP14_OUTRO0x0
28EP14_INRO0x0
27EP13_OUTRO0x0
26EP13_INRO0x0
25EP12_OUTRO0x0
24EP12_INRO0x0
23EP11_OUTRO0x0
22EP11_INRO0x0
21EP10_OUTRO0x0
20EP10_INRO0x0
19EP9_OUTRO0x0
18EP9_INRO0x0
17EP8_OUTRO0x0
16EP8_INRO0x0
15EP7_OUTRO0x0
14EP7_INRO0x0
13EP6_OUTRO0x0
12EP6_INRO0x0
11EP5_OUTRO0x0
10EP5_INRO0x0
9EP4_OUTRO0x0
8EP4_INRO0x0
7EP3_OUTRO0x0
6EP3_INRO0x0
5EP2_OUTRO0x0
4EP2_INRO0x0
3EP1_OUTRO0x0
2EP1_INRO0x0
1EP0_OUTRO0x0
BitsDescriptionTypeReset
0EP0_INRO0x0
USB: EP_ABORT Register

Offset: 0x060

Description

Device only: Can be set to ignore the buffer control register for this endpoint in case you would like to revoke a buffer. A NAK will be sent for every access to the endpoint until this bit is cleared. A corresponding bit in EP_ABORT_DONE is set when it is safe to modify the buffer control register.

Table 1206.
EP_ABORT Register

BitsDescriptionTypeReset
31EP15_OUTRW0x0
30EP15_INRW0x0
29EP14_OUTRW0x0
28EP14_INRW0x0
27EP13_OUTRW0x0
26EP13_INRW0x0
25EP12_OUTRW0x0
24EP12_INRW0x0
23EP11_OUTRW0x0
22EP11_INRW0x0
21EP10_OUTRW0x0
20EP10_INRW0x0
19EP9_OUTRW0x0
18EP9_INRW0x0
17EP8_OUTRW0x0
16EP8_INRW0x0
15EP7_OUTRW0x0
14EP7_INRW0x0
13EP6_OUTRW0x0
12EP6_INRW0x0
11EP5_OUTRW0x0
10EP5_INRW0x0
9EP4_OUTRW0x0
8EP4_INRW0x0
7EP3_OUTRW0x0
6EP3_INRW0x0
5EP2_OUTRW0x0
4EP2_INRW0x0
BitsDescriptionTypeReset
3EP1_OUTRW0x0
2EP1_INRW0x0
1EP0_OUTRW0x0
0EP0_INRW0x0
USB: EP_ABORT_DONE Register

Offset: 0x064

Description

Device only: Used in conjunction with EP_ABORT . Set once an endpoint is idle so the programmer knows it is safe to modify the buffer control register.

Table 1207.
EP_ABORT_DONE
Register

BitsDescriptionTypeReset
31EP15_OUTWC0x0
30EP15_INWC0x0
29EP14_OUTWC0x0
28EP14_INWC0x0
27EP13_OUTWC0x0
26EP13_INWC0x0
25EP12_OUTWC0x0
24EP12_INWC0x0
23EP11_OUTWC0x0
22EP11_INWC0x0
21EP10_OUTWC0x0
20EP10_INWC0x0
19EP9_OUTWC0x0
18EP9_INWC0x0
17EP8_OUTWC0x0
16EP8_INWC0x0
15EP7_OUTWC0x0
14EP7_INWC0x0
13EP6_OUTWC0x0
12EP6_INWC0x0
11EP5_OUTWC0x0
10EP5_INWC0x0
9EP4_OUTWC0x0
8EP4_INWC0x0
7EP3_OUTWC0x0
6EP3_INWC0x0
BitsDescriptionTypeReset
5EP2_OUTWC0x0
4EP2_INWC0x0
3EP1_OUTWC0x0
2EP1_INWC0x0
1EP0_OUTWC0x0
0EP0_INWC0x0
USB: EP_STALL_ARM Register

Offset: 0x068

Description

Device: this bit must be set in conjunction with the STALL bit in the buffer control register to send a STALL on EP0. The device controller clears these bits when a SETUP packet is received because the USB spec requires that a STALL condition is cleared when a SETUP packet is received.

Table 1208.
EP_STALL_ARM
Register

BitsDescriptionTypeReset
31:2Reserved.--
1EP0_OUTRW0x0
0EP0_INRW0x0
USB: NAK_POLL Register

Offset: 0x06c

Description

Used by the host controller. Sets the wait time in microseconds before trying again if the device replies with a NAK.

Table 1209.
NAK_POLL Register

BitsDescriptionTypeReset
31:28RETRY_COUNT_HI: Bits 9:6 of nak_retry countRO0x0
27EPX_STOPPED_ON_NAK: EPX polling has stopped because a nak was receivedWC0x0
26STOP_EPX_ON_NAK: Stop polling epX when a nak is receivedRW0x0
25:16DELAY_FS: NAK polling interval for a full speed deviceRW0x010
15:10RETRY_COUNT_LO: Bits 5:0 of nak_retry_countRO0x00
9:0DELAY_LS: NAK polling interval for a low speed deviceRW0x010
USB: EP_STATUS_STALL_NAK Register

Offset: 0x070

Description

Device: bits are set when the IRQ_ON_NAK or IRQ_ON_STALL bits are set. For EP0 this comes from SIE_CTRL . For all other endpoints it comes from the endpoint control register.

Table 1210.
EP_STATUS_STALL_NAK
Register

BitsDescriptionTypeReset
31EP15_OUTWC0x0
30EP15_INWC0x0
BitsDescriptionTypeReset
29EP14_OUTWC0x0
28EP14_INWC0x0
27EP13_OUTWC0x0
26EP13_INWC0x0
25EP12_OUTWC0x0
24EP12_INWC0x0
23EP11_OUTWC0x0
22EP11_INWC0x0
21EP10_OUTWC0x0
20EP10_INWC0x0
19EP9_OUTWC0x0
18EP9_INWC0x0
17EP8_OUTWC0x0
16EP8_INWC0x0
15EP7_OUTWC0x0
14EP7_INWC0x0
13EP6_OUTWC0x0
12EP6_INWC0x0
11EP5_OUTWC0x0
10EP5_INWC0x0
9EP4_OUTWC0x0
8EP4_INWC0x0
7EP3_OUTWC0x0
6EP3_INWC0x0
5EP2_OUTWC0x0
4EP2_INWC0x0
3EP1_OUTWC0x0
2EP1_INWC0x0
1EP0_OUTWC0x0
0EP0_INWC0x0
USB: USB_MUXING Register

Offset: 0x074

Description

Where to connect the USB controller. Should be to_phy by default.

Table 1211.
USB_MUXING Register

BitsDescriptionTypeReset
31SWAP_DPDM : Swap the USB PHY DP and DM pins and all related controls and flip receive differential data. Can be used to switch USB DP/DP on the PCB. This is done at a low level so overrides all other controls.RW0x0
30:5Reserved.--
4USBPHY_AS_GPIO : Use the usb DP and DM pins as GPIO pins instead of connecting them to the USB controller.RW0x0
3SOFTCONRW0x0
2TO_DIGITAL_PADRW0x0
1TO_EXTPHYRW0x0
0TO_PHYRW0x1
USB: USB_PWR Register

Offset: 0x078

Description

Overrides for the power signals in the event that the VBUS signals are not hooked up to GPIO. Set the value of the override and then the override enable to switch over to the override value.

Table 1212. USB_PWR Register

BitsDescriptionTypeReset
31:6Reserved.--
5OVERCURR_DETECT_ENRW0x0
4OVERCURR_DETECTRW0x0
3VBUS_DETECT_OVERRIDE_ENRW0x0
2VBUS_DETECTRW0x0
1VBUS_EN_OVERRIDE_ENRW0x0
0VBUS_ENRW0x0
USB: USBPHY_DIRECT Register

Offset: 0x07c

Description

This register allows for direct control of the USB phy. Use in conjunction with usbphy_direct_override register to enable each override bit.

Table 1213.
USBPHY_DIRECT Register

BitsDescriptionTypeReset
31:26Reserved.--
25RX_DM_OVERRIDE : Override rx_dm value into controllerRW0x0
24RX_DP_OVERRIDE : Override rx_dp value into controllerRW0x0
23RX_DD_OVERRIDE : Override rx_dd value into controllerRW0x0
22DM_OVV : DM over voltageRO0x0
21DP_OVV : DP over voltageRO0x0
20DM_OVCN : DM overcurrentRO0x0
BitsDescriptionTypeReset
19DP_OVCN : DP overcurrentRO0x0
18RX_DM : DPM pin stateRO0x0
17RX_DP : DPP pin stateRO0x0
16RX_DD : Differential RXRO0x0
15TX_DIFFMODE : TX_DIFFMODE=0: Single ended mode
TX_DIFFMODE=1: Differential drive mode (TX_DM, TX_DM_OE ignored)
RW0x0
14TX_FSSLEW : TX_FSSLEW=0: Low speed slew rate
TX_FSSLEW=1: Full speed slew rate
RW0x0
13TX_PD : TX power down override (if override enable is set). 1 = powered down.RW0x0
12RX_PD : RX power down override (if override enable is set). 1 = powered down.RW0x0
11TX_DM : Output data. TX_DIFFMODE=1, Ignored
TX_DIFFMODE=0, Drives DPM only. TX_DM_OE=1 to enable drive.
DPM=TX_DM
RW0x0
10TX_DP : Output data. If TX_DIFFMODE=1, Drives DPP/DPM diff pair.
TX_DP_OE=1 to enable drive. DPP=TX_DP, DPM=~TX_DP
If TX_DIFFMODE=0, Drives DPP only. TX_DP_OE=1 to enable drive.
DPP=TX_DP
RW0x0
9TX_DM_OE : Output enable. If TX_DIFFMODE=1, Ignored.
If TX_DIFFMODE=0, OE for DPM only. 0 - DPM in Hi-Z state; 1 - DPM driving
RW0x0
8TX_DP_OE : Output enable. If TX_DIFFMODE=1, OE for DPP/DPM diff pair. 0 - DPP/DPM in Hi-Z state; 1 - DPP/DPM driving
If TX_DIFFMODE=0, OE for DPP only. 0 - DPP in Hi-Z state; 1 - DPP driving
RW0x0
7Reserved.--
6DM_PULLDN_EN : DM pull down enableRW0x0
5DM_PULLUP_EN : DM pull up enableRW0x0
4DM_PULLUP_HISEL : Enable the second DM pull up resistor. 0 - Pull = Rpu2; 1 - Pull = Rpu1 + Rpu2RW0x0
3Reserved.--
2DP_PULLDN_EN : DP pull down enableRW0x0
1DP_PULLUP_EN : DP pull up enableRW0x0
0DP_PULLUP_HISEL : Enable the second DP pull up resistor. 0 - Pull = Rpu2; 1 - Pull = Rpu1 + Rpu2RW0x0
USB: USBPHY_DIRECT_OVERRIDE Register

Offset: 0x080

Description

Override enable for each control in usbphy_direct

Table 1214.
USBPHY_DIRECT_OVERRIDE Register

BitsDescriptionTypeReset
31:19Reserved.--
18RX_DM_OVERRIDE_ENRW0x0
BitsDescriptionTypeReset
17RX_DP_OVERRIDE_ENRW0x0
16RX_DD_OVERRIDE_ENRW0x0
15TX_DIFFMODE_OVERRIDE_ENRW0x0
14:13Reserved.--
12DM_PULLUP_OVERRIDE_ENRW0x0
11TX_FSSLEW_OVERRIDE_ENRW0x0
10TX_PD_OVERRIDE_ENRW0x0
9RX_PD_OVERRIDE_ENRW0x0
8TX_DM_OVERRIDE_ENRW0x0
7TX_DP_OVERRIDE_ENRW0x0
6TX_DM_OE_OVERRIDE_ENRW0x0
5TX_DP_OE_OVERRIDE_ENRW0x0
4DM_PULLDN_EN_OVERRIDE_ENRW0x0
3DP_PULLDN_EN_OVERRIDE_ENRW0x0
2DP_PULLUP_EN_OVERRIDE_ENRW0x0
1DM_PULLUP_HISEL_OVERRIDE_ENRW0x0
0DP_PULLUP_HISEL_OVERRIDE_ENRW0x0
USB: USBPHY_TRIM Register

Offset: 0x084

Description

Used to adjust trim values of USB phy pull down resistors.

Table 1215.
USBPHY_TRIM
Register

BitsDescriptionTypeReset
31:13Reserved.--
12:8DM_PULLDN_TRIM: Value to drive to USB PHY
DM pulldown resistor trim control
Experimental data suggests that the reset value will work, but this register allows adjustment if required
RW0x1f
7:5Reserved.--
4:0DP_PULLDN_TRIM: Value to drive to USB PHY
DP pulldown resistor trim control
Experimental data suggests that the reset value will work, but this register allows adjustment if required
RW0x1f
USB: LINESTATE_TUNING Register

Offset: 0x088

Description

Used for debug only.

Table 1216.
LINESTATE_TUNING
Register

Bits 2 1 0 BitsDescription RESET PUSH DATA Description: Reset (before sending a new key)Type RW RW RW TypeReset 0x0 0x0 0x0 Reset
Register 31:12Reserved.--
11:8SPARE_FIXRW0x0
7DEV_LS_WAKE_FIX: Device - exit suspend on any non-idle signalling, not qualified with a 1ms timerRW0x1
6DEV_RX_ERR_QUIESCE: Device - suppress repeated errors until the device FSM is next in the process of decoding an inbound packet.RW0x1
5SIE_RX_CHATTER_SE0_FIX: RX - when recovering from line chatter or bitstuff errors, treat SE0 as the end of chatter as well as 8 consecutive idle bits.RW0x1
4SIE_RX_BITSTUFF_FIX: RX - when a bitstuff error is signalled by rx_dasm, unconditionally terminate RX decode to avoid a hang during certain packet phases.RW0x1
3DEV_BUFF_CONTROL_DOUBLE_READ_FIX match.: Device - the controller FSM performs two reads of the buffer status memory address toRW0x1
2MULTI_HUB_FIX: Host - increase inter-packet and turnaround timeouts to accommodate worst-case hub delays.RW0x0
1LINESTATE_DELAY sampling.: Device/Host - add an extra 1-bit debounce of linestateRW0x0
0RCV_DELAY: Device - register the received data to account for hub bit dribble before EOP. Only affects certain hubs.RW0x0
BitsRaw Interrupts DescriptionTypeReset
31:24Reserved.--
23EPX_STOPPED_ON_NAK: Source: NAK_POLL.EPX_STOPPED_ON_NAKRO0x0
22DEV_SM_WATCHDOG_FIRED: Source: DEV_SM_WATCHDOG.FIREDRO0x0
21ENDPOINT_ERROR: Source: SIE_STATUS.ENDPOINT_ERRORRO0x0
20RX_SHORT_PACKET: Source: SIE_STATUS.RX_SHORT_PACKETRO0x0
19EP_STALL_NAK: Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK.RO0x0
18ABORT_DONE: Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE.RO0x0
17DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet.RO0x0
16SETUP_REQ: Device. Source: SIE_STATUS.SETUP_RECRO0x0
15DEV_RESUME_FROM_HOST: Set when the device receives a resume from the host. Cleared by writing to SIE_STATUS.RESUMERO0x0
USB: INTR Register

Offset: 0x08c

Description

Raw Interrupts

Table 1217. INTR
Register

Bits 2 1 0 BitsDescription RESET PUSH DATA Description: Reset (before sending a new key)Type RW RW RW TypeReset 0x0 0x0 0x0 Reset
9ERROR_CRC: Source: SIE_STATUS.CRC_ERRORRO0x0
8ERROR_BIT_STUFF: Source: SIE_STATUS.BIT_STUFF_ERRORRO0x0
7ERROR_RX_OVERFLOW: Source: SIE_STATUS.RX_OVERFLOWRO0x0
6ERROR_RX_TIMEOUT: Source: SIE_STATUS.RX_TIMEOUTRO0x0
5ERROR_DATA_SEQ: Source: SIE_STATUS.DATA_SEQ_ERRORRO0x0
4BUFF_STATUS: Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS.RO0x0
3TRANS_COMPLETE: Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit.RO0x0
2HOST_SOF: Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RDRO0x0
1HOST_RESUME: Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUMERO0x0
0HOST_CONN_DIS: Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing toRO0x0
BitsInterrupt Enable DescriptionTypeReset
31:24Reserved.--
23EPX_STOPPED_ON_NAK: Source: NAK_POLL.EPX_STOPPED_ON_NAKRW0x0
22DEV_SM_WATCHDOG_FIRED: Source: DEV_SM_WATCHDOG.FIREDRW0x0
21ENDPOINT_ERROR: Source: SIE_STATUS.ENDPOINT_ERRORRW0x0
20RX_SHORT_PACKET: Source: SIE_STATUS.RX_SHORT_PACKETRW0x0
19EP_STALL_NAK: Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK.RW0x0
18ABORT_DONE: Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE.RW0x0
17DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet.RW0x0
USB: INTE Register

Offset: 0x090

Description

Interrupt Enable

Table 1218. INTE Register

Bits 2 1 0 BitsDescription RESET PUSH DATA Description: Reset (before sending a new key)Type RW RW RW TypeReset 0x0 0x0 0x0 Reset
11VBUS_DETECT: Source: SIE_STATUS.VBUS_DETECTEDRW0x0
10STALL : Source: SIE_STATUS.STALL_RECRW0x0
9ERROR_CRC: Source: SIE_STATUS.CRC_ERRORRW0x0
8ERROR_BIT_STUFF: Source: SIE_STATUS.BIT_STUFF_ERRORRW0x0
7ERROR_RX_OVERFLOW: Source: SIE_STATUS.RX_OVERFLOWRW0x0
6ERROR_RX_TIMEOUT: Source: SIE_STATUS.RX_TIMEOUTRW0x0
5ERROR_DATA_SEQ: Source: SIE_STATUS.DATA_SEQ_ERRORRW0x0
4BUFF_STATUS: Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS.RW0x0
3TRANS_COMPLETE: Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit.RW0x0
2HOST_SOF: Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RDRW0x0
1HOST_RESUME: Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUMERW0x0
0HOST_CONN_DIS: Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing toRW0x0
BitsInterrupt Force DescriptionTypeReset
31:24Reserved.--
23EPX_STOPPED_ON_NAK: Source: NAK_POLL.EPX_STOPPED_ON_NAKRW0x0
22DEV_SM_WATCHDOG_FIRED: Source: DEV_SM_WATCHDOG.FIREDRW0x0
21ENDPOINT_ERROR: Source: SIE_STATUS.ENDPOINT_ERRORRW0x0
20RX_SHORT_PACKET: Source: SIE_STATUS.RX_SHORT_PACKETRW0x0
19EP_STALL_NAK: Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK.RW0x0
USB: INTF Register

Offset: 0x094

Description

Interrupt Force

Table 1219. INTF Register

Bits 2 1 0 BitsDescription RESET PUSH DATA Description: Reset (before sending a new key)Type RW RW RW TypeReset 0x0 0x0 0x0 Reset
13DEV_CONN_DIS: Set when the device connection state changes. Cleared byRW0x0
12BUS_RESETwriting to SIE_STATUS.CONNECTED : Source: SIE_STATUS.BUS_RESETRW0x0
11VBUS_DETECT: Source: SIE_STATUS.VBUS_DETECTEDRW0x0
10STALL : Source: SIE_STATUS.STALL_RECRW0x0
9ERROR_CRC: Source: SIE_STATUS.CRC_ERRORRW0x0
8ERROR_BIT_STUFF: Source: SIE_STATUS.BIT_STUFF_ERRORRW0x0
7ERROR_RX_OVERFLOW: Source: SIE_STATUS.RX_OVERFLOWRW0x0
6ERROR_RX_TIMEOUT: Source: SIE_STATUS.RX_TIMEOUTRW0x0
5ERROR_DATA_SEQ: Source: SIE_STATUS.DATA_SEQ_ERRORRW0x0
4BUFF_STATUS: Raised when any bit in BUFF_STATUS is set. Clear by clearingRW0x0
3TRANS_COMPLETEall bits in BUFF_STATUS. : Raised every time SIE_STATUS.TRANS_COMPLETE isRW0x0
2HOST_SOFset. Clear by writing to this bit. : Host: raised every time the host sends a SOF (Start of Frame).RW0x0
1HOST_RESUMECleared by reading SOF_RD : Host: raised when a device wakes up the host. Cleared byRW0x0
0HOST_CONN_DISwriting to SIE_STATUS.RESUME : Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing toRW0x0
BitsDescriptionTypeReset
31:24Reserved.--
23EPX_STOPPED_ON_NAK: Source: NAK_POLL.EPX_STOPPED_ON_NAKRO0x0
22DEV_SM_WATCHDOG_FIRED: Source: DEV_SM_WATCHDOG.FIREDRO0x0
21ENDPOINT_ERROR: Source: SIE_STATUS.ENDPOINT_ERRORRO0x0
USB: INTS Register

Offset: 0x098

Description

Interrupt status after masking & forcing

Table 1220. INTS Register

BitsDescriptionTypeReset
20RX_SHORT_PACKET : Source: SIE_STATUS.RX_SHORT_PACKETRO0x0
19EP_STALL_NAK : Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK.RO0x0
18ABORT_DONE : Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE.RO0x0
17DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet. Cleared by reading SOF_RDRO0x0
16SETUP_REQ : Device. Source: SIE_STATUS.SETUP_RECRO0x0
15DEV_RESUME_FROM_HOST : Set when the device receives a resume from the host. Cleared by writing to SIE_STATUS.RESUMERO0x0
14DEV_SUSPEND : Set when the device suspend state changes. Cleared by writing to SIE_STATUS.SUSPENDEDRO0x0
13DEV_CONN_DIS : Set when the device connection state changes. Cleared by writing to SIE_STATUS.CONNECTEDRO0x0
12BUS_RESET : Source: SIE_STATUS.BUS_RESETRO0x0
11VBUS_DETECT : Source: SIE_STATUS.VBUS_DETECTEDRO0x0
10STALL : Source: SIE_STATUS.STALL_RECRO0x0
9ERROR_CRC : Source: SIE_STATUS.CRC_ERRORRO0x0
8ERROR_BIT_STUFF : Source: SIE_STATUS.BIT_STUFF_ERRORRO0x0
7ERROR_RX_OVERFLOW : Source: SIE_STATUS.RX_OVERFLOWRO0x0
6ERROR_RX_TIMEOUT : Source: SIE_STATUS.RX_TIMEOUTRO0x0
5ERROR_DATA_SEQ : Source: SIE_STATUS.DATA_SEQ_ERRORRO0x0
4BUFF_STATUS : Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS.RO0x0
3TRANS_COMPLETE : Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit.RO0x0
2HOST_SOF : Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RDRO0x0
1HOST_RESUME : Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUMERO0x0
0HOST_CONN_DIS : Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEEDRO0x0
USB: SOF_TIMESTAMP_RAW Register

Offset: 0x100

Table 1221.
SOF_TIMESTAMP_RA
W Register

Bits Register 31:28 27 26 25 24Description QSPI_SD QSPI_CSN QSPI_SCK USB_DM USB_DPType WO WO WO WO WOReset 0x0 0x0 0x0 0x0 0x0
W Register 31:21Reserved.- -
20:0Device only. Raw value of free-running PHY clock counter @48MHz. Used to calculate time between SOF events.RO 0x000000
Table 1222. Offset Bits: 0x104 DescriptionType Reset
SOF_TIMESTAMP_LAS T Register 31:21Reserved.- -
20:0Device only. Value of free-running PHY clock counter @48MHz when last SOF event occured.RO 0x000000
Table 1223. Offset Bits: 0x108 DescriptionTypeReset
SM_STATE Register 31:12Reserved.--
11:8RX_DASMRO0x0
7:5BC_STATERO0x0
4:0STATERO0x00
Description TX error count for each endpoint. Write to each field to reset the counter to 0.
Table 1224. BitsTX error count for each endpoint. Write to each field to reset the counter to 0 Description. TypeReset
EP_TX_ERROR Register 31:30EP15WC0x0
29:28EP14WC0x0
27:26EP13WC0x0
25:24EP12WC0x0
23:22EP11WC0x0
21:20EP10WC0x0
19:18EP9WC0x0
17:16EP8WC0x0
15:14EP7WC0x0
13:12EP6WC0x0
11:10EP5WC0x0
9:8EP4WC0x0
7:6EP3WC0x0
USB: SOF_TIMESTAMP_LAST Register

Offset: 0x104

Table 1222.
SOF_TIMESTAMP_LAS
T Register

USB: SM_STATE Register

Offset: 0x108

Table 1223.
SM_STATE Register

USB: EP_TX_ERROR Register

Offset: 0x10c

Description

TX error count for each endpoint. Write to each field to reset the counter to 0.

Table 1224.
EP_TX_ERROR
Register

BitsDescriptionTypeReset
5:4EP2WC0x0
3:2EP1WC0x0
1:0EP0WC0x0

USB: EP_RX_ERROR Register

Offset: 0x110

Description

RX error count for each endpoint. Write to each field to reset the counter to 0.

Table 1225.
EP_RX_ERROR
Register

BitsDescriptionTypeReset
31EP15_SEQWC0x0
30EP15_TRANSACTIONWC0x0
29EP14_SEQWC0x0
28EP14_TRANSACTIONWC0x0
27EP13_SEQWC0x0
26EP13_TRANSACTIONWC0x0
25EP12_SEQWC0x0
24EP12_TRANSACTIONWC0x0
23EP11_SEQWC0x0
22EP11_TRANSACTIONWC0x0
21EP10_SEQWC0x0
20EP10_TRANSACTIONWC0x0
19EP9_SEQWC0x0
18EP9_TRANSACTIONWC0x0
17EP8_SEQWC0x0
16EP8_TRANSACTIONWC0x0
15EP7_SEQWC0x0
14EP7_TRANSACTIONWC0x0
13EP6_SEQWC0x0
12EP6_TRANSACTIONWC0x0
11EP5_SEQWC0x0
10EP5_TRANSACTIONWC0x0
9EP4_SEQWC0x0
8EP4_TRANSACTIONWC0x0
7EP3_SEQWC0x0
6EP3_TRANSACTIONWC0x0
5EP2_SEQWC0x0
Bits 4 3 2 1 0Description EP2_TRANSACTION EP1_SEQ EP1_TRANSACTION EP0_SEQ EP0_TRANSACTIONType WC WC WC WC WCReset 0x0 0x0 0x0 0x0 0x0
Bits DEV_SM_WATCHDOGDescriptionTypeReset
Register 31:21Reserved.--
20FIREDWC0x0
19RESET: Set to 1 to forcibly reset the device state machine on watchdog expiry RW0x0
18ENABLERW0x0
17:0LIMITRW0x00000
based on this timebase. RP2350 has two instances of the system timer: separately controlled timers, each in a different security domain. It supports the following features: A single 64-bit counter, incrementing once per microsecondTIMER0 and TIMER1. This allows for two
Four alarms that match on the lower 32 bits of the counter and generate IRQ on match The timer uses a one microsecond reference generated by the tick generators (seeSection 8.5), and derived from the
reference clock (Figure 33), which itself is usually connected directly to the crystal oscillator (Section 8.2) .
•12.8.1.1. Changes from RP2040 RP2350 now has two timer instances:TIMER0 and TIMER1
•On RP2350, the tick source for each timer comes from the system-level tick generators (seeSection 8.5)
•RP2350 added two new registers: LOCKEDis used to disable write access to the timer, andSOURCE allows the timer to
USB: DEV_SM_WATCHDOG Register

Offset: 0x114

Description

Watchdog that forces the device state machine to idle and raises an interrupt if the device stays in a state that isn't idle for the configured limit. The counter is reset on every state transition.

Set limit while enable is low and then set the enable.

Table 1226.
DEV_SM_WATCHDOG
Register