A method and MCU for implementing a PD protocol PHY layer by software
Implementing the PD protocol PHY layer in software solves the problem of high hardware implementation costs, reduces chip area and cost, improves flexibility, and simplifies the design process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUXI ZHONGXIANG TECH CO LTD
- Filing Date
- 2023-06-28
- Publication Date
- 2026-07-10
AI Technical Summary
The existing PD protocol implements the PHY layer in hardware, which is costly and lacks flexibility.
The method of implementing the PD protocol PHY layer through software includes steps such as detecting CC line status, preamble data, SOP characters, and CRC verification, and uses an 8-bit MCU for data processing.
It reduces the area and cost of PD protocol chips, improves flexibility, and reduces the difficulty of hardware design and simulation.
Smart Images

Figure CN116828072B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and more specifically to a method for implementing the PD protocol PHY layer through software and an MCU. Background Technology
[0002] The PD (Power Delivery) protocol is a charging protocol developed by the USB Association to unify connectors through the Type-C interface. In essence, it is a process of handshaking and exchanging information between the charger (source end) and the device being charged (sink end). The Type-C interface has a dedicated CC line for transmitting data packets. The PHY layer (physical layer) is responsible for transmitting and receiving packets. The data packet transmission frequency is 300kHz (the protocol specifies that it can operate between 270kHz and 330kHz).
[0003] The format of the PD protocol message is as follows: Figure 1 As shown, where:
[0004] Preamble consists of 64 alternating 0s and 1s and cannot be encoded using 4B / 5B;
[0005] The SOP (Start of Packet Sequence) consists of 4 K characters, totaling 20 bits. These 20 bits can tolerate single-bit errors, and the receiving side needs to have an error correction mechanism.
[0006] The message header and bytex are the payloads, which are transmitted by the protocol layer. This part needs to be converted from 4B to 5B.
[0007] CRC is a CRC32 checksum added by the physical layer, which is 32 bits in total and also requires 4B / 5B conversion;
[0008] EOP is a 0xD character, which is only 5 bits long.
[0009] Since data packets are transmitted in half-duplex mode on the CC line, the physical layer also needs a collision avoidance mechanism to reduce the occurrence of interaction errors. This necessitates the following functions on the data packet sending side: 1. Receive the packet to be sent from the protocol layer; 2. Calculate and append CRC32; 3. Pack the data (add preamble, header, CRC, and end-of-line code); 4. Perform 4B to 5B (NMC) conversion on the data and send the packet. Simultaneously, the data packet receiving side needs to have the following functions: 1. Restore the clock and lock the preamble; 2. Detect SOP*; 3. Perform 5B to 4B conversion on the packet; 4. Detect the end-of-line code (EOP) and determine if the packet is erroneous based on the CRC32 carried in the packet.
[0010] For existing PD protocol chips, implementations are based on actual requirements using 32-bit MCUs, 8-bit MCUs, or pure hardware. 32-bit MCUs are the most expensive, while pure hardware implementations are low-cost but less flexible. 8-bit MCUs offer a balance between flexibility and cost. However, in the implementation of the PD protocol PHY layer, because the PD protocol requires error correction and CRC32 algorithms, it is generally implemented in hardware, which increases costs. Summary of the Invention
[0011] In view of the shortcomings of the prior art, the present invention provides a method and MCU for implementing the PHY layer of the PD protocol through software. The technical problem to be solved is that the existing PD protocol is implemented in hardware, which is costly.
[0012] To solve the above technical problems, the present invention provides the following technical solution: a method for implementing the PHY layer of the PD protocol through software, comprising the following steps:
[0013] S1: Check if the CC line of the Type-C interface is pulled low. If the CC line is pulled low, proceed to step S2.
[0014] S2: Detect whether preamble data has been received. If preamble data has been received, determine whether the received preamble data meets the preamble judgment requirements. If it does, proceed to step S3.
[0015] S3: Search for the first K character of SOP. After finding the first K character, search for the second K character of SOP. After finding the second K character, receive 15 bits of data first, and then execute step S4. If the first K character or the second K character cannot be found, determine whether there is a BMC signal. If there is a BMC signal, execute step S3 again. If there is no BMC signal, end step S3.
[0016] S4: Determine if there is a BMC signal. If there is, proceed to step S5; otherwise, end step S4.
[0017] S5: Determine whether the received 5-bit data is equal to 0xd. If it is, proceed to step S7; otherwise, proceed to step S6.
[0018] S6: Includes the following steps:
[0019] S60: Perform 5B / 4B conversion on the received 5-bit data and receive 1-bit data;
[0020] S61: Update the 32-bit check data based on the 1-bit data received in step S60, and receive 1-bit data;
[0021] S62: Update the 32-bit check data based on the 1-bit data received in step S61, and receive 1-bit data;
[0022] S63: Update the 32-bit check data based on the 1-bit data received in step S62, and receive 1-bit data;
[0023] S64: Update the 32-bit check data based on the 1-bit data received in step S63, and accept 1-bit data;
[0024] S65: Return to step S4;
[0025] S7: Verify the 32-bit check data.
[0026] In one implementation, in step S2, it is determined whether preamble data has been received by checking whether there is a BMC signal. If there is a BMC signal, it is considered that the preamble data has been received, and the preamble data is converted into data 0 or data 1.
[0027] In one implementation, the preamble determination requirement refers to determining whether the converted preamble data is equal to 0x55 or 0xAA.
[0028] In one implementation, the method for searching for the first K character and the second K character of SOP in step S3 is as follows:
[0029] S30: Determine whether the most recently received 5 bits of data is equal to 0x18. If it is, then the first K character has been found, and then proceed to step S31. Otherwise, proceed to step S32.
[0030] S31: Determine whether the subsequently received 5 bits of data are equal to 0x18, 0x08, 0x10, 0x1c, 0x1a or 0x19. If they are equal, the second K character has been found. If they are not equal, proceed to step S34.
[0031] S32: Determine whether the most recently received 5 bits of data are equal to 0x08, 0x10, 0x1c, 0x1a or 0x19. If they are equal, it is considered that the first K character has been found, and then step S33 is executed; otherwise, step S34 is executed.
[0032] S33: Determine whether the subsequently received 5 bits of data are equal to 0x18. If they are equal, it is considered that the second K character has been found. If they are not equal, proceed to step S34.
[0033] S34: Determine whether the most recently received 5 bits of data is equal to 0x0d. If it is equal, end step S34. If it is not equal, proceed to step S35. If it is equal, end step S34.
[0034] S35: Determine if there is a BMC signal. If there is a BMC signal, proceed to step S30; otherwise, end step S35.
[0035] In one implementation, step S7 involves checking whether the 32-bit check data is equal to 0x04C11DB7. If they are equal, the received message is considered correct; otherwise, the received message is considered incorrect.
[0036] In addition, the present invention also provides an MCU, which includes software for implementing a method for the PHY layer of the PD protocol. The MCU may be an 8-bit MCU.
[0037] The advantages of this invention compared to existing technologies are as follows: First, this invention implements the PHY layer of the PD protocol in software, reducing the hardware required for implementing the PHY layer in the PD protocol chip, thereby reducing the area and cost of the PD protocol chip; second, due to the software implementation, the overall flexibility is high, reducing the limitations of the PHY layer on the PD protocol chip, thus allowing for customized message extraction according to actual needs; finally, implementing the PHY layer in software reduces the difficulty of chip hardware and simulation, and the design of the PHY layer does not need to be considered before chip tape-out. Attached Figure Description
[0038] Figure 1 This is a schematic diagram of the structure of an existing PD protocol message;
[0039] Figure 2 This is a schematic diagram of the BMC conversion structure;
[0040] Figure 3 The flowchart below illustrates the present invention in the embodiments;
[0041] Figure 4 This is a flowchart of step S3 of the present invention. Detailed Implementation
[0042] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0043] For existing PD protocol chips, the PHY layer is mostly implemented in hardware. Hardware implementation requires significant chip area and limits the chip's usability, failing to flexibly meet various application requirements. Furthermore, data packets are transmitted on the CC line of the Type-C interface, and BMC conversion is required during transmission. This facilitates clock recovery at the receiving end. The BMC conversion format is as follows: Figure 2 As shown.
[0044] To address the shortcomings of implementing the PHY layer in hardware, such as Figure 3 As shown, this invention provides a method for implementing the PD protocol PHY layer through software, comprising the following steps:
[0045] S1: Check if the CC line of the Type-C interface is pulled low. If the CC line is pulled low, proceed to step S2.
[0046] S2: Detect whether preamble data has been received. If preamble data has been received, determine whether the received preamble data meets the preamble judgment requirements. If it does, proceed to step S3.
[0047] from Figure 1 As can be seen from this, the preamble data consists of 64 alternating 0s and 1s. The preamble data is transmitted from the CC line after being converted by the BMC. Therefore, in step S2, it can be determined whether the preamble data has been received by checking whether there is a BMC signal. After receiving the preamble data, the preamble data is converted to the corresponding 0 or 1, and the converted data is used as the preamble conversion data.
[0048] Since data on the CC line is transmitted bit by bit, the correctness of the transmitted preamble data can be determined based on the received preamble conversion data. Specifically, the preamble conversion data has two distribution patterns: 0101010101… and 10101010…. Therefore, judging the received preamble conversion data can determine whether the correct preamble data has been received. For example, selecting the most recently received eight bits of data, if the hexadecimal data corresponding to these eight bits is 0x55 or 0XAA, then the received preamble data is considered correct. Furthermore, if the most recently received preamble data is less than eight bits, preamble data can continue to be received. Additionally, if no BMC signal is detected while continuing to receive preamble data, step S2 ends.
[0049] In one implementation, the most recently received 16-bit preamble data can be selected for judgment, and it is not necessarily limited to 8-bit data.
[0050] S3: Search for the first K character of SOP. After finding the first K character, search for the second K character of SOP. After finding the second K character, receive 15 bits of data first, and then execute step S4. If the first K character or the second K character cannot be found, determine whether there is a BMC signal. If there is a BMC signal, execute step S3 again. If there is no BMC signal, end step S3.
[0051] exist Figure 1In the structure of the PD protocol message shown, after the current preamble data is sent, SOP data will be sent. In addition, for the DFP mode charger, only the start sequence of the message needs to be processed. The SOP data is shown in Table 1.
[0052] Table 1
[0053]
[0054] Based on this, such as Figure 4 As shown, the method for searching for the first K character and the second K character of SOP in step S3 is as follows:
[0055] S30: Determine whether the most recently received 5 bits of data is equal to 0x18. If it is, then the first K character has been found, and then proceed to step S31. Otherwise, proceed to step S32.
[0056] S31: Determine whether the subsequently received 5 bits of data are equal to 0x18, 0x08, 0x10, 0x1c, 0x1a or 0x19. If they are equal, the second K character has been found. If they are not equal, proceed to step S34.
[0057] S32: Determine whether the most recently received 5 bits of data are equal to 0x08, 0x10, 0x1c, 0x1a or 0x19. If they are equal, it is considered that the first K character has been found, and then step S33 is executed; otherwise, step S34 is executed.
[0058] S33: Determine whether the subsequently received 5 bits of data are equal to 0x18. If they are equal, it is considered that the second K character has been found. If they are not equal, proceed to step S34.
[0059] S34: Determine whether the most recently received 5 bits of data is equal to 0x0d. If it is equal, end step S34. If it is not equal, proceed to step S35. If it is equal, end step S34.
[0060] S35: Determine if there is a BMC signal. If there is a BMC signal, proceed to step S30; otherwise, end step S35.
[0061] S4: Determine if there is a BMC signal. If there is, proceed to step S5; otherwise, end step S4.
[0062] S5: Determine whether the received 5-bit data is equal to 0xd. If it is, proceed to step S7; otherwise, proceed to step S6. Here, 0xd belongs to the end content of the PD protocol message. Therefore, by determining whether the most recently received 5-bit data is equal to 0xd, it can be determined whether the message has been received.
[0063] S6: Includes the following steps:
[0064] S60: Perform 5B / 4B conversion on the received 5-bit data and receive 1-bit data;
[0065] S61: Update the 32-bit check data based on the 1-bit data received in step S60, and receive 1-bit data;
[0066] S62: Update the 32-bit check data based on the 1-bit data received in step S61, and receive 1-bit data;
[0067] S63: Update the 32-bit check data based on the 1-bit data received in step S62, and receive 1-bit data;
[0068] S64: Update the 32-bit check data based on the 1-bit data received in step S63, and accept 1-bit data;
[0069] S65: Return to step S4.
[0070] In practical use, for step S6 of the present invention, by simultaneously receiving new 1-bit data while updating the 32-bit check data of the previously received 1-bit data, the overall calculation speed and processing efficiency can be improved.
[0071] S7: Verify the 32-bit check data.
[0072] Specifically, in this embodiment, in step S7, it is determined whether the 32-bit check data is equal to 0x04C11DB7. If they are equal, the received message is considered correct; otherwise, the received message is considered incorrect.
[0073] In summary, the method of this invention first implements the PHY layer of the PD protocol in software, reducing the hardware required for implementing the PHY layer in the PD protocol chip, thereby reducing the chip's area and cost. Furthermore, because it is implemented in software, it offers high overall flexibility, reducing the limitations imposed by the PHY layer on the PD protocol chip, allowing for customized message extraction based on actual needs. Finally, implementing the PHY layer in software reduces the complexity of chip hardware and simulation, and eliminates the need to consider PHY layer design before chip fabrication.
[0074] In addition, the present invention also provides an MCU, which includes software for implementing a method for the PHY layer of the PD protocol. The MCU may be an 8-bit MCU.
[0075] Based on the above description, those skilled in the art can make various changes and modifications without departing from the technical concept of this invention. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A method for implementing the PD protocol PHY layer via software, characterized in that, Includes the following steps: S1: Check if the CC line of the Type-C interface is pulled low. If the CC line is pulled low, proceed to step S2. S2: Detect whether preamble data has been received. If preamble data has been received, determine whether the received preamble data meets the preamble judgment requirements. If it does, proceed to step S3. S3: Search for the first K character of SOP. After finding the first K character, search for the second K character of SOP. After finding the second K character, receive 5 bits of data first, and then execute step S4. If the first K character or the second K character cannot be found, determine whether there is a BMC signal. If there is a BMC signal, execute step S3 again. If there is no BMC signal, end step S3. The method for searching for the first and second K characters of SOP in step S3 is as follows: S30: Determine whether the most recently received 5 bits of data is equal to 0x18. If it is, then the first K character has been found, and then proceed to step S31. Otherwise, proceed to step S32. S31: Determine whether the subsequently received 5 bits of data are equal to 0x18, 0x08, 0x10, 0x1c, 0x1a or 0x19. If they are equal, the second K character has been found. If they are not equal, proceed to step S34. S32: Determine if the most recently received 5 bits of data are equal to 0x08, 0x10, 0x1c, 0x1a, or 0x19. If they are equal, it is considered that the first K character has been found, and then step S33 is executed; otherwise, step S34 is executed. S33: Determine whether the subsequently received 5 bits of data are equal to 0x18. If they are equal, it is considered that the second K character has been found. If they are not equal, proceed to step S34. S34: Determine whether the most recently received 5 bits of data are equal to 0x0d. If they are equal, end step S34; otherwise, proceed to step S35. S35: Determine if there is a BMC signal. If there is a BMC signal, proceed to step S30; otherwise, end step S35. S4: Determine if there is a BMC signal. If there is, proceed to step S5; otherwise, end step S4. S5: Determine whether the received 5-bit data is equal to 0xd. If it is, proceed to step S7; otherwise, proceed to step S6. S6: Includes the following steps: S60: Perform 5B / 4B conversion on the received 5-bit data and receive 1-bit data; S61: Update the verification data based on the 1-bit data received in step S60, and receive 1-bit data; S62: Update the verification data based on the 1-bit data received in step S61, and receive 1-bit data; S63: Update the verification data based on the 1-bit data received in step S62, and receive 1-bit data; S64: Update the verification data based on the 1-bit data received in step S63, and receive 1-bit data; S65: Return to S4; S7: Verify the 32-bit check data.
2. The method for implementing the PD protocol PHY layer via software according to claim 1, characterized in that, In step S2, it is determined whether the preamble data has been received by checking whether there is a BMC signal. If there is a BMC signal, it is considered that the preamble data has been received, and the preamble data is converted into data 0 or data 1.
3. The method for implementing the PD protocol PHY layer via software according to claim 2, characterized in that, The preamble judgment requirement refers to determining whether the converted preamble data is equal to 0x55 or 0xAA.
4. The method for implementing the PD protocol PHY layer via software according to claim 1, characterized in that... In step S7, the verification is performed by judging whether the 32-bit check data is equal to 0x04C11DB7. If they are equal, the received message is considered to be correct; otherwise, the received message is considered to be incorrect.
5. An MCU, characterized in that, Includes software that implements the method for implementing the PD protocol PHY layer as described in any one of claims 1-4.
6. The MCU according to claim 5, characterized in that, The MCU is an 8-bit MCU.