68. USB Type-C ® /USB Power Delivery interface (UCPD)

68.1 UCPD introduction

The USB Type-C/USB Power Delivery interface complies with:

It integrates the physical layer of the Power Delivery (PD) specification, with CC signaling method (no VBUS), for operation with Type-C cables.

68.2 UCPD main features

68.3 UCPD implementation

The devices have one UCPD controller to support one USB Type-C port.

In the following table, “X” denotes supported, and “-” not supported.

Table 753. UCPD implementation

UCPD featureUCPD1
Dead battery support via UCPDx_DBCC1 and UCPDx_DBCC2 external signalsX
UCPDx_FRSTX as alternate function pinX
Fully automatic trimmingX(1)
USB PD receiver hardware filter controlX
Discrete-component PHY support-

1. No software trimming required.

68.4 UCPD functional description

The UCPD peripheral provides hardware support for the USB Power Delivery control interface specification, using I/Os specifically designed for that purpose.

The built-in PHY directly detects Type-C voltage levels, supports Power Delivery BIST carrier mode 2 (Tx only), BIST test data (Tx and Rx), and Power Delivery Rx FRS signaling.

For Power Delivery FRS Tx signaling, the device can be configured to control, through UCPD_FRSTX pin (alternate function), external NMOS transistors that ensure low-resistance pull-down on CC lines.

The UCPD transmitter BMC (bi-phase mark) encodes and transmits data: preamble, SOP, payload data from protocol layer (after 4b5b-encoding), CRC, and EOP on the Type-C connector CC lines. It automatically inserts inter-frame gap and executes “Hard Reset”.

The UCPD receiver detects SOP, BMC-decodes the incoming stream, recovers the preamble, 4b5b-decodes payload data, detects EOP, and checks CRC. It automatically detects five K-code SOP and two Reset ordered sets, plus two software-defined patterns (allows for only three out of four K-codes being correctly received, as defined by the standard).

In Stop mode, the peripheral maintains the ability to detect incoming USB Power Delivery messages and FRS signaling, which allows low-power operation.

68.4.1 UCPD block diagram

Figure 977. UCPD block diagram

UCPD block diagram showing internal components like Registers, Power Delivery Tx/Rx, and Analog PHY, along with external connections to RCC, NVIC, EXTI, and DMA.

The diagram illustrates the internal architecture of the UCPD (USB Type-C/USB Power Delivery interface). It is divided into several functional blocks:

MSv45535V2

UCPD block diagram showing internal components like Registers, Power Delivery Tx/Rx, and Analog PHY, along with external connections to RCC, NVIC, EXTI, and DMA.

The following table lists external signals (alternate or additional I/O functions).

Table 754. UCPD signals on pins

Pin nameSignal typeDescription
UCPDx_FRSTXOutputUSB Type-C fast role swap (FRS) signaling control, applicable to DRPs only. The signal (active high) drives an external NMOS transistor that pulls down the active CC line. A typical application has two such transistors (one per CC line) and reserves a separate I/O to drive either NMOS. Initially, the I/Os are configured as low-driving GPIOs. Upon detecting, through the Type-C state machine, the orientation of the cable attached, which determines the active CC line, the I/O of the active CC line must be set to its UCPDx_FRSTX alternate function and the I/O of the inactive CC line as low-driving GPIO.
UCPDx_CC1Input/outputUSB Type-C configuration control line 1, to be routed to the USB Type-C connector CC1 terminal.
UCPDx_CC2Input/outputUSB Type-C configuration control line 2, to be routed to the USB Type-C connector CC2 terminal.
UCPDx_DBCC1InputUSB Type-C configuration control line 1 dead battery signal, to be routed to the USB Type-C connector CC1 terminal if dead battery support is required.
UCPDx_DBCC2InputUSB Type-C configuration control line 2 dead battery signal, to be routed to the USB Type-C connector CC2 terminal if dead battery support is required.

The following table lists key internal signals.

Table 755. UCPD internal signals

Internal signal nameSignal typeDescription
ucpd_pclkInputAPB clock for registers
ucpd_ker_ckInputKernel clock
ucpd_tx_dmaInput/OutputRx DMA acknowledge / request
ucpd_rx_dmaInput/OutputTx DMA acknowledge / request
ucpd_itOutputInterrupt request (all interrupts OR-ed) connected to NVIC
ucpd_wkupOutputWake-up request connected to EXTI
clk_rqOutputClock request connected to RCC

68.4.2 UCPD reset and clocks

The peripheral has a single reset signal (APB bus reset).

The register section is clocked with the APB clock (ucpd_pclk).

The main functional part of the transmitter is clocked with ucpd_clk clock, pre-scaled from the ucpd_ker_ck clock according to the PSC_UCPDCLK[2:0] bitfield of the UCPD_CFGR1 register. The main functional part of the receiver is clocked with the ucpd_rx_clk recovered from the incoming bitstream.

The receiver is designed to work in the clock frequency range from 6 to 18 MHz. However, the optimum performance is ensured in the range from 6 to 12 MHz.

The following diagram shows the clocking and timing elements of the UCPD peripheral.

Figure 978. Clock division and timing elements

Block diagram of clock division and timing elements for the UCPD peripheral. The diagram shows the flow from ucpd_ker_ck through a Pre-scaler (1 to 16) to ucpd_clk, then through a 'Half bit' divider (1 to 64) to hbit_clk (~ 600 kHz). The ucpd_pclk input goes to Registers. The hbit_clk feeds into Counters, which include 'tTransitionWindow' (2 to 32) and 'tInterFrameGap' (2 to 32). These counters feed into the BMC receiver and BMC transmitter. Control signals PSC_UCPDCLK[2:0] and HBITCLKDIV[5:0] are shown. The diagram is labeled MSv45536V3.

The diagram illustrates the clocking and timing elements of the UCPD peripheral. It shows the following components and connections:

Block diagram of clock division and timing elements for the UCPD peripheral. The diagram shows the flow from ucpd_ker_ck through a Pre-scaler (1 to 16) to ucpd_clk, then through a 'Half bit' divider (1 to 64) to hbit_clk (~ 600 kHz). The ucpd_pclk input goes to Registers. The hbit_clk feeds into Counters, which include 'tTransitionWindow' (2 to 32) and 'tInterFrameGap' (2 to 32). These counters feed into the BMC receiver and BMC transmitter. Control signals PSC_UCPDCLK[2:0] and HBITCLKDIV[5:0] are shown. The diagram is labeled MSv45536V3.

Refer to the USB PD specification in order to set appropriate delays. For tTransitionWindow and especially for tInterFrameGap, the clock frequency uncertainty must be taken into account so as to respect specified timings in all cases.

68.4.3 Physical layer protocol

The physical layer covers the signaling underlying the USB Power Delivery specification.

On the transmitter side its main function is to form packets according to the defined packet format including generally:

Before going on the CC line, the data stream is BMC-encoded, respecting specified timing restrictions.

On the receive side, the principle task is to:

The receive is basically a reverse of the transmit process, thus starting with BMC data stream decoding.

Symbol encoding

Apart from the preamble all symbols are encoded with a 4b5b scheme according to the specification shown in the following table.

Table 756. 4b5b symbol encoding table

Name4b5bSymbol description
0000011110hex data 0
1000101001hex data 1
2001010100hex data 2
3001110101hex data 3
4010001010hex data 4
5010101011hex data 5
6011001110hex data 6
7011101111hex data 7
8100010010hex data 8
9100110011hex data 9
A101010110hex data A
B101110111hex data B
C110011010hex data C

Table 756. 4b5b symbol encoding table (continued)

Name4b5bSymbol description
D110111011hex data D
E111011100hex data E
F111111101hex data F
Sync-1K-code11000Startsynch #1
Sync-2K-code10001Startsynch #2
RST-1K-code00111Hard Reset #1
RST-2K-code11001Hard Reset #2
EOPK-code01101EOP
ReservedError00000Do Not Use
ReservedError00001Do Not Use
ReservedError00010Do Not Use
ReservedError00011Do Not Use
ReservedError00100Do Not Use
ReservedError00101Do Not Use
Sync-3K-code00110Startsynch #3
ReservedError01000Do Not Use
ReservedError01100Do Not Use
ReservedError10000Do Not Use
ReservedError11111Do Not Use

Ordered sets

An ordered set consists of four K-codes as shown in the following figure.

Figure 979. K-code transmission

Diagram illustrating K-code transmission. It shows four K-codes (K-code 4, K-code 3, K-code 2, K-code 1) being transmitted. K-code 1 is the first to be transmitted, followed by K-code 2, K-code 3, and K-code 4. The transmission of K-code 1 is shown as a sequence of bits (b4 to b0). The diagram also indicates the transmission order for the bits of each K-code, with K-code 4 being transmitted last and K-code 1 being transmitted first.

The diagram illustrates the transmission of K-codes. At the top, four boxes represent K-codes: K-code 4, K-code 3, K-code 2, and K-code 1. K-code 1 is labeled 'Transmit first' and K-code 4 is labeled 'Transmit last'. An arrow points from K-code 1 down to a box containing 'b4' and 'b0'. Below this, five boxes represent bits: Bit 4, Bit 3, Bit 2, Bit 1, and Bit 0. Bit 0 is labeled 'Transmit first' and Bit 4 is labeled 'Transmit last'. An arrow points from the 'b4 b0' box down to Bit 0.

MSv45537V1

Diagram illustrating K-code transmission. It shows four K-codes (K-code 4, K-code 3, K-code 2, K-code 1) being transmitted. K-code 1 is the first to be transmitted, followed by K-code 2, K-code 3, and K-code 4. The transmission of K-code 1 is shown as a sequence of bits (b4 to b0). The diagram also indicates the transmission order for the bits of each K-code, with K-code 4 being transmitted last and K-code 1 being transmitted first.

The following table lists the defined ordered sets, including all possible SOP* sequences.

At the physical layer, the Hard Reset has higher priority than the other ordered sets so it can interrupt an ongoing Tx message.

Table 757. Ordered sets

Ordered set nameK-code #1K-code #2K-code #3K-code #4
SOPSync-1Sync-1Sync-1Sync-2
SOP'Sync-1Sync-1Sync-3Sync-3
SOP''Sync-1Sync-3Sync-1Sync-3
Hard ResetRST-1RST-1RST-1RST-2
Cable ResetRST-1Sync-1RST-1Sync-3
SOP'_DebugSync-1RST-2RST-2Sync-3
SOP''_DebugSync-1RST-2Sync-3Sync-2

On reception, the physical layer must accept ordered sets with any combination of three correct K-codes out of four, as shown in the following table:

Table 758. Validation of ordered sets

Status1st code2nd code3rd code4th code
ValidCorruptK-codeK-codeK-code
ValidK-codeCorruptK-codeK-code

Table 758. Validation of ordered sets (continued)

Status1st code2nd code3rd code4th code
ValidK-codeK-codeCorruptK-code
ValidK-codeK-codeK-codeCorrupt
Valid (perfect)K-codeK-codeK-codeK-code
Not valid (example)K-codeCorruptK-codeCorrupt

Bit ordering at transmission

Allowed transmission data units / data sizes are in the following table.

Table 759. Data size

Data unitNon-encodedEncoded
Byte8-bits10-bits
Word16-bits20-bits
DWord32-bits40-bits

The bit transmission order is shown in the following figure.

Figure 980. Transmit order for various sizes of data

Diagram showing the transmit order for various sizes of data, from 32-bit DWord down to 5-bit 4b5b encoding.

The diagram illustrates the bit transmission order for different data sizes. It starts with a 32-bit DWord (bits b31 to b0). This is split into two 16-bit Words. The first Word (bits b15 to b0) is labeled 'Transmit first', while the second Word (bits b31 to b16) is labeled 'Transmit last'. The first Word is further divided into two 8-bit Bytes. The first Byte (bits b7 to b0) is labeled 'Transmit first', and the second Byte (bits b15 to b8) is labeled 'Transmit last'. The first Byte is then split into two 4-bit nibbles: the upper nibble (bits b7 to b4) and the lower nibble (bits b3 to b0). These two nibbles are combined into a 4b5b encoding, represented by a box labeled 'bit4 bit0'. Finally, this 5-bit encoding is transmitted from 'Transmit first' (Bit 0) to 'Transmit last' (Bit 4). The diagram is labeled MSv45538V1 in the bottom right corner.

Diagram showing the transmit order for various sizes of data, from 32-bit DWord down to 5-bit 4b5b encoding.

Packet format

Messages other than Hard Reset and Cable Reset

The packet format is shown in the following figure, with information on 4b5b encode and data source.

Figure 981. Packet format

Diagram of a packet format showing fields: Preamble (training for receiver), SOP* (start of packet), Header, Byte 0, Byte 1, ..., Byte n-1, Byte n, CRC, and EOP (end of packet). A legend indicates encoding and layer source.

The diagram illustrates the structure of a packet. It consists of a sequence of fields: Preamble (training for receiver), SOP* (start of packet), Header, Byte 0, Byte 1, followed by an ellipsis, then Byte n-1, Byte n, CRC, and EOP (end of packet). The Preamble and SOP* fields are shaded light gray, while the CRC and EOP fields are shaded dark gray. The Header and all Byte fields are white. A legend below the diagram defines the shading: light gray for 'Provided by the physical layer, not 4b5b-encoded', dark gray for 'Provided by the physical layer, 4b5b-encoded', and white for 'Provided by the protocol layer, 4b5b-encoded'. The identifier 'MSv45539V2' is located in the bottom right corner of the diagram area.

Diagram of a packet format showing fields: Preamble (training for receiver), SOP* (start of packet), Header, Byte 0, Byte 1, ..., Byte n-1, Byte n, CRC, and EOP (end of packet). A legend indicates encoding and layer source.

Hard Reset

The physical layer handles the Hard Reset signaling differently than the other types of message as it has higher priority to be able to interrupt an ongoing transfer.

The physical layer specification implies the following sequence in the case of an ongoing Tx message:

  1. 1. Terminate the message by sending an EOP K-code and discard the rest of the message.
  2. 2. Wait for tInterFrameGap time.
  3. 3. If the CC line is not idle, wait until it goes idle.
  4. 4. Send the preamble followed by the four K-codes of Hard Reset signaling.
  5. 5. Disable the CC channel (stop sending and receiving), reset the physical layer and inform the protocol layer that the physical layer is reset.
  6. 6. Re-enable the channel when requested by the protocol layer.

Figure 982. Line format of Hard Reset

Diagram of the line format of Hard Reset showing fields: Preamble (training for receiver), RST-1, RST-1, RST-1, and RST-2. A legend indicates encoding and layer source.

The diagram shows the line format for a Hard Reset. It starts with a Preamble (training for receiver) field, followed by four RST fields: RST-1, RST-1, RST-1, and RST-2. The Preamble field is shaded light gray, and the RST fields are shaded dark gray. A bracket below the RST fields groups them as the 'Hard Reset ordered set'. A legend below the diagram defines the shading: light gray for 'Provided by the physical layer, not 4b5b-encoded' and dark gray for 'Provided by the physical layer, 4b5b-encoded'. The identifier 'MSv45540V2' is located in the bottom right corner of the diagram area.

Diagram of the line format of Hard Reset showing fields: Preamble (training for receiver), RST-1, RST-1, RST-1, and RST-2. A legend indicates encoding and layer source.

Cable Reset

Cable Reset shown in the following figure is similar in format to Hard Reset, but unlike Hard Reset it does not require a specific high-priority treatment.

Figure 983. Line format of Cable Reset

Diagram showing the line format of Cable Reset with fields: Preamble (training for receiver), RST-1, Sync-1, RST-1, and Sync-3. Includes a legend for physical layer encoding and a reference code MSv45541V2.
Diagram showing the line format of Cable Reset with fields: Preamble (training for receiver), RST-1, Sync-1, RST-1, and Sync-3. Includes a legend for physical layer encoding and a reference code MSv45541V2.

Collision avoidance

The physical layer respects the tInterFrameGap delay between end of last-transmitted bit of a Tx message, and the first bit of a following message.

It also checks the idle state of the CC line before starting transmission. The CC line is considered idle if it shows less than three (nTransitionCount) transitions within tTransitionWindow (12 to 20 μs). The Power Delivery specification revision 3.1 also requires to manage the Rp value (source) and monitor Type-C voltage level for these Rp modifications (at the sink).

Physical layer signaling schemes

The bit are signaled with bi-phase mark coding (BMC).

BIST

Depending on the BIST action required by the protocol layer, either of the following can be run:

The two possible patterns supported in UCPD (corresponding to “BMC” mode) are:

BIST test data pattern

The test data pattern is not viewed as a special case in UCPD.

The BIST test data packet frame format is shown in the following figure.

Figure 984. BIST test data frame

Diagram of BIST test data frame structure showing Preamble (training for receiver), SOP* (start of packet), Header (Data objects = 7), BIST Test Data BDO, BIST test data (192 bits), CRC, and EOP (end of packet). A legend categorizes blocks as physical layer non-4b5b encoded, physical layer 4b5b encoded, or protocol layer 4b5b encoded. Document reference MSv45542V2.
Diagram of BIST test data frame structure showing Preamble (training for receiver), SOP* (start of packet), Header (Data objects = 7), BIST Test Data BDO, BIST test data (192 bits), CRC, and EOP (end of packet). A legend categorizes blocks as physical layer non-4b5b encoded, physical layer 4b5b encoded, or protocol layer 4b5b encoded. Document reference MSv45542V2.

This is a fixed length test data pattern. In reality the only aspect that marks its difference from the general packet format already shown in Figure 981: Packet format is the contents of the Header. As UCPD receives the Tx Header contents via programming (it is simply viewed as part of the payload), it is only this programming (and not the block's behavior) that differentiates the general packet from the BIST Test Data packet.

BIST Carrier Mode 2

When required, this BIST test mode sends an alternating pattern of 1010 that is continually repeated. As this mode is intended for signal analysis it is stable condition with (in V1.0 of the USB PD specification) no defined length. Starting from V1.1 of the USB PD specification, the protocol layer defines a counter that indicates when to exit this mode.

The way to quit the infinite 1010 sequence (according to requirements of the USB PD specification) is to disable the UCPD peripheral via the UCPDEN bit.

Figure 985. BIST Carrier Mode 2 frame

Diagram of BIST Carrier Mode 2 frame structure showing Preamble (training for receiver), SOP* (start of packet), and repeating pattern '101010101010101010...... (repeated until UCPD is disabled)' ending with UCPDEN = 0. Document reference MSv45543V2.
Diagram of BIST Carrier Mode 2 frame structure showing Preamble (training for receiver), SOP* (start of packet), and repeating pattern '101010101010101010...... (repeated until UCPD is disabled)' ending with UCPDEN = 0. Document reference MSv45543V2.

68.4.4 UCPD BMC transmitter

The BMC transmitter comprises 4b5b encoding, CRC generation, and BMC encode, as shown in the following figure. Its output goes to the analog PHY through a channel switch.

Figure 986. UCPD BMC transmitter architecture

Block diagram of the UCPD BMC transmitter architecture showing three clock domains: ucpd_pclk, ucpd_clk, and hbit_clk. The ucpd_pclk domain contains registers for Tx message contents (UCPD_TXDR, UCPD_TX_ORDSET, UCPD_TX_PAYSZ), Tx message control (UCPD_CR), and peripheral configuration (UCPD_CFG1, UCPD_CFG2, UCPD_CFG3). Data flows from these registers through a USB PD transmitter state machine and CRC block in the ucpd_clk domain, then through a multiplexer and 4b5b encoder in the hbit_clk domain, finally reaching the BMC encoder and analog PHY. The diagram is labeled MSv45544V2.
Block diagram of the UCPD BMC transmitter architecture showing three clock domains: ucpd_pclk, ucpd_clk, and hbit_clk. The ucpd_pclk domain contains registers for Tx message contents (UCPD_TXDR, UCPD_TX_ORDSET, UCPD_TX_PAYSZ), Tx message control (UCPD_CR), and peripheral configuration (UCPD_CFG1, UCPD_CFG2, UCPD_CFG3). Data flows from these registers through a USB PD transmitter state machine and CRC block in the ucpd_clk domain, then through a multiplexer and 4b5b encoder in the hbit_clk domain, finally reaching the BMC encoder and analog PHY. The diagram is labeled MSv45544V2.

BMC encoder

The bi-phase mark coding method is defined in the IEC 60958-1 Digital Audio Interface Part:1 General Edition 3.0 2008-09 www.iec.ch specification.

The half-bit clock hbit_clk is derived from ucpd_clk through a simple divider controlled by the HBITCLKDIV[5:0] bitfield of the UCPD_CFGR1 register. This ensures the same duration of high and low half-bit periods (if neglecting a small difference due to different rising and falling edge duration and due to jitter), and the same bit duration (if neglecting jitter).

Transmitter timing and collision avoidance

Hardware support of collision avoidance is made as a function of the half bit time for the transmitter. Two counters are implemented:

These two counters once set correctly generates the interframe gap.

Hard Reset in transmitter

In order to facilitate generation of a Hard Reset, a special code of TXMODE field is used. No other fields need to be written.

On writing the correct code, the hardware forces Hard Reset Tx under the correct (optimal) timings with respect to an ongoing Tx message, which (if still in progress) is cleanly terminated by truncating the current sequence and directly appending an EOP K-code sequence. No specific interrupt is generated relating to this truncation event.

Transmitter behavior in the case of errors

The under-run condition (TXUND interrupt) may happen by accident and in this case, the UCPD is starved of (the correct) Tx payload and is not able to complete the Tx message correctly. This is a serious error (for this to happen the software fails to respond in time). As a result the hardware ensures the CRC is incorrect at the end of the message, thus guaranteeing the message to be discarded at the receiver.

68.4.5 UCPD BMC receiver

The UCPD BMC receiver performs:

The receiver is activated as soon as the UCPD peripheral is enabled (via UCPDEN), but it waits for an idle CC line state before attempting to receive a message.

The following figure shows the UCPD BMC receiver high-level architecture.

Figure 987. UCPD BMC receiver architecture

Figure 987: UCPD BMC receiver architecture diagram. The diagram is divided into three clock domains: ucpd_clk, ucpd_rx_clk, and ucpd_pclk. In the ucpd_clk domain, data from the analog PHY goes to a 'Clock recovery / BMC decode' block. In the ucpd_rx_clk domain, data passes through a '20-bit FIFO', '4b5b decode', and 'CRC check' blocks. It also includes an 'Ordered set / EOP detect' block. In the ucpd_pclk domain, there is a 'USB PD receiver state machine' and a 'Registers' block containing several registers: UCPD_RXDR (Rx payload data), UCPD_RX_PAYSZ (Rx payload size), UCPD_SR (Rx status flags), UCPD_ICR (Interrupt clear), UCPD_IMR (Interrupt mask), UCPD_CR (Rx control), UCPD_RX_ORDSET, UCPD_RX_ORDSET1, and UCPD_RX_ORDSET2 (Ordered set type). Data flows from the FIFO to the 4b5b decoder, then to the CRC checker and the state machine. The state machine interacts with the 'Manage status flags' and 'Message type' registers. The 'Ordered set / EOP detect' block interacts with the 'Ordered set detect/type' register. The 'For future extensions' block is also present. Diagram code MSv45545V2.
Figure 987: UCPD BMC receiver architecture diagram. The diagram is divided into three clock domains: ucpd_clk, ucpd_rx_clk, and ucpd_pclk. In the ucpd_clk domain, data from the analog PHY goes to a 'Clock recovery / BMC decode' block. In the ucpd_rx_clk domain, data passes through a '20-bit FIFO', '4b5b decode', and 'CRC check' blocks. It also includes an 'Ordered set / EOP detect' block. In the ucpd_pclk domain, there is a 'USB PD receiver state machine' and a 'Registers' block containing several registers: UCPD_RXDR (Rx payload data), UCPD_RX_PAYSZ (Rx payload size), UCPD_SR (Rx status flags), UCPD_ICR (Interrupt clear), UCPD_IMR (Interrupt mask), UCPD_CR (Rx control), UCPD_RX_ORDSET, UCPD_RX_ORDSET1, and UCPD_RX_ORDSET2 (Ordered set type). Data flows from the FIFO to the 4b5b decoder, then to the CRC checker and the state machine. The state machine interacts with the 'Manage status flags' and 'Message type' registers. The 'Ordered set / EOP detect' block interacts with the 'Ordered set detect/type' register. The 'For future extensions' block is also present. Diagram code MSv45545V2.

CRC checker

The received bits are fed into a CRC checker which evolves a 32-bit state during the received the payload bitstream. At the end the 32 bits of the CRC also fed into the logic

The EOP detection (5 bits) halts the process and a check is performed for the fixed residual state which confirms correct reception of the payload (in fact the residual is 0xC704DD78).

At this point the UCPD raises interrupt RXMSGEND. If the CRC was not correct then RXERR is set true and the receive data must be discarded.

Under normal operation, this interrupt would previously have been acknowledged and thus cleared. If this is not the case, a different interrupt RXOVR is generated in place of RXMSGEND.

Ordered set detection

This function detects the different ordered sets each consisting of four 5-bit K-codes.

Once we are in the preamble we open a sliding window detection of the ordered set (4 words of 5 bits).

The ordered sets detected include all SOP* codes (SOP, SOP', and SOP''), but also Hard Reset, Cable Reset, SOP'_Debug, SOP''_Debug, and two extensions defined by registers UCPD_RX_ORDEXT1 and UCPD_RX_ORDEXT2.

EOP detection and Hard Reset exception handling

EOP is a fixed 5-bit K-code marking the end of a message.

The way in which a transmitter is required to send a Hard Reset (if a previous message transmit is still in progress) is that this previous message is truncated early with an EOP.

If Hard Reset were ignored, then the EOP detection can be done only at the expected time. However, due to the Hard Reset issue, the EOP detector must be active while an Rx message is arriving. When an “early EOP” is detected, the truncated Rx message is immediately discarded.

Truncated or corrupted message exception

Once the ordered set has been detected, depending on the message, there may be data bytes to be received which is completed with a CRC and EOP. If at any point during these phases an error condition happens:

In both cases, the receiver quits the current message, raising RXMSGEND and RXERR flags.

Short preamble or incomplete ordered set exception

In the exceptional case of the receiver seeing less than half of the expected preamble, the frequency estimation allowing correct BMC-decode becomes impossible. Even if the full preamble is seen, allowing frequency estimation, but the ordered set is not fully received before the line becomes static, the receiver state machine does not start.

In both of these cases, the clock-recovery/BMC decoder re-starts, checking initially for an IDLE condition, followed by a preamble, and then estimating frequency.

68.4.6 UCPD Type-C pull-ups (Rp) and pull-downs (Rd)

UCPD offers simple control of these resistors via ANAMODE and ANASUBMODE[1:0]. In case only one of the CC lines is to be used, it is possible to optimize power consumption by disabling control on the other line, through the CCENABLE[1:0] bitfield.

When the MCU is unpowered, it still presents the “dead battery” Rd, provided that UCPDx_DBCC1 and UCPDx_DBCC2 pins are each connected to UCPDx_CC1 and UCPDx_CC2 pins, respectively.

If dead battery behavior is not required (for example for source only products), then UCPDx_DBCC1 and UCPDx_DBCC2 pins must both be tied to ground.

After power arrives and the MCU boots, the desired behavior (for example source) must be programmed into ANAMODE and ANASUBMODE[1:0] before setting the UCPD_DBDIS bit of the PWR_UCPDR register to remove dead battery pull-down resistor and allow the values just programmed to take effect.

Use of Standby low-power mode is possible for sinks in the unattached state.

Note: In order to guarantee the correct behavior of the Rd resistors, please set the USBPD_DIS option bit to 0 (following the procedure described in the “modification” section of the FLASH chapter).

68.4.7 UCPD Type-C voltage monitoring and de-bouncing

For correct operation of the Type-C state machine and for detecting the cable orientation, the CC1/2 lines must be monitored for voltage level, while ignoring fast events such as peaks.

Thresholds between voltage levels on the CC1/2 lines are determined through PHY threshold detector settings.

The TYPEC_VSTATE_CC1/2[1:0] bitfields reflect the CC1/2 line levels processed with a hardware de-bouncing filter that suppresses high-speed line events such as peaks. The PHYCCSEL bit selects the line, CC1 or CC2, to be used for Power Delivery signaling.

For minimizing the power consumption, it is recommended to use the polling method, with the Type-C detectors only turned on for the instant of polling, rather than keeping the Type-C detectors permanently on and wake the device up from Stop mode upon CC1/2 line events.

68.4.8 UCPD fast role swap (FRS)

FRS signaling

The FRS condition (a pulse of a specific length), is generated upon setting the FRSTX bit.

For the duration of FRS condition, the I/O configured as UCPD_FRSTX (alternate function) controls, with high level, the gate of an external NMOS transistor that pulls the active CC line down.

FRS detection

FRS monitoring is enabled by setting the bit FRSRXEN, after writing PHYCCSEL that selects the active CC line depending on the cable orientation detected.

68.4.9 UCPD DMA Interface

DMA is implemented in the UCPD and when it is enabled the byte-level interrupts to handle UCPD1_TXDR and UCPD1_RXDR registers (Tx and Rx data register, each one byte) are no longer needed.

By enabling bits TXDMAEN and/or RXDMAEN, DMA can be activated independently for Tx and/or Rx functionality.

68.4.10 Wake-up from Stop mode

For power consumption optimization, it is useful to use Stop mode and wait for events on CC lines to wake the MCU up.

In order for this to work, it must be first enabled by writing a 1 to WUPEN.

The events causing the wake-up can be:

68.5 UCPD programming sequences

The normal sequence of use of the UCPD unit is:

  1. 1. Configure UCPD.
  2. 2. Enable UCPD.
  3. 3. Concurrently:
    • – On demand from protocol layer, send Tx message
    • – Intercept (poll or wait for interrupt) relevant Rx messages and recover detail to hand off to protocol layer

Repeat the last point infinitely.

68.5.1 Initialization phase

Use the following sequence for a clean startup:

  1. 1. Prepare all initial clock divider values, by writing the UCPD_CFG register.
  2. 2. Enable the unit, by setting the UCPDEN bit.
  3. 3. Enable the analog Rx filter of either CC line, via the RXAFILTEN bit of the UCPD_CFGR2 register.

68.5.2 Type-C state machine handling

For the general application cases of source, sink, or dual-role port (the last alternating the source and the sink), the software must implement a corresponding USB Type-C state machine. The basic coding is in the following table.

Table 760. Coding for ANAMODE, ANASUBMODE and link with TYPEC_VSTATE_CCx

ANAMODEANASUBMODE[1:0]NotesTYPEC_VSTATE_CCx[1:0]
00011011
0: Source00: DisabledDisabledN/A
01: Default USB Rp-vRa[Def]vRd[Def]vOPEN[Def]N/A
10: 1.5A Rp-vRa[1.5]vRd[1.5]vOPEN[1.5]
11: 3.0A Rp-vRa[3.0]vRd[3.0]vOPEN[3.0]
1: Sinkxx-vRavRd-USBvRd-1.5vRd-3.0

The CCENABLE[1:0] bitfield can disable pull-up/pull-downs on one of the CC lines.

Note: The Type-C state machine depends not only on CC line levels, but also on VBUS presence detection (sink mode) and, when in source mode, determines VCONN generation and VBUS state (ON/OFF/+voltage level); discharge). UCPD does not directly control VBUS generation circuitry nor VCONN load switch (enabling VCONN supply generator to be connected to the CC line), but the application needs these inputs and controls, to function correctly.

General programming sequence (with UCPD configured then enabled)

  1. 1. Set ANAMODE and ANASUBMODE[1:0] based on the current position in USB Type-C state machine (and also the current advertisement in the case of a source). This turns on the appropriate pull-ups/pull-downs on the CC lines, and defines the voltage levels that the TYPEC_VSTATE fields represent. Note that before programming, the PHY is effectively off.
  2. 2. Read TYPEC_VSTATE_CC1/2 to determine the initial Type-C state (for example whether the local source is connected to a remote sink).
  3. 3. In the case of no connection, wait for a connection event.
  4. 4. Assuming a connection is detected and assuming a local Power Delivery functionality is implemented, start sending/receiving Power Delivery messages.
  5. 5. When a new interrupt/event occurs on PHYEVT1/2 indicating a change in stable voltage, re-evaluate the implications and give this input to the Type-C state machine.

Case of a source that needs to change between one of the three possible Rp values (Default-USB / 1.5A / 3.0A) and the sink connected to it:

Programming for a dual-role port (DRP) toggling from source to sink:

Detailed programming sequence (example):

Table 761. Type-C sequence (source: 3A); cable/sink connected (Rd on CC1; Ra on CC2)

Type-C stateANAMODE;
ANASUBMODE[1:0]
CCENABLEPHYCCSELRDCHCC[x]
VCONNEN(1)
Event =>
go to
next line
Comments
Unattached.
SRC
0:Source;
11:Rp3A0
11:both
enabled
0 (don't
care)
0:
[Norm
al]
00:
[neither]
PHYEVT
1: [VRd-
3A0]
Wait for sink attach
detect ; seen on CC1
[EVT1]
Attachwait.
SRC
0
[Rd on
CC1]
PHYEVT
2: [VRa]
Attachwait started (100-
200 ms) ; now also see
the Ra => requesting
VCONN
Attached.
SRC
[VCONN =>
CC2]
0:Source;
11:Rp3A0
[SinkTxOK]
01: CC2
disable
(possible
and
recommend
ed due to
external
VCONN
switch)
10: [CC2
active]
Timer
(100 ms)
and no
PHYEVT
x
Local CC2 disconnected
from PHY (VCONN
switch connects VCONN
source to CC2
externally;
Continue to monitor
PHYEVT1
0:Source;
10:Rp1A5
[SinkTxNG]
SW
timers
(SinkTxN
G)
Source wants to initiate
message sequence
(SinkTxNG condition set
first)
0:Source;
11:Rp3A0
[SinkTxOK]
PHYEVT
1:
[VOpen-
3A0]
Source finished
message sequence
(SinkTxOK condition
afterwards)
11:both
enabled
Wait for Sink
disconnected (Vopen on
CC1)
Unattached
wait.
SRC
0:Source;
11:Rp3A0
0 (do not
care)
1:
[discha
rge]
00:
[neither]
> 0.8V
detection
Discharge VCONN
[CC2] actively [Rdch];
to < 0.8V
Unattached.
SRC
11:both
enabled
0:
[Norm
al]
[Details as first line of
table]

1. Two GPIOs to enable VCONN through external load switch components

68.5.3 USB PD transmit

On reception of a message from the protocol layer (that is, to be sent), prepare Tx message contents by writing the UCPD_TX_ORDSET and UCPD_TX_PAYSZ registers.

The message transmission is triggered by setting the TXSEND bit, with an appropriate value of the TXMODE bitfield.

When the data byte is transmitted, the TXIS flag is raised to request a new data write to the UCPD_TXDR register.

This re-iterates until the entire payload of data is transmitted.

Upon sending the CRC packet, the TXMSGSENT flag is set to indicate the completion of the message transmission.

Hard Reset transmission

As soon as it is known that a Hard Reset needs to be transmitted, setting the TXHRST bit of the UCPD_CR register forces the internal state machine to generate the correct sequence. The value of UCPD_TX_ORDSET does not require update in this precise case (the correct code for Hard Reset is sent by UCPD).

The USB Power Delivery specification requires that in the case of an ongoing message transmission, the Hard Reset takes precedence. In this case, for example, UCPD truncates the payload of the current message, appending EOP to the end. No notification is available via the registers (for example through the TXMSGSEND flag). This is justified by the fact that the Hard Reset takes precedence over any previous activity (for which it is therefore no longer important to know if it is completed).

Use of DMA for transmission

DMA (Direct Memory Access) can be enabled for transmission by setting the TXDMAEN bit in the UCPD_CR register.

For each message:

68.5.4 USB PD receive

Notification of start of the receive message sequence is triggered by an interrupt on UCPD_SR (bit RXORDDET).

The information is recovered by reading:

The data previously read from UCPD_RXDR above must be discarded at this point if the RXERR flag is set.

If the CRC is valid, the received data is transferred to the protocol layer.

For debug purposes, it may be desirable to track statistics of the number of incorrect K-codes received (this is done only when 3/4 K-codes were valid as defined in the specification). This is facilitated through:

Use of DMA for reception

DMA (Direct Memory Access) can be enabled for reception by setting the RXDMAEN bit in the UCPD_CR register.

Whenever a Rx message is expected:

68.6 UCPD low-power modes

A summary of low-power modes is shown below in Table 762: Effect of low power modes on the UCPD.

Table 762. Effect of low power modes on the UCPD

ModeDescription
SleepNo effect
StopDetection of events (Type-C, BMC Rx, FRS detection) remains operational and can wake up the MCU.
StandbyUCPD is not operating, and cannot wake up the MCU. Pull-downs remain active if configured.
UnpoweredDead battery pull-downs remain active.

The UCPD is able to wake up the MCU from Stop mode when it recognizes a relevant event, either:

Wake-up from Stop mode is enabled by setting the WUPEN bit in the UCPD_CFG2 register.

At UCPD level three types of event requiring kernel clock activity may occur during Stop mode:

In order to function correctly with the RCC, the clock request signal is activated (conditional on WUPEN) when there is asynchronous activity on:

68.7 UCPD interrupts

The table below lists the UCPD event flags, with the associated flag clear bits and interrupt enable bits.

Table 763. UCPD interrupt requests

Interrupt eventEvent flagEvent flag/Interrupt clearing methodInterrupt enable control bit
FRS detectionFRSEVTSet FRSEVTCFFRSEVTIE
Type C voltage level change on CC2TYPECEVT2Set TYPECEVT2CFTYPECEVT2IE
Type C voltage level change on CC1TYPECEVT1Set TYPECEVT1CFTYPECEVT1IE
Rx message receivedRXMSGENDSet RXMSGENDCFRXMSGENDIE
Rx data overflowRXOVRSet RXOVRCFRXOVR
Rx Hard Reset detectedRXHRSTDETSet RXHRSTDETCFRXHRSTDETIE
Rx ordered set (4 K-codes) detectedRXORDDETSet RXORDDETCFRXORDDETIE
Receive data register not emptyRXNERead data in UCPD_RXDRRXNEIE
Tx data underrunTXUNDSet TXUNDCFTXUNDIE
Hard Reset sentHRSTSENTSet HRSTSENTCFHRSTSENTIE
Hard Reset discardedHRSTDISCSet HRSTDISCCFHRSTDISCIE
Transmit message abortedTXMSGABTSet TXMSGABTCFTXMSGABTIE
Transmit message sentTXMSGSENTSet TXMSGSENTCFTXMSGSENTIE
Transmit message discardedTXMSGDISCSet TXMSGDISCCFTXMSGDISCIE
Transmit data requiredTXISWrite data to the UCPD_TXDR registerTXISIE

When an interrupt from the UCPD is received, then the software has to check what is the source of the interrupt by reading the UCPD_SR register.

Depending on which bit is at 1, the ISR must handle that condition and clear the bit by a write to the appropriate bit of the UCPD_ICR register.

68.8 UCPD registers

68.8.1 UCPD configuration register 1 (UCPD_CFGR1)

Address offset: 0x000

Reset value: 0x0000 0000

General configuration of the peripheral. Writing to this register is only effective when UCPD is disabled (UCPDEN = 0).

31302928272625242322212019181716
UCPDENRXDMAENTXDMAENRXORDSETEN[8:0]PSC_UCPDCLK[2:0]Res.
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
TRANSWIN[4:0]IFRGAP[4:0]HBITCLKDIV[5:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
ST logo
ST logo

68.8.2 UCPD configuration register 2 (UCPD_CFGR2)

Address offset: 0x004

Reset value: 0x0000 0000

Configuration of the UCPD Rx signal filtering. Writing to this register is only effective when UCPD is disabled (UCPDEN = 0).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.RXAFIL
TEN
Res.Res.Res.Res.WUPE
N
FORCE
CLK
RXFILT
2N3
RXFILT
DIS
rwrwrwrwrw

Bits 31:9 Reserved, must be kept at reset value.

Bit 8 RXAFILTEN: Rx analog filter enable
Setting the bit enables the Rx analog filter required for optimum Power Delivery reception.
0: Disable
1: Enable

Bits 7:4 Reserved, must be kept at reset value.

Bit 3 WUPEN: Wake-up from Stop mode enable
Setting the bit enables the UCPD_ASYNC_INT signal.
0: Disable
1: Enable

Bit 2 FORCECLK: Force ClkReq clock request
0: Do not force clock request
1: Force clock request

Bit 1 RXFILT2N3: BMC decoder Rx pre-filter sampling method
Number of consistent consecutive samples before confirming a new value.
0: 3 samples
1: 2 samples

Bit 0 RXFILTDIS: BMC decoder Rx pre-filter enable
0: Enable
1: Disable
The sampling clock is that of the receiver (that is, after pre-scaler).

ST logo
ST logo

68.8.3 UCPD control register (UCPD_CR)

Address offset: 0x00C

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is enabled (UCPDEN = 1).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CC2TC
DIS
CC1TC
DIS
Res.RDCHFRSTXFRSRX
EN
rwrwrwrsrw
1514131211109876543210
Res.Res.Res.Res.CCENABLE[1:0]ANAM
ODE
ANASUBMODE[1:0]PHYCC
SEL
PHYRX
EN
RXMO
DE
TXHRS
T
TXSEN
D
TXMODE[1:0]
rwrwrwrwrwrwrwrwrsrsrwrw

Bits 31:22 Reserved, must be kept at reset value.

Bit 21 CC2TCDIS: CC2 Type-C detector disable

The bit disables the Type-C detector on the CC2 line.

0: Enable

1: Disable

When enabled, the Type-C detector for CC2 is configured through ANAMODE and ANASUBMODE[1:0].

Bit 20 CC1TCDIS: CC1 Type-C detector disable

The bit disables the Type-C detector on the CC1 line.

0: Enable

1: Disable

When enabled, the Type-C detector for CC1 is configured through ANAMODE and ANASUBMODE[1:0].

Bit 19 Reserved, must be kept at reset value.

Bit 18 RDCH: Rdch condition drive

The bit drives Rdch condition on the CC line selected through the PHYCCSEL bit (thus associated with VCONN), by remaining set during the source-only UnattachedWait.SRC state, to respect the Type-C state. Refer to "USB Type-C ECN for Source VCONN Discharge". The CCENABLE[1:0] bitfield must be set accordingly, too.

0: No effect

1: Rdch condition drive

Bit 17 FRSTX: FRS Tx signaling enable.

Setting the bit enables FRS Tx signaling.

0: No effect

1: Enable

The bit is cleared by hardware after a delay respecting the USB Power Delivery specification Revision 3.1.

Bit 16 FRSRXEN: FRS event detection enable

Setting the bit enables FRS Rx event (FRSEVT) detection on the CC line selected through the PHYCCSEL bit. 0: Disable

1: Enable

Clear the bit when the device is attached to an FRS-incapable source/sink.

Bit 15 Reserved, must be kept at reset value.

Bits 1:0 TXMODE[1:0]: Type of Tx packet

Writing the bitfield triggers the action as follows, depending on the value:

0x0: Transmission of Tx packet previously defined in other registers

0x1: Cable Reset sequence

0x2: BIST test sequence (BIST Carrier Mode 2)

Others: invalid

From V1.1 of the USB PD specification, there is a counter defined for the duration of the BIST Carrier Mode 2. To quit this mode correctly (after the "tBISTContMode" delay), disable the peripheral (UCPDEN = 0).

68.8.4 UCPD interrupt mask register (UCPD_IMR)

Address offset: 0x010

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is enabled (UCPDEN = 1).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FRSEVTIERes.Res.Res.Res.
r
1514131211109876543210
TYPECEVT2IETYPECEVT1IERes.RXMSGENDIERXOVRIERXHRSTDETIERXORDDETIERXNEIERes.TXUNDIEHRSTSENTIEHRSTDISCIETXMSGABTIETXMSGSENTIETXMSGDISCIETXISIE
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:21 Reserved, must be kept at reset value.

Bit 20 FRSEVTIE: FRSEVT interrupt enable

0: Disable

1: Enable

Bits 19:16 Reserved, must be kept at reset value.

Bit 15 TYPECEVT2IE: TYPECEVT2 interrupt enable

0: Disable

1: Enable

Bit 14 TYPECEVT1IE: TYPECEVT1 interrupt enable

Bit 13 Reserved, must be kept at reset value.

Bit 12 RXMSGENDIE: RXMSGEND interrupt enable

0: Disable

1: Enable

Bit 11 RXOVRIE: RXOVR interrupt enable

0: Disable

1: Enable

Bit 10 RXHRSTDETIE: RXHRSTDET interrupt enable

0: Disable

1: Enable

68.8.5 UCPD status register (UCPD_SR)

Address offset: 0x014

Reset value: 0x0000 0000

The flags (single-bit status bitfields) are associated with interrupt request. Interrupt is generated if enabled by the corresponding bit of the UCPD_IMR register.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FRSEVTTYPEC_VSTATE_CC2[1:0]TYPEC_VSTATE_CC1[1:0]
rrrrr
1514131211109876543210
TYPECEVT2TYPECEVT1RXERRRXMSGENDRXOV RRXHRS TDETRXOR DDETRXNERes.TXUNDHRSTSENTHRSTDISCTXMSGABTTXMSGSENTTXMSGDISCTXIS
rrrrrrrrrrrrrrr

Bits 31:21 Reserved, must be kept at reset value.

Bit 10 RXHRSTDET: Rx Hard Reset receipt detection

The flag indicates the receipt of valid Hard Reset message. It is cleared by setting the RXHRSTDETCF bit.

Bit 9 RXORDDET: Rx ordered set (4 K-codes) detection

The flag indicates the detection of an ordered set. The relevant information is stored in the RXORDSET[2:0] bitfield of the UCPD_RX_ORDSET register. It is cleared by setting the RXORDDETCF bit.

Bit 8 RXNE: Receive data register not empty detection

The flag indicates that the UCPD_RXDR register is not empty. It is automatically cleared upon reading UCPD_RXDR.

Bit 7 Reserved, must be kept at reset value.

Bit 6 TXUND: Tx data underrun detection

The flag indicates that the Tx data register (UCPD_TXDR) was not written in time for a transmit message to execute normally. It is cleared by setting the TXUNDCAF bit.

Bit 5 HRSTSENT: Hard Reset message sent

The flag indicates that the Hard Reset message is sent. The flag is cleared by setting the HRSTSENTCF bit.

Bit 4 HRSTDISC: Hard Reset discarded

The flag indicates that the Hard Reset message is discarded. The flag is cleared by setting the HRSTDISCCF bit.

Bit 3 TXMSGABT: Transmit message abort

The flag indicates that a Tx message is aborted due to a subsequent Hard Reset message send request taking priority during transmit. It is cleared by setting the TXMSGABTCF bit.

Bit 2 TXMSGSENT: Message transmission completed

The flag indicates the completion of packet transmission. It is cleared by setting the TXMSGSENTCF bit.

In the event of a message transmission interrupted by a Hard Reset, the flag is not raised.

Bit 1 TXMSGDISC: Message transmission discarded

The flag indicates that a message transmission was dropped. The flag is cleared by setting the TXMSGDISCCF bit.

0: No Tx message discarded

1: Tx message discarded

Transmission of a message can be dropped if there is a concurrent receive in progress or at excessive noise on the line. After a Tx message is discarded, the flag is only raised when the CC line becomes idle.

Bit 0 TXIS: Transmit interrupt status

The flag indicates that the UCPD_TXDR register is empty and new data write is required (as the amount of data sent has not reached the payload size defined in the TXPAYSZ bitfield).

The flag is cleared with the data write into the UCPD_TXDR register.

0: New Tx data write not required

1: New Tx data write required

68.8.6 UCPD interrupt clear register (UCPD_ICR)

Address offset: 0x018

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is enabled (UCPDEN = 1).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FRSEVT
TCF
Res.Res.Res.Res.
w
1514131211109876543210
TYPECEVT2CFTYPECEVT1CFRes.RXMSGENDCFRXOVRCFRXHRSTDETCFRXORDDETCFRes.Res.TXUNDCFHRSTSENTCFHRSTDISCCFTXMSGABTCFTXMSGSENTCFTXMSGDISCCFRes.
wwwwwwwwwwww

Bits 31:21 Reserved, must be kept at reset value.

Bit 20 FRSEVTCF: FRS event flag (FRSEVT) clear

Setting the bit clears the FRSEVT flag in the UCPD_SR register.

Bits 19:16 Reserved, must be kept at reset value.

Bit 15 TYPECEVT2CF: Type-C CC2 line event flag (TYPECEVT2) clear

Setting the bit clears the TYPECEVT2 flag in the UCPD_SR register

Bit 14 TYPECEVT1CF: Type-C CC1 event flag (TYPECEVT1) clear

Setting the bit clears the TYPECEVT1 flag in the UCPD_SR register

Bit 13 Reserved, must be kept at reset value.

Bit 12 RXMSGENDCF: Rx message received flag (RXMSGEND) clear

Setting the bit clears the RXMSGEND flag in the UCPD_SR register.

Bit 11 RXOVRCF: Rx overflow flag (RXOVR) clear

Setting the bit clears the RXOVR flag in the UCPD_SR register.

Bit 10 RXHRSTDETCF: Rx Hard Reset detect flag (RXHRSTDET) clear

Setting the bit clears the RXHRSTDET flag in the UCPD_SR register.

Bit 9 RXORDDETCF: Rx ordered set detect flag (RXORDDDET) clear
Setting the bit clears the RXORDDDET flag in the UCPD_SR register.

Bits 8:7 Reserved, must be kept at reset value.

Bit 6 TXUNDCF: Tx underflow flag (TXUND) clear
Setting the bit clears the TXUND flag in the UCPD_SR register.

Bit 5 HRSTSENTCF: Hard reset send flag (HRSTSENT) clear
Setting the bit clears the HRSTSENT flag in the UCPD_SR register.

Bit 4 HRSTDISCCF: Hard reset discard flag (HRSTDISC) clear
Setting the bit clears the HRSTDISC flag in the UCPD_SR register.

Bit 3 TXMSGABTCF: Tx message abort flag (TXMSGABT) clear
Setting the bit clears the TXMSGABT flag in the UCPD_SR register.

Bit 2 TXMSGSENTCF: Tx message send flag (TXMSGSENT) clear
Setting the bit clears the TXMSGSENT flag in the UCPD_SR register.

Bit 1 TXMSGDISCCF: Tx message discard flag (TXMSGDISC) clear
Setting the bit clears the TXMSGDISC flag in the UCPD_SR register.

Bit 0 Reserved, must be kept at reset value.

68.8.7 UCPD Tx ordered set type register (UCPD_TX_ORDSETR)

Address offset: 0x01C

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is enabled (UCPDEN = 1) and no packet transmission is in progress (TXSEND and TXHRST bits are both low).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TXORDSET[19:16]
rwrwrwrw
1514131211109876543210
TXORDSET[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 TXORDSET[19:0]: Ordered set to transmit

The bitfield determines a full 20-bit sequence to transmit, consisting of four K-codes, each of five bits, defining the packet to transmit. The bit 0 (bit 0 of K-code1) is the first, the bit 19 (bit 4 of K-code4) the last.

68.8.8 UCPD Tx payload size register (UCPD_TX_PAYSZR)

Address offset: 0x020

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is enabled (UCPDEN = 1).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.TXPAYSZ[9:0]
rwrwrwrwrwrwrwrwrwrw

Bits 31:10 Reserved, must be kept at reset value.

Bits 9:0 TXPAYSZ[9:0]: Payload size yet to transmit

The bitfield is modified by software and by hardware. It contains the number of bytes of a payload (including header but excluding CRC) yet to transmit: each time a data byte is written into the UCPD_TXDR register, the bitfield value decrements and the TXIS bit is set, except when the bitfield value reaches zero. The enumerated values are standard payload sizes before the start of transmission.

0x2: 2 bytes - the size of Control message from the protocol layer

0x6: 6 bytes - the shortest Data message allowed from the protocol layer

0x1E: 30 bytes - the longest non-extended Data message allowed from the protocol layer

0x106: 262 bytes - the longest possible extended message

0x3FF: 1024 bytes - the longest possible payload (for future expansion)

68.8.9 UCPD Tx data register (UCPD_TXDR)

Address offset: 0x024

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is enabled (UCPDEN = 1).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.TXDATA[7:0]
rwrwrwrwrwrwrwrw

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:0 TXDATA[7:0]: Data byte to transmit

68.8.10 UCPD Rx ordered set register (UCPD_RX_ORDSETR)

Address offset: 0x028

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.RXSOPKINVALID[2:0]RXSOP3OF4RXORDSET[2:0]
rrrrrrr

Bits 31:7 Reserved, must be kept at reset value.

Bits 6:4 RXSOPKINVALID[2:0]:

The bitfield is for debug purposes only.

0x0: No K-code corrupted

0x1: First K-code corrupted

0x2: Second K-code corrupted

0x3: Third K-code corrupted

0x4: Fourth K-code corrupted

Others: Invalid

Bit 3 RXSOP3OF4:

The bit indicates the number of correct K-codes. For debug purposes only.

0: 4 correct K-codes out of 4

1: 3 correct K-codes out of 4

Bits 2:0 RXORDSET[2:0]: Rx ordered set code detected

0x0: SOP code detected in receiver

0x1: SOP' code detected in receiver

0x2: SOP" code detected in receiver

0x3: SOP'_Debug detected in receiver

0x4: SOP"_Debug detected in receiver

0x5: Cable Reset detected in receiver

0x6: SOP extension#1 detected in receiver

0x7: SOP extension#2 detected in receiver

68.8.11 UCPD Rx payload size register (UCPD_RX_PAYSZR)

Address offset: 0x02C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.RXPAYSZ[9:0]
rrrrrrrrrr

Bits 31:10 Reserved, must be kept at reset value.

Bits 9:0 RXPAYSZ[9:0]: Rx payload size received

This bitfield contains the number of bytes of a payload (including header but excluding CRC) received: each time a new data byte is received in the UCPD_RXDR register, the bitfield value increments and the RXMSGEND flag is set (and an interrupt generated if enabled).

0x2: 2 bytes - the size of Control message from the protocol layer

0x6: 6 bytes - the shortest Data message allowed from the protocol layer)

0x1E: 30 bytes - the longest non-extended Data message allowed from the protocol layer

0x106: 262 bytes - the longest possible extended message

0x3FF: 1024 bytes - the longest possible payload (for future expansion)

The bitfield may return a spurious value when a byte reception is ongoing (the RXMSGEND flag is low).

68.8.12 UCPD receive data register (UCPD_RXDR)

Address offset: 0x030

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.RXDATA[7:0]
rrrrrrrr

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:0 RXDATA[7:0]: Data byte received

68.8.13 UCPD Rx ordered set extension register 1 (UCPD_RX_ORDEXTR1)

Address offset: 0x034

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is disabled (UCPDEN = 0).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RXSOPX1[19:16]
rwrwrwrw
1514131211109876543210
RXSOPX1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 RXSOPX1[19:0]: Ordered set 1 received

The bitfield contains a full 20-bit sequence received, consisting of four K-codes, each of five bits. The bit 0 (bit 0 of K-code1) is receive first, the bit 19 (bit 4 of K-code4) last.

68.8.14 UCPD Rx ordered set extension register 2 (UCPD_RX_ORDEXTR2)

Address offset: 0x038

Reset value: 0x0000 0000

Writing to this register is only effective when the peripheral is disabled (UCPDEN = 0).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RXSOPX2[19:16]
rwrwrwrw
1514131211109876543210
RXSOPX2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 RXSOPX2[19:0]: Ordered set 2 received

The bitfield contains a full 20-bit sequence received, consisting of four K-codes, each of five bits. The bit 0 (bit 0 of K-code1) is receive first, the bit 19 (bit 4 of K-code4) last.

68.8.15 UCPD register map

Table 764. UCPD register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000UCPD_CFGR1UCPDENRXDMAENTXDMAENRXORDSETEN[8:0]PSC_UCPDCLK[2:0]Res.TRANSWIN[4:0]IFRGAP[4:0]HBITCLKDIV[5:0]
Reset value000000000000000000000000000000
0x004UCPD_CFGR2Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RXAFILTENRes.Res.Res.Res.WUPENFORCECLKRXFILT2N3RXFILTDIS
Reset value00000
0x008Reserved
0x00CUCPD_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.CC2TCDISCC1TCDISRes.RDCHFRSTXFRSRXENRes.Res.Res.Res.Res.CCENABLE[1:0]ANAMODEANASUBMODE[1:0]PHYCCSELPHYRXENRXMODETXHRSTTXSENDTXMODE[1:0]
Reset value0000000000000000

Table 764. UCPD register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x010UCPD_IMRResResResResResResResResResResResFRSEVTIEResResResResTYPECEVT2IETYPECEVT1IEResRXMSGENDIERXOVRIERXHRSTDETIERXORDDETIERXNEIEResTXUNDIEHRSTSENTIEHRSTDISCIETXMSGABTIETXMSGSENTIETXMSGDISCIETXISIE
Reset value00000000000000
0x014UCPD_SRResResResResResResResResResResResFRSEVTTYPEC_VSTATE_CC2[1:0]TYPEC_VSTATE_CC1[1:0]TYPECEVT2TYPECEVT1RXERRRXMSGENDRXOVRRXHRSTDETRXORDDETRXNEResTXUNDHRSTSENTHRSTDISCTXMSGABTTXMSGSENTTXMSGDISCTXIS
Reset value0000000000000000000
0x018UCPD_ICRResResResResResResResResResResResFRSEVTCFResResResResTYPECEVT2CFTYPECEVT1CFResRXMSGENDCFRXOVRCFRXHRSTDETCFRXORDDETCFResResTXUNDCFHRSTSENTCFHRSTDISCCFTXMSGABTCFTXMSGSENTCFTXMSGDISCCFRes
Reset value0000000000000
0x01CUCPD_TX_ORDSETRResResResResResResResResResResResResTXORDSET[19:0]
Reset value00000000000000000000
0x020UCPD_TX_PAYSZRResResResResResResResResResResResResResResResResResResResResResResResTXPAYSZ[9:0]
Reset value000000000
0x024UCPD_TXDRResResResResResResResResResResResResResResResResResResResResResResResTXDATA[7:0]
Reset value00000000
0x028UCPD_RX_ORDSETRResResResResResResResResResResResResResResResResResResResResResResResResRXSOPKINVALID[2:0]RXSOP3OF4RXORDSET[2:0]
Reset value00000000
0x02CUCPD_RX_PAYSZRResResResResResResResResResResResResResResResResResResResResResResResRXPAYSZ[9:0]
Reset value000000000
0x030UCPD_RXDRResResResResResResResResResResResResResResResResResResResResResResResRXDATA[7:0]
Reset value00000000
0x034UCPD_RX_ORDEXTR1ResResResResResResResResResResResResRXSOPX1[19:0]
Reset value00000000000000000000

Table 764. UCPD register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x038UCPD_RX
_ORDEXTR2
ResResResResResResResResResResResResRXSOPX2[19:0]
Reset value00000000000000000000
0x03C -
0x3FF
Reserved

Refer to Section 2.3: Memory organization for the register boundary addresses.

ST logo
ST logo