0. Errata
Today, we found that the Q1 and Q2 MOS tubes were connected incorrectly (as shown above). The correct connection method is shown below. This connection error does not affect normal use. This MOS is only used for discharge when unplugged. It has been corrected. Thanks to @雷老师讲电子错误
1. Introduction
CS5268 is a USB TYPE-C to HDMI1.4b 4K-30Hz controller with PD3.0, USB3.1, and VGA.
Compatible with Nintendo SWITCH, most Win notebooks, and mobile phones that support video output (most Huawei flagship phones).
It is the upper position of CS5266. I have done the CS5266 project. Jump link: https://oshwhub.com/aknice/type-c-zhuan-huan-qi
This project changes CS5266 to CS5268, and adds a MUX chip on this basis.
The MUX chip is an indispensable part of the TYPE-C DP device. Only with this chip can the forward and reverse insertion of the expansion dock mother seat be realized.
Corresponding: There are four situations in total:
the dock is plugged in forward + reverse,
the main device is plugged in forward + reverse . If the MUX chip is not added and the TPYE-C female socket is used, the device end can be plugged in forward and reverse, but the dock end can only output images when plugged in forward! But both sides can be charged with PD fast. 2. TYPE-C DP knowledge supplement The previous CS5266 article has already explained in detail why a MUX chip is needed. Jump link: https://oshwhub.com/aknice/type-c-zhuan-huan-qi Simply put, it is to use a small tail or a direct male plug to directly connect to the PD controller, which can save a MUX chip. If a female plug is needed, a MUX chip must be added. 3. MUX chip-VL17X series Taking VL170 as an example, VL170 is a MUX chip used between 4-channel DisplayPort source input and 2-channel USB 3.1 host input to the USB-C connector. The MUX switch signal performance supports up to USB 3.1. When we need to transmit video, we also need to transmit USB3 signals, so EN is H and AMSEL is L. The main difference between VL170 and VL171 is that VL170 transmits DP1.3, VL171 transmits DP1.4, and the two chips are PIN to PIN. Here is a video interface specification table. Interface transmission signal Supported resolution/refresh rate VGA analog 2560x1600 DVI-D digital 2560x1600@60Hz HDMI 1.4b digital 2560x1600@60Hz HDMI 2.0b digital 3840x2160@60Hz HDMI 2.1 digital 7680x4320@60Hz DisplayPort 1.1 digital 2560x1600 @60Hz DisplayPort 1.2 digital 4096x2160@60Hz DisplayPort 1.3 digital 5120x2880@60Hz DisplayPort 1.4 Digital 7680x4320@60Hz 4.MUX control logic Among the CS526X chips, some of the agent chips have GPIO5 pins that can be used for POL control of VL17X , but the CS526X chips bought on Taobao do not have them. At present, I personally think that the best way is to add MCU to control it. Of course, you can add transistor circuits for matching, but it is more complicated to adjust the parameters. 4.1 How to determine whether TYPE-C is plugged in forward or reverse Then we can have two methods to determine whether TYPE-C is currently plugged in forward or reverse 4.1.1 CC judgment About CC pin PD and DP communication (note the difference between PD and DP) USB PD is transmitted on the CC (Configuration Channel) pin. PD has a VDM (Vendor defined message) function that defines the device end ID. When a device that supports DP or PCIe is read, DFP enters alternate mode. If DFP recognizes the device as DP, it switches the MUX/Configuration Switch to change the Type-C USB3.1 signal pin to transmit DP signals. AUX auxiliary is transmitted by Type-C's SBU1 and SUB2. Zoom in on one of the waveforms: 1. The charger CC first provides charging specification selection to the PD device. The PD controller selects the power specification VDM and enters the alternate mode DFP to determine the DP. This process is consistent with the DP communication process mentioned above. Then through the above analysis, you will find that CC1 is pulled low when plugged in, and only CC2 determines the PD and DP specifications, and the reverse is the case. Then we just need to determine whether CC1 is low level when plugged in. Yes, this is a good method, but when we detect CC2, if we detect it during CC communication, it may be misdetected, resulting in abnormal CC communication, and the PD charging specification will be dynamically adjusted according to the device requirements when the device is trickle charged. Therefore, in order to avoid affecting device communication, we try not to use the method of detecting CC communication. 4.1.2 SBU signal judgment SBU1, SBU2: Sideband use (Side Band Use) signals are suitable for transmitting non-USB signals. They can be used in analog audio mode or in alternate mode. I have found many articles on the Internet, but they don't specifically say what they are used for. It seems to be mostly used for analog audio transmission. However, when plugging in forward and reverse directions, the SBU will always have one signal high and one signal low, so the SBU signal can be used to determine whether the plug is forward or reverse. ----------------------------Dividing line---------------------------- 2023.07.09
Today, I found that when using the SBU signal to judge the forward and reverse insertion, there is an SBU signal for the full-function TYPE-C
port, but there is only a USB3 transmission function. When plugged in, there is no SBU signal .
Because there is no SBU signal, the external MCU has no effect on the POL port of the VL171 chip.
Therefore, for the TYPE-C port with only USB3 transmission function, which can only run at the speed of USB2,
it is recommended to use the CC signal to judge the forward and reverse insertion and control POL
---------------------------- Divider line ----------------------------
4.2 Methods for controlling the forward and reverse insertion of TYPE-C
After knowing how to judge, we still need a control method.
We can use the hardware circuit method to control, connect the SBU input to the triode, make a logic circuit, and SBU1 high POL high.
This method is good, but it is not recommended. Since SBU is sometimes useful, in order not to affect the SBU transmission signal, adding an MCU and using ADC detection is a better method.
I used a CH552T as the main control MCU.
This MCU is also a small MCU that I mainly use at present.
The periphery is very simple, only a reset circuit, download button, and crystal oscillator are needed, which is less than the traditional single-chip microcomputer. It is
super cheap at 1.5 yuan per piece.
It supports multiple development environments: KEIL, Arduino, etc.
4-channel 8-bit ADC
2 groups of PWM
2 groups of UART
Built-in USB controller
Built-in 5V to 3.3V LDO, external power supply can also go to 2.8V
This MCU is mostly used in keyboards. It is a cheap and high-performance MCU, but it is a pity that there is no hardware IIC.
This is the schematic diagram of the CH552T part of the docking station.
I connected SBU1 and SBU2 to P1.4 and P1.5 respectively.
The specification book corresponds to AIN1 and AIN2
for use as ADC. The high and low input of SBU determines whether it is inserted forward or reverse.
The entire control logic is actually very simple
4.3 The CH552
code is actually very simple, and it is written by Arduino.
It connects SBU1 and SBU2 to P1.4 and P1.5 of CH552, and detects their levels as ADC.
Then judge the AD value SBU1<10 and SBU2>70, which means reverse insertion, POL is pulled high, and vice versa, the POL pin is pulled low. Other default settings pull POL low.
4.4 Control circuits also need to pay attention to
the fact that the POL pin needs to be pulled low by default .
The pull-down resistor uses 100K.
Here, the CH552 needs a level conversion circuit to control the POL pin
. Since we use 5V to power CH552, the IO output is 5V, and the VL17X chip POL pin does not say the maximum level value,
but for the stability of the VL17X chip, it is not recommended to input an input that exceeds its own voltage. Therefore, it is recommended to input a logic high level of 3.3V~2.7V here.
Of course, I have tested that it can run normally by directly giving 5V.
There is a POL indicator light
that goes out when it is plugged in forward and lights up when it is plugged in reverse. 5. An upgrade and a reset button are reserved on the
CH552 firmware burning board. To upgrade, you only need to use the upgrade button to download the attached firmware CH552T for CS5268.7z and decompress it to get two files, one is the .ino source code, and the other is a hex file. The firmware uploaded is a hex file, and there is no need to set up the environment and then compile it. Unzip the attached Tools.7z and run WCHISPTool_Setup.exe as an administrator to install the CH burning tool. Open the tool , click the CH55X series, select CH552, select the hex firmware, then plug the A end of the TYPE-C data cable into the computer, press and hold the upgrade button, and then insert the TYPE-C data cable into the PD charging port. Note that you must press it first, then plug the cable in, don't get it wrong, don't plug it into the TYPE-C port of the device on the left, and plug it into the PD charging port shown in the figure below. At this time, the tool can recognize CH552, and you can let go after recognizing it, without keeping pressing it. Then you can click download and burn it. There will be a success prompt when the download is completed. Then you can unplug the data cable. 6. The LAYOUT part uses a 1.0 board thickness, a four-layer board, and an impedance structure of JLC04101H-7628. You can get HDMI for free . The DP part uses 100 ohm impedance to match TYPE-C's B2, B3, A10, and A11. HDMI's D0, D1, D2, and CLK signals need to go through the USB part. The impedance matches TYPE-C's A2, A3, A6, A7, B10, and B11 signals need to go through 7. Chip purchase . Just search for CS5268 or CS5266 chips on Ma Yun.com. I saw that there is also a PDD selling it. I don't know how it works. You can try it . 8. Actual test 1. Nintendo SWITCH positive and negative plug + expansion dock positive and negative plug 2. Laptop HDMI + USB3 + PD fast charging