CH568DS1-EN
CH568DS1-EN
CH568 Datasheet
Overview
CH568 is a high-performance 32-bit RISC reduced instruction set microcontroller, built-in 192KB FLASH
flash memory, 32KB SRAM and 32KB DataFlash. On-chip integrated high-speed USB2.0 master/slave
controller, 4 groups of SD controllers, SATA controllers, encryption algorithm modules, 4 groups of UARTs,
7 groups of PWMs, 3 groups of timers and other rich peripheral resources, which can be widely used for
various embedded applications.
Features
l Core: PWMX:
- 32-bit RISC reduced instruction set core - Expand 4 sets of PWM output
- 120MHz maximum frequency - Adjustable duty cycle
l Memory: l Universal asynchronous
-192KB bytes program memory, support write receiver/transmitter (UART):
protection - 4 groups of independent UARTs, compatible
- 32KB bytes SRAM with 16C550
- 32KB bytes DataFlash - The highest baud rate is 6Mbps
l USB2.0 high-speed receiver-transmitter - Built-in FIFO, multiple trigger levels
(built-in PHY): l SPI:
- High-speed Host / Device mode - 2 sets of SPIs: One supports Master and
- Support control/bulk/interrupt/synchronous Slave mode, the other supports only Master
transmission mode
- Support double buffering PINT-PONG - Built-in FIFO
- Support DMA - SPI0 supports DMA
l 4 groups of independent SD controllers: l LED screen interface:
- Support single-wire, 4-wire, 8-wire - Support 1/2/4 channel data line
communication mode - Built-in FIFO, support double buffering
- Support SD/TF card, SDIO card and eMMC - Support DMA
card, etc. l Low power:
- Built-in FIFO - Sleep mode
- Support AES and SM4 Algorithms -Support some GPIO, USB or SATA signal
- Provide 8 encryption and decryption modes wake-up
- Support DMA l General-purpose I/O port:
l SATA controller (built-in PHY): - 26 GPIOs
- Support 1.5G/3G mode - 8 pins can be configured level or edge
- Support power management interrupt
- Support automatic data flow control - Some pins have multiplexing and mapping
- Support DMA functions
l Timer: l ID Number of chip:
- 3 sets of 26-bit timers - Unique 64bit ID identification number
- Support signal width sample/edge capture, l Power:
PWM adjustable output, count function - 3.0~3.6V(3.3V±10%)
- TMR1 and TMR2 support DMA l Package: LQFP48
Applications
Security storage, home security, USB-related applications, monitoring, alarm systems, printers, scanners and
other application control.
36
35
34
33
32
31
30
29
28
27
26
25
VCC33
UD+
PB0/SD20/CTS
UD-
RUSB
XI
PB1/SD21/DSR
GND
XO
VCC12
V33IO3
PB11/PWM6_/CAP2_
37 24
PB10/SD3CK/DBGIO/INT7 PB2/PWM5_/SD22/CAP1_/RI
38 23
RST#/DBGCK PB3/SD23/DCD
39 22
PA3/SD1CK/PWM4/LED3/CAP0/INT0 PB4/SD30/RXD0/INT6
40 21
PA4/SD2CK/PWM0/LEDC/RXD3/INT1 PB5/DTR/SD31
41 20
PA5/TXD3/PWM1 V33IO3 PB6/RTS/SD32
42 V33IO1 19
PA6/SD0CK/RXD2/INT2 V33IO2 PB7/TXD0/SD33
43 18
PA7/TXD2/CMD0 V33IO1
44 17
PA8/PWM2/SD00/RXD1 PA0/SCK1/LED0/CMD1
45 16
PA9/TXD1/PWM3/SD01 PA1/MOSI1/LED1/CMD2
46 15
PA10/PWM5/SD02/CAP1/INT3 PA2/MISO1/LED2/CMD3
47 14
PA11/PWM6/SD03/CAP2/INT4 PA12/SD10/SCS/INT5
48 13
PA15/MISO0/SD13/RXD0_
PA14/MOSI0/TXD0_/SD12
V33IO2 PA13/SCK0/SD11
VCC12A
VCC12A
RSATA
VCC33
VCC12
SRXM
STXM
SRXP
STXP
GND
1
3
2
4
5
6
7
8
9
11
10
12
ATTENTION:
(1). I: Input; O: Output; P: Power.
(2). SATA: SATA signal; USB: USB signal.
(3). The priority of multiplexing functions of the pins in the table are arranged in order of high to low
(excluding the main function GPIO function)
(4). Pins 37, 39 and 40 of the chips whose lot number is less than 50591 do not support SDIO clock output,
while output by pin 42.
Remarks:
In order to be compatible with the power system of external devices, CH568 will divide zones to manage the
power of peripherals and IOs, and provide multiple sets of power pins. In the above pin description, the pins
marked with different colors belong to different power domains, and the assignments are as follows:
Font color: Same as power VCC33
Font color: Same as power V33IO1
Font color: Same as power V33IO2
Font color: Same as power V33IO3
The CPU core, DMA arbitration controller, SRAM and various peripheral modules are mounted on the 64bit
system bus of CH568. The DMA controller can be used for peripheral modules such as USB, SATA, SD,
SPI0, LED and TIMER.
of the register is described in detail. The following table shows the assignment of base address of each
peripheral.
Table 2-2 Peripheral Base Address Assignment
Peripheral No. Peripheral name Peripheral base address
1 SYS 0x0040 1000
2 TMR0 0x0040 2000
3 TMR1 0x0040 2400
4 TMR2 0x0040 2800
5 UART0 0x0040 3000
6 UART1 0x0040 3400
7 UART2 0x0040 3800
8 UART3 0x0040 3C00
9 SPI0 0x0040 4000
10 SPI1 0x0040 4400
11 PWMX 0x0040 5000
12 LED 0x0040 6000
13 USB 0x0040 9000
14 SDC 0x0040 A000
15 SATA 0x0040 B000
16 ECDC 0x0040 C400
The following table shows the explanation of "Access" in the register description in the subsequent chapters:
Abbreviation Description
RF The read value is fixed, which is not affected by reset.
RO Read only.
WO Write only (the read value is 0 or invalid).
RZ Read-only, automatically cleared after read operation.
WZ Write to clear.
RW Readable, writable.
RW1 Clear by reading/writing 1.
WA Write-only (in safety mode), the read value is 0 or invalid.
RWA Write in read/safety mode.
After the system or power is reset, CH568 is in running state. When the CPU does not need to continue to
run, or some functional modules do not need to be used, the clock or independent power of these modules
can be turned off, to reduce power consumption.
The register R8_GLOB_RESET_KEEP is only reset at the time of power-on reset, and it is not affected by
other types of reset.
signal;
0: Disable.
[1:0] RB_RESET_FLAG RO Last reset flag, as shown in Table 3-2. 1
In order to reduce power consumption, the physical PHY module (such as USB/SATA) that is not used
during the low power period shall be turned off before entering the low power state. Set the
RB_SLP_SATA_PWRDN bit to 1, and the RB_SLP_USB1_PWRDN bit to 1. In addition, GPIO pins cannot
be in a floating state, and need to be set to output state or external input state with a fixed level. If there is no
external input with a fixed level, it needs to be set to the input state in internal pull-down mode.
In low power mode, CH568 only supports part of GPIOs or USB or SATA wake up, please refer to
R8_SLP_WAKE_CTRL register.
There are 8 GPIO pins that support wake-up, which are 8 pins that support GPIO interrupts. GPIO wake-up
event source is the same as the GPIO interrupt event source. However, only when there is level trigger
(R8_GPIO_INT_MODE is not required) and the bit corresponding to R8_GPIO_INT_POLAR is 0, the
GPIO pin will wake up in a low level. When the bit corresponding to R8_GPIO_INT_POLAR is 1, GPIO
will wake up in a high level.
When there is a low level at PA3 port, a wake-up event will be generated. After CH568 exits the low-power
mode, it will trigger the GPIO interrupt of PA3 port.
When the wake-up signal appears on the USB port, a wake-up event will be generated. After CH568 exits
the low-power mode, the following register needs to be set.
RB_SLP_USB1_PWRDN = 0; //In safe mode
bUH_TX_BUS_RESUME = 1;
bUH_TX_BUS_RESUME = 0;
After the external clock is sent to the CH568, it will be connected to USB-PHY and SATA-PHY to generate
the clock frequency required by USB and SATA controllers, and generate the frequency multiplication clock
of 480MHz through the PLL module. Get the clock frequency of 30MHz or 480MHz before frequency
division through the clock source selection control bit (RB_CLK_SEL_PLL). The system clock Fsys (HCLK)
can be obtained after the clock frequency is divided by R8_CLK_PLL_DIV, namely the main clock of CPU,
Relevant information can be downloaded from the website: www.wch.cn
CH568 Datasheet 15 http://wch.cn
Each peripheral module clock has a corresponding clock register control bit, which can be turned on or off
individually. In order to reduce the power consumption of chip, you can turn off the function module clocks
that are not used.
When the system is powered on, 30MHz is selected as the PLL clock source by default, the frequency
division factor is 2, and the default main frequency is 15MHz.
In the PA port, bits PA[0]-PA[15] are valid, corresponding to the 16 GPIO pins on the chip. In the PB port,
the PB[0]-PB[7] and PB[10]-PB[11] bits are valid, corresponding to the 10 GPIO pins on the chip. Among
them, 8 GPIO ports have interrupt function and can realize sleep wake-up function.
Each I/O port bit can be freely programmed, but the I/O port register must be accessed by 8-bit, 16-bit or
32-bit words. If the multiplexing function of pin is not enabled, it will be used as a general-purpose I/O port.
[9:8]
PB pin Schmitt trigger function control:
1: Enable the Schmitt trigger input function or
[11:10]
R32_PB_SMT RW low slope output function of this pin; 1
[7:0]
0: Disable the Schmitt trigger input function
or low slope output function of this pin.
If a pin is multiplexed with multiple functions, and multiple functions are enabled, please refer to the
function order in the "Multiplexing Function and Mapping" list in the pin of section 1.2 for the priority order
of multiplexing function.
For example: If PA0 pin is multiplexed as /SCK1/LED0/CMD1, the clock function of SPI1 has priority, and
the CMD1 function of SD1 controller is the lowest. In this way, the multiplexing functions with the
relatively higher priority of the pin whose functions with the lowest priority need not to be used can be
enabled among multiple multiplexing functions.
The following tables list the I/O pins used by each functional module.
Table 5-2 Serial Peripheral Interface (SPI0)
Pin GPIO Function Description
SCS PA12 Chip selection input pin of SPI0 slave
SCK0 PA13 SPI0 serial clock pin, host output/slave input
MOSI0 PA14 SPI0 serial data pin, host output/slave input
MISO0 PA15 SPI0 serial data pin, host input/slave output
MOSI1 PA1 SPI1 serial data output pin (only host function)
MISO1 PA2 SPI1 serial data input pin (only host function)
5.3.2 Remapping
In order to optimize the number of peripherals in the chip package, some multiplexing functions can be
remapped to other pins. The remapping of pin can be realized by means of setting the multiplexing and
mapping register R8_PORT_PIN.
CH568 supports the remapping of UART0, TIMER1 and TIMER 2 peripheral pins, please refer to the
following table for details:
Table 5-9 Remapping Pin
Peripheral Function Default Pin Remapping Pin
UART0 PB4/PB7 PA15/PA14
TIMER1/PWM5 PA10 PB2
TIMER2/PWM6 PA11 PB11
The CH568 chip has 2 SPI interfaces, and their respective characteristics are as follows:
SPI0 features:
(1). Support master mode and device mode;
(2). Compatible with Serial Peripheral Interface (SPI) specification;
(3). Support the data transmission methods in mode 0 and mode 3;
(4). 8-bit data transmission mode;
(5). The clock frequency is close to half of Fsys;
(6). 8-byte FIFO;
(7). The device mode supports the first byte as command mode or data stream mode;
(8). Support DMA data transmission.
SPI1 features:
(1). Only support master mode;
(2). Support the data transmission methods in mode 0 and mode 3;
(3). 8-bit data transmission mode;
(4). The maximum clock frequency is close to half of Fsys;
(5). 8-byte FIFO.
mode);
0: Mode 0 (SCK is at low level in idle
mode).
This bit is only valid in host mode.
2-wire or 3-wire SPI mode configuration
bit, only for SPI0, SPI1 does not need this
2 RB_SPI_2WIRE_MOD RW control bit: 0
1: 2-wire mode (SCK, MISO);
0: 3-wire mode (SCK, MOSI, MISO).
FIFO register and counter register clear
bit:
1 RB_SPI_ALL_CLEAR RW 1
1: Force to clear;
0: Not clear.
SPI0 master/slave mode selection bit, only
for SPI0
0 RB_SPI_MODE_SLAVE RW 1: Device mode; 0
0: Host mode.
Note: SPI1 does not support device mode.
SPI0:
1: Enable the first byte received to
generate an interrupt;
0: Disable the first byte received to
generate an interrupt.
To enable this function, you need to set
SPI to device mode, and meanwhile it is
required to set the
RB_SPI_SLV_CMD_MOD bit to 1, thus
entering the first byte command mode.
[6:5] Reserved RO Reserved. 0
FIFO overflow interrupt enable bit, only
supported by SPI0:
4 RB_SPI_IE_FIFO_OV RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
DMA end interrupt enable bit, only
supported by SPI0:
3 RB_SPI_IE_DMA_END RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
FIFO half use interrupt enable bit:
2 RB_SPI_IE_FIFO_HF RW 1: Enable the corresponding interrupt; 0
0: Disable the corresponding interrupt.
SPI single byte transmission completion
interrupt enable bit:
1 RB_SPI_IE_BYTE_END RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
SPI all byte transmission completion
interrupt enable bit:
0 RB_SPI_IE_CNT_END RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
Register R8_SPIx_BUFFER and register R8_SPIx_FIFO are SPI data related registers. The main difference
is: After the latter reads one byte of data, the value of length register (R16_SPI_TOTAL_CNT) is
automatically reduced by 1 because it reads from FIFO. After the former reads one byte, the length register
value remains unchanged.
Mode 0: RB_SPI_MST_SCK_MOD = 0
模式0时序图
Cycle 1 2 3 4 5 6 7 8
CLK
MSB 6 5 4 3 2 1 LSB
MOSI
Mode 3: RB_SPI_MST_SCK_MOD = 1
模式3时序图
Cycle 1 2 3 4 5 6 7 8
CLK
Configuration Steps:
(1). Set SPI master mode clock divider register (R8_SPIx_CLOCK_DIV), to configure SPI clock speed;
(2). Set the RB_SPI_MODE_SLAVE bit of SPI mode configuration register (R8_SPIx_CTRL_MOD) to 0,
to configure SPI as the master mode;
(3). Set the RB_SPI_SLV_CMD_MOD bit of SPI mode configuration register (R8_SPIx_CTRL_MOD), and
set it to mode 0 or mode 3 according to the requirements of the connected device;
(4). Set the RB_SPI_FIFO_DIR bit of SPI mode configuration register (R8_SPIx_CTRL_MOD), and
configure the FIFO direction. If it is 1, the current FIFO direction is data input. If it is 0, the current FIFO
direction is data output.
(5). Set the RB_SPI_MOSI_OE bit and RB_SPI_SCK_OE bit of SPI mode configuration register
(R8_SPIx_CTRL_MOD) to 1, and set the RB_SPI_MISO_OE bit to 0, and set the bits corresponding to the
MOSI pin and SCK pin in the PA port direction register (R32_PB_DIR) to 1, set the bit corresponding to
MISO pin to 0, to configure the MOSI pin and SCK pin direction as output, and configure the MISO pin
direction as input;
Configuration Steps:
(1). Set the RB_SPI_MODE_SLAVE bit of SPI0 mode configuration register (R8_SPI0_CTRL_MOD) to 1,
to configure SPI0 as the slave mode;
(2). Set the RB_SPI_SLV_CMD_MOD bit of SPI0 mode configuration register (R8_SPI0_CTRL_MOD) as
required;
(3). Set the RB_SPI_FIFO_DIR bit of SPI0 mode configuration register (R8_SPI0_CTRL_MOD), to
configure the FIFO direction. If it is 1, the current FIFO direction is data input. If it is 0, the current FIFO
direction is data output.
Relevant information can be downloaded from the website: www.wch.cn
CH568 Datasheet 35 http://wch.cn
(4). Set the RB_SPI_MOSI_OE bit and RB_SPI_SCK_OE bit of SPI0 mode configuration register
(R8_SPI0_CTRL_MOD) to 0, and set the RB_SPI_MISO_OE bit to 1, and set the bits corresponding to the
MOSI pin, SCK pin and SCS pin in the PA port direction register (R32_PB_DIR) to 0, set the bit
corresponding to MISO pin to 1, to configure the MOSI pin, SCK pin and SCS pin direction as input, and
configure the MISO pin direction as output. If the MISO pin is not configured as output, when SCS chip
selection is valid (low level), MISO will automatically enable output. It is recommended to set the MISO pin
as input so that MISO does not output when chip selection is invalid, so that SPI bus can be shared when
multiple devices operates. Note: For I/O pin direction of MISO in SPI slave mode, in addition to setting it as
output, it also can be automatically configured as output during the period of valid SPI chip selection, but its
output data is selected by RB_SPI_MISO_OE. When RB_SPI_MISO_OE is 1, SPI data is output. When
RB_SPI_MISO_OE is 0, GPIO register data is output.
(5). Optionally, set the preset data register in SPI0 device mode (R8_SPI0_SLAVE_PRE), to be
automatically loaded into the buffer for the first time after chip selection for external output. After 8 clocks
(that is, the exchange of the first byte data between host and slave is completed), the controller will obtain
the first byte data (command code) from the external SPI host, and the external SPI host exchanges and the
preset data (status value) in R8_SPI0_SLAVE_PRE can be obtained. The bit 7 of this register will be
automatically loaded into the MISO pins during the low level period of SCK after valid SPI chip selection.
For SPI mode 0 (CLK defaults to low level), if the bit 7 of R8_SPI0_SLAVE_PRE is preset, the external SPI
master will obtain the preset value of bit 7 of R8_SPI0_SLAVE_PRE by inquiring the MISO pins when the
SPI chip selection is valid but there is no data transmission, thereby the value of bit 7 of
R8_SPI0_SLAVE_PRE can be obtained only by the valid SPI chip selection.
UART features:
(1). Compatible with 16C550 asynchronous serial port and enhanced;
(2). Support 5, 6, 7 or 8 data bits and 1 or 2 stop bits;
(3). Support the parity check modes of odd, even, no check, blank 0 and flag 1;
(4). Programmable communication baud rate, support 115200bps and communication baud rate up to
6Mbps;
(5). Built-in 8-byte FIFO buffer, support 4 FIFO trigger levels;
(6). UART0 supports MODEM signals CTS, DSR, RI, DCD, DTR and RTS, which can be converted to
RS232 level;
(7). Support automatic handshake and automatic transmission rate control of hardware flow control signals
CTS and RTS, compatible with TL16C550C;
(8). Support serial port frame error detection and Break line interval detection;
(9). Support full-duplex and half-duplex serial communication, and UART0 provides a transmiting status pin
for switching RS485;
enable/disable bit
1: Enter half-duplex transceiver mode,
giving priority to transmission, receiving
when not transmitting;
0: Disable half-duplex transceiver mode.
Note: This only supports UART0.
Being transmiting status (TNOW) output
(DTR pin) enable bit of UART0:
1: Enable the DTR pin of UART0 to
output status of being transmiting TNOW,
6 RB_MCR_TNOW RW 0
which can be used to control switch of
RS485 transceiving;
0: Disable.
Note: This only supports UART0.
UART0 allow CTS and RTS hardware
automatic flow control bit:
1: Allow CTS and RTS hardware
automatic flow control;
0: Invalid.
Note: This only supports UART0.
In the flow control mode, if this bit is 1,
then UART will continuously send the
next data only when it detects that the CTS
pin input is valid (active low). Otherwise,
the serial port transmission will be
suspended. And the change of CTS input
5 RB_MCR_AU_FLOW_EN RW status will not generate MODEM status 0
Interrupt when this bit is 1. If this bit is 1
and RTS is 1, UART will automatically
validate the RTS pin (active low) when
receiver FIFO is empty. And UART will
automatically invalidate the RTS pin until
the number of received bytes reaches the
trigger point of FIFO and can re-validate
RTS pin when receiver FIFO is empty. The
CTS pin can be connected to the other
party RTS pin through hardware automatic
band rate control, and the RTS pin to the
other CTS pin.
Test mode control bit of UART0 internal
loop:
1: Enable the test mode of internal loop;
0: Disable the test mode of internal loop.
In the test mode of the internal loop, all
4 RB_MCR_LOOP RW 0
external output pins of UART are invalid,
TXD internally returns to RXD (i.e., the
output of TSR internally returns to the
input of RSR), RTS internally returns to
CTS, DTR internally returns to DSR,
The meaning of bit RB_IIR_NO_INT of interrupt recognition register (R8_UARTx_IIR) and each bit of
RB_IIR_INT_MASK domain are shown in the following table:
Table 8-3 Meaning of RB_IIR_INT_MASK in IIR Register
IIR register bit Method for
Priority Interrupt Type Interrupt sources clearing
IID3 IID2 IID1 NOINT
interrupt
No interrupt
0 0 0 1 None No interrupt
generated
0: No data.
After reading all the data in the FIFO, this
bit will be automatically cleared.
When R8_UART0_ADR is not 0FFH and RB_LCR_PAR_EN=1, the automatic comparison function of bus
address is enabled, and the following parameters should be configured: RB_LCR_WORD_SZ is 11b to
select 8 data bits. For the case when the address byte is MARK (that is, the bit 9 of data byte is 0),
RB_LCR_PAR_MOD should be set to 10b; for the case when the address byte is SPACE (that is, the bit 9 of
data byte is 1), RB_LCR_PAR_MOD should be set to 11b.
4 sets of UARTs have built-in independent transceiver buffer and 8-byte FIFO, support simplex, half-duplex
or full duplex asynchronous serial communication. Serial data includes 1 low-level start bit, 5, 6, 7 or 8 data
bits, 0 or 1 additional verification code or flag bit, 1 or 2 high-level stop bits, and supports
odd/even/mark/blank check. Support common communication baud rates: 1200, 2400, 4800, 9600, 19.2K,
38.4K, 57.6K, 115.2K, 230.4K, 460.8K, 921.6K, 1.8432M, 2.7648M, 7.8125M, etc. The baud rate error of
UART transmitting signal is less than 0.2%, and the allowable baud rate error of UART receiving signal is
not greater than 2%.
In interrupt trigger mode, when it receives the THR empty interrupt, if FIFO is enabled, up to 8 bytes can be
written to THR and FIFO at a time, then it will be transmitted automatically by the controller in sequence. If
FIFO is disabled, only one byte can be written at a time. If no data needs to be transmitted, simply exit (the
Relevant information can be downloaded from the website: www.wch.cn
CH568 Datasheet 47 http://wch.cn
In the query mode, it can judge whether the transmitter FIFO is empty according to
RB_LSR_TX_FIFO_EMP bit of LSR. If this bit is 1, it can write data to THR and FIFO. If FIFO is enabled,
it can write up to 8 bytes at a time.
Data timeout interrupt received by the serial port (the low 4 bits of IIR are 0CH) means that there is at least
one byte of data in the receiver FIFO, and the user has waited for the time equivalent to the time for
receiving 4 data when the serial port receives data last time and the MCU takes the data last time. The
interrupt is cleared when a new data is received again, or the interrupt can also be cleared when the MCU
reads RBR once. When receiver FIFO is empty, RB_LSR_DATA_RDY bit of LSR is 0. When there is data
in the receiver FIFO, it is valid when RB_LSR_DATA_RDY bit is 1.
In the interrupt trigger mode, you can read the R8_UARTx_RFC register to query the remaining data count
in the current FIFO after receiving the interrupt that serial port receives data timeout, read all the data
directly, or continuously query the RB_LSR_DATA_RDY bit of LSR. If this bit is valid, read the data until
this bit becomes invalid. After receiving the interrupt for receiving data availability from serial port, you can
read the number of bytes set by RB_FCR_FIFO_TRIG of FCR from RBR, and then directly read the data for
the number of bytes, or you can read all the data in the current FIFO according to the RB_LSR_DATA_RDY
bit and the R8_UARTx_RFC register.
In query mode, MCU can judge whether the receiver FIFO is empty according to the RB_LSR_DATA_RDY
bit of LSR, or read the R8_UARTx_RFC register to get the data count in the current FIFO and get all the
data received by the serial port.
If automatic CTS is enabled, CTS pin must be valid before the serial port sends data. The serial port
transmitter detects CTS pin before sending the next data. When CTS pin state is valid, the transmitter sends
the next data. In order to ensure that the transmitter stops sending the later data, CTS pin must be disabled
before the intermediate moment of the last stop bit currently sent. The automatic CTS function reduces the
interrupt applied to the MCU system. When hardware flow control is enabled, a change of CTS pin level
does not trigger a MODEM interrupt as the controller automatically controls the transmitter based on CTS
pin status. If automatic RTS is enabled, RTS pin output will be valid only when there is enough space in
FIFO to receive data, and RTS pin output is disabled when the receiver FIFO is full. RTS pin output will be
valid if all the data in the receiver FIFO is taken or cleared. When the trigger points for the receiver FIFO are
reached (the number of existing bytes in the receiver FIFO is not less than the number of bytes set by
RB_FCR_FIFO_TRIG of FCR), RTS pin output is invalid, and the transmitter of the other side is allowed to
send another data after RTS pin is invalid. Once the data in the receiver FIFO is emptied, RTS pin will be
automatically re-enabled, so that the transmitter of the other side restores sending. If both automatic CTS and
automatic RTS are enabled (both RB_MCR_AU_FLOW_EN and RB_MCR_RTS of MCR register are 1),
one side will not send data unless there is sufficient space in the receiver FIFO of the other side when RTS
pin of one side is connected to CTS pin of the other side. Therefore, the hardware flow control can avoid
FIFO overflow and timeout errors during serial port reception.
Features:
(1). 3 26-bit timers, and the longest timing interval of each timer is 2^26 clock cycles;
(2). Each timer supports PWM function;
(3). Each timer supports capture function;
(4). Timer interrupt is supported by each timer, and among them TMR1 and TMR2 support DMA and
interrupt;
(5). The capture function can be set to level change capture function and high or low level hold time capture
function;
(6). PWM function supports dynamically adjust PWM duty cycle settings;
0: No action.
Timer mode setting bit:
0 RB_TMR_MODE_IN RW 1: Capture/count mode 0
0: Timing mode/PWM mode
It is needed to set the register (R32_TMRx_FIFO) and register (R32_TMRx_CNT_END) when PWM
outputs, R32_TMRx_FIFO as the data register, R32_TMRx_CNT_END as the PWM total cycle register.
If RB_TMR_PWM_REPEAT domain is set to 00, it means that the above process repeates once, 01 means
that the above process repeates for 4 times, 10 means that the above process repeates for 8 times, and 11
means that the above process repeates for 16 times. After repeating, take the next data in FIFO and then
continue.
01 Edge trigger
Falling edge to
10
falling edge
There are two trigger states in edge trigger mode, which can capture high level width or low level width.
When highest bit (bit 25) of the valid data in data register (R32_TMRx_FIFO) is 1, high level is captured;
otherwise, low level is captured. If the bit 25 of multiple sets of data is 1 (or 0), the width of the high (or low)
level exceeds the timeout value, and multiple sets need to be accumulated are required.
In the trigger modes from falling edge to falling edge or from rising edge to rising edge, an input change
cycle can be captured. When the highest bit (bit 25) of the valid data in data register (R32_TMRx_FIFO) is 0,
one cycle is normally sampled. When it is 1, the input change period exceeds the timeout value
R32_TMRx_CNT_END, and the latter set of data needs to be added and accumulated as a single input
change cycle.
Chapter 9 PWM
The extended PWM pin output is identified as PWM3/ PWM4/ PWM5/ PWM6, among which PWM5 and
PWM6 support remapping to PWM5_ and PWM6_ pins.
0: No action.
LED serial data bit sequence:
0 RB_LED_BIT_ORDER RW 1: High byte is the first; 0
0: Low byte is the first;
The USB related registers of CH568 are divided into 3 parts, some of which are reused in the host and
device modes.
1) USB global registers;
2) USB device controller registers;
3) USB host controller registers.
5 Reserved RO Reserved. 0
FIFO overflow interrupt:
4 bUIE_FIFO_OV RW 1: Enable the corresponding interrupt; 0
0: Disable the corresponding interrupt.
In USB host mode, SOF timing interrupt:
3 bUIE_HST_SOF RW 1: Enable the corresponding interrupt; 0
0: Disable the corresponding interrupt.
USB bus suspension or wake-up event
interrupt:
2 bUIE_SUSPEND RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
USB transfer completion interrupt:
1 bUIE_TRANSFER RW 1: Enable the corresponding interrupt; 0
0: Disable the corresponding interrupt.
In USB host mode, USB device connection
or disconnection event interrupt:
0 bUIE_DETECT RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
In USB device mode, USB bus reset event
interrupt:
0 bUIE_BUS_RST RW 0
1: Enable the corresponding interrupt;
0: Disable the corresponding interrupt.
MASK_UIS_H_RES is only valid in host mode. In host mode, if the host sends OUT/SETUP token packet,
the PID is the handshake packet ACK/NAK/STALL/NYET, or the device has no response/timeout. If the
host sends IN token packet, the PID is the PID of the data packet (DATA0/DATA1/DATA2/MDATA) or the
handshake packet PID.
Endpoint 0 is the default endpoint and supports control transmission. The sending and receiving share a
64-byte data buffer area.
Endpoint 1, endpoint 2, endpoint 3 each includes a sending endpoint IN and a receiving endpoint OUT. The
sending and receiving endpoint each has a separate 512-byte data buffer or double 512-byte data buffer
respectively, support bulk transmission, interrupt transmission, and isochronous/synchronous transmission.
Endpoint 4 includes a sending endpoint IN and a receiving endpoint OUT. The sending and receiving
endpoint each has a separate 512 bytes data buffer respectively, support bulk transmission, interrupt
transmission, and isochronous/synchronous transmission.
Endpoints 0/1/2/3 all can set UEPn_DMA register to configure their DMA addresses respectively. Set the
endpoint receiving and sending data buffer mode through UEP4_1_MOD and UEP2_3_MOD registers.
Each group of endpoints are equipped with receiving and transmission control register UEPn_TX_CTRL and
UEPn_RX_CTRL and sending length register UEPn_T_LEN (n=0/1/2/3/4), which are used to set the
synchronization trigger bit of this endpoint, the response to OUT transactions and IN transactions and the
length of data to be sent.
As the necessary USB bus pull-up resistor of USB device, it can be set whether to be enabled by software at
any time. When bUC_DEV_EN in USB control register USB_CTRL is set to 1, CH568 will set according to
the speed of bUC_SPEED_TYPE, internally connect the pull-up resistor with the DP/DM pin of the USB
bus and enable the USB device function.
When a USB bus reset, USB bus suspending or waking event is detected, or when the USB successfully
processes data sending or receiving, the USB protocol processor will set corresponding interrupt flag. If the
interrupt enable is on, the corresponding interrupt request will be also generated. The application program
can directly query or query and analyze the interrupt flag register USB_INT_FG in the USB interrupt service
program, and perform corresponding processing according to UIF_BUS_RST and UIF_SUSPEND. In
addition, if UIF_TRANSFER is valid, it is required to continue to analyze the USB interrupt status register
USB_INT_ST, and perform the corresponding processing according to the current endpoint number
MASK_UIS_ENDP and the current transaction token PID identification MASK_UIS_TOKEN. If the
synchronization trigger bit bUEP_R_TOG of OUT transaction of each endpoint is set in advance, you can
judge whether the synchronization trigger bit of the data packet received matches the synchronization trigger
bit of the endpoint through bUIS_TOG_OK. If the data is synchronized, the data is valid. If the data is not
synchronized, the data should be discarded. After the USB sending or receiving interrupt is processed each
time, the synchronization trigger bit of corresponding endpoint should be modified correctly to detect
whether the data packet sent next time and the data packet received next time are synchronized. In addition,
bUEP_AUTO_TOG can be set to automatically flip the corresponding synchronization trigger bit after
sending or receiving successfully.
The data to be sent by each endpoint is in their own buffer, and the length of the data to be sent is
independently set in UEPn_T_LEN, and the sending length of one packet cannot exceed 512 bytes. The data
received by each endpoint is in their own buffer, but the length of the data received is in the USB length
receiving register USB_RX_LEN, and it can be distinguished according to the current endpoint number
when the USB is receiving an interrupt. The maximum packet length that can be received by each endpoint
needs to be written into the UEPn_MAX_LEN register in advance.
5 Reserved RO Reserved. 0
4 bUEP3_BUF_MOD RW Endpoint 3 data buffer mode control bit. 0
1: Enable endpoint 2 receiving (OUT);
3 bUEP2_RX_EN RW 0
0: Disable endpoint 2 receiving.
1: Enable endpoint 2 sending (IN);
2 bUEP2_TX_EN RW 0
0: Disable endpoint 2 sending.
1 Reserved RO Reserved. 0
0 bUEP2_BUF_MOD RW Endpoint 2 data buffer mode control bit. 0
The data buffer modes of USB endpoints 1, 2 and 3 are controlled by a combination of bUEPn_RX_EN,
bUEPn_TX_EN and bUEPn_BUF_MOD (n=1/2/3) respectively, refer to the following table for details.
Among them, in double 512-byte buffer mode, the first 512-byte buffer will be selected based on
bUEP_*_TOG=0 and the last 512-byte buffer will be selected based on bUEP_*_TOG=1 during USB data
transmission, and bUEP_AUTO_TOG=1 is set to realize automatic switch.
control bit:
1: After data is successfully received, the
corresponding synchronization trigger bit is
automatically flipped;
0: It is not flipped automatically, but can be
switched manually.
Only endpoint 1/2/3 supports, and
isochronous/synchronous transmission can
only be switched manually.
Expected synchronization trigger bit of the
receiver (processing OUT transactions) of
USB endpoint n:
00: Expect DATA0;
[4:3] MASK_UEP_R_TOG RW 01: Expect DATA1; 0
10: Expect DATA2;
11: Expect MDATA.
It is invalid for isochronous/synchronous
transmission.
1: Expect no response, used to achieve
isochronous/synchronous transmission of
2 bUEP_R_RES_NO RW endpoints other than endpoint 0. Ignore 0
MASK_UEP_R_RES at this time;
0: Expect response.
Response control from receiver of USB
endpoint n to OUT transactions:
00: Response ACK; -
10: Response NAK or busy;
[1:0] MASK_UEP_R_RES RW 0
11: Response STALL or error;
01: Response NYET.
It is invalid for isochronous/synchronous
transmission.
Each USB transaction initiated by host endpoint always automatically sets the interrupt flag
UIF_TRANSFER after processing. The application program can directly query or query and analyze the
interrupt flag register USB_INT_FG in the USB interrupt service program, and perform corresponding
processing according to each interrupt flag. In addition, if UIF_TRANSFER is valid, it is required to
continue to analyze the USB interrupt status register USB_INT_ST, and perform the corresponding
processing according to the response PID identification MASK_UIS_H_RES of the current USB
transmission transaction.
If the synchronization trigger bit bUH_R_TOG of IN transaction of host receiving endpoint is set in advance,
you can judge whether the synchronization trigger bit of the data packet received matches the
synchronization trigger bit of the endpoint through bUIS_TOG_OK. If the data is synchronized, the data is
valid. If the data is not synchronized, the data should be discarded. After the USB sending or receiving
interrupt is processed each time, the synchronization trigger bit of corresponding host endpoint should be
modified correctly to synchronize the data packet sent next time and detect whether the data packet received
next time is synchronized. In addition, bUEP_AUTO_TOG can be set to automatically flip the
corresponding synchronization trigger bit after sending or receiving successfully.
USB host token setting register UH_EP_PID is used to set the endpoint number of the target device being
operated and the token PID packet identification of the USB transmission transaction. The data
corresponding to the SETUP token and OUT token is provided by the host sending endpoint. The data to be
sent is in the UH_TX_DMA buffer, and the length of the data to be sent is set in UH_TX_LEN. The data
corresponding to the IN token is returned by the target device to the host receiving endpoint, the received
data is stored in the UH_RX_DMA buffer, and the received data length is stored in USB_RX_LEN. The
maximum packet length that can be received by the host endpoint needs to be written to the
UH_RX_MAX_LEN register in advance.
The data buffer modes of USB host sending endpoint are controlled by a combination of bUH_EP_TX_EN
and bUH_EP_TBUF_MOD, refer to the following table.
Table 11-6 Host send buffer Mode
bUH_EP_TX_EN bUH_EP_TBUF_MOD Structure description: Take UH_TX_DMA as start address
0 x Endpoint is disabled, UH_TX_DMA buffer is not used.
1 0 Single 512-byte sending buffer (SETUP/OUT).
Double 512-byte sending buffer, selected by bUH_T_TOG:
1 1 When bUH_T_TOG=0, select the first 512 bytes of buffer;
When bUH_T_TOG=1, select the last 512 bytes of buffer.
The data buffer modes of USB host receiving endpoint are controlled by a combination of bUH_EP_RX_EN
and bUH_EP_RBUF_MOD, refer to the following table.
Table 11-7 Host receive buffer Mode
bUH_EP_RX_EN bUH_EP_RBUF_MOD Structure description: Take UH_TX_DMA as start address
0 x Endpoint is disabled, UH_RX_DMA buffer is not used.
1 0 Single 512-byte receiving buffer (IN).
Double 512-byte receiving buffer, selected by
bUH_R_TOG:
1 1
When bUH_R_TOG=0, select the first 512 bytes of buffer;
When bUH_R_TOG=1, select the last 512 bytes of buffer.
SDx_RESPONSE3 register is multiplexed. The multiplexing of the register is: in the process of continuously
writing multiple blocks of data to the card using the CMD25 command and when the block interrupt is
completed, if it is not required to change DMA address, write the action of this register and start the
operation of writing data to SD. To change DMA address, write to the DMA address register to start to write
data to SD, and do not need to start it by writing to register.
If continuous multi-block read and write SD operations are performed, the user can write to SDx_DMA
register to change the DMA address as needed after the single block transmission is completed
(bSIF_BLOCK_GAP). Do not change the DMA address during the transmission process, otherwise, data
counting errors may be caused.
When performing continuous multi-block writing, it is required to start the continued write operation by
writing to SDx_WRITE_CONT or SDx_DMA register after the single block transmission is completed. It is
not required when reading multi-block.
ECB mode and CTR mode with AES algorithm 128bit key;
ECB mode and CTR mode with AES algorithm 192bit key;
ECB mode and CTR mode with AES algorithm 256bit key;
In the process of data encryption and decryption, the key needs to be loaded. For AES algorithm, the key
length is set to 128/192/256 bits, the user key is extended to 11×128/13×128/15×128-bit extended keys.
While for SM4 algorithm, the 128-bit user key is extended to 32×32-bit extended key. These extended keys
are stored in internal registers for use during encryption and decryption.
Figure 12-1 Encryption and Decryption Diagram in ECB and CTR Modes
0: Encryption mode.
Enable to write SD data for encryption and
decryption control bit:
2 bRDDAT_ED_EN RW 0
1: Encryption and decryption;
0: No action.
Enable to read SD data for encryption and
decryption control bit:
1 bWRDAT_ED_EN RW 0
1: Encryption and decryption;
0: No action.
Key extension function enable control bit,
0 bKEYE_EN RW 0
high level pulse enable.
Note: When bKEYE_EN bit is used, it needs to be set high and then low.
3. Set bKEYE_EN of control register AES_SM4_CTRL, set it to 1 and then to 0, to enable the key
expansion;
4. Query the interrupt flag register AES_SM4_INT_FG and wait for the key extension to complete the
interrupt. Optionally, turn on the key expansion completion interrupt enable bit bKEYE_ACT_IE of control
register and wait for the interrupt to be triggered;
5. Clear the interrupt. Set bEDMOD_SELT bit of the control register to 0, select the encryption mode, and
set the bRDDAT_ED_EN bit to 1, to enable the encryption function when transmitting data from SRAM to
SD, or set bWRDAT_ED_EN bit to 1, to enable the encryption function when transmitting data from SD to
SRAM.
1: Enable;
0: Disable.
SATA working mode selection bit:
5 bSC_HOST_MODE RW 1: SATA host mode; 0
0: SATA device mode.
SATA speed type selection bit:
1: Forced to work in 1.5G mode;
4 bSC_FORCE_1P5G RW 0: Normal mode. At this time, the speed 0
depends on bSMS_SPEED_TYPE bit in
SATA_MIS_ST register.
Automatical suspend enable bit before
SATA transmission completion interrupt
flag is not cleared:
1: Automatically suspend before interrupt
flag SIF_TRANSFER is not cleared. For
3 bSC_INT_BUSY RW 0
receiving, the R_RDY primitive is
automatically not returned. For sending,
subsequent transmissions are automatically
suspended;
0: Not suspend.
SATA physical layer software reset control
bit:
1: Physical layer reset;
2 bSC_RESET_PHY RW 0: The physical layer is working normally. 1
It is ready to send COMRESET in host
mode, and ready to send COMINIT in
device mode.
SATA link layer software reset control bit:
1 bSC_RESET_LINK RW 1: Link layer reset; 1
0: The link layer is working normally.
1: Empty SATA interrupt flag and FIFO,
0 bSC_CLR_ALL RW needs software to clear; 1
0: Not empty.
0: No event.
Terminate DMA data transmission interrupt
flag bit, cleared by writing 1:
5 bSIF_DMAT RW1 0
1: DMATp event trigger is received;
2. No event.
FIFO overflow interrupt flag bit, cleared by
writing 1:
4 bSIF_FIFO_OV RW1 0
1: FIFO overflow trigger;
2. No event.
In the master mode, bus conflict flag bit,
cleared by writing 1:
3 bSIF_COLLIDE RW1 0
1: When sending data, bus conflict occurs.
2. No event.
Data reception completion flag bit, cleared
by writing 1:
2 bSIF_RECV_OK RW1 1: One frame of data is received and 0
triggered;
2. No event.
Data sending completion flag bit, cleared
by writing 1:
1 bSIF_TRAN_OK RW1 0
1: One frame of data is sent and triggered;
2. No event.
Physical layer connection or disconnection
event flag bit, cleared by writing 1:
0 bSIF_PHYRDY RW1 1: Physical layer connection or 0
disconnection event trigger is detected;
2. No event.
Note: 1. When bSIF_DMAT interrupt is received, it indicates that some of data being sent has been
transmitted, and the data frame received on the other side is complete, and CRC and EOF will still be sent.
So bSIF_TRAN_OK interrupt will still be generated.
2. When bSIF_TRAN_OK interrupt is detected, bSIS_CRC_OK=1 and there is no bSIF_DMAT
interrupt during this period, the current data has been sent correctly, otherwise, MCU needs to restart to send.
If an error occurs during data reception, bSIF_RECV_OK interrupt will not be generated. In addition, if
bSRC_R_AUTO_TOG or bSRC_T_AUTO_TOG is 1, any sending error or receiving error will not be
automatically reversed.
3 Reserved RO Reserved. 0
1: Ready to receive data;
2 bSRC_R_READY RW 0
0: Prohibit receiving data.
1: Ready to send data, start sending, and
1 bSRC_T_READY RW needs to be manually cleared after sending; 0
0: Not send.
1: Force to suspend the current transmission
0 bSRC_SYNC_ESCAPE RW and send SYNCp primitive; 0
0: No action.
Chapter 14 Interrupt
Chapter 15 Parameters
Chapter 16 Package
Chip package
Width Of Ordering
Package Pitch Of Pin Instruction Of Package
Plastic Information
LQFP-48 7*7mm 0.5mm 19.7mil Standard LQFP48 pin patch CH568L
Remarks:
The unit of dimension is mm (millimeters)
The pin center spacing is the nominal value, there is no error, and other dimension error is not greater than
±0.2mm.