1. Project Introduction
The desktop electronic clock is designed based on the R7FA2E1A72DFL chip. The time and temperature are displayed through a four-digit 0.56-inch common cathode digital tube. The DHT11 temperature and humidity sensor is used to collect the ambient temperature and humidity. The reset button, serial port circuit, and SWD download circuit are all led out for easy download and debugging.
II. Onboard resources

Figure 2-1 Front view of desktop electronic clock resources

Figure 2-2 Back view of desktop electronic clock resources
1. Main control chip: R7FA2E1A72DFL;
2. Power interface: TYPE-C, 2Pin plug-in;
3. LED: one power indicator light, one charging status indicator light;
4. Buttons: one reset button, one BOOT button, four function buttons;
5. Debug interface: SWD download debug interface, serial port download debug interface, both use 2.54 pin header interface for lead-out;
6. Peripherals: one 0.56-inch common cathode digital tube, one DHT11 temperature and humidity sensor, one passive buzzer;
III. Advantages and features

Figure 3-1 Dimensions of desktop electronic clock board
1. The onboard appearance is small, with a size of only 70mm*35mm (2755.906mil*1377.953mil);
2. Complete download and debugging interfaces;
3. With power switching circuit, it can continue to work through lithium battery power supply even when power is off;
4. Cheap price and complete functions;
5. Use Jiali Chuang's high-quality PCB and genuine components to ensure product quality;
IV. Circuit analysis

4.1. Power supply
circuit The power supply circuit is mainly composed of TYPE-C interface and power indicator light. It uses 2Pin TYPE-C interface, which is simple, convenient and easy to weld. R1 is used as the current limiting resistor of the power indicator light, and LED1 is used as the power indicator light. When the switch is closed, it will light up for prompting.

Figure 4-2 Power input part
4.2. Main control circuit The main control
microcontroller uses R7FA2E1A72DFL, with an operating voltage between 1.6V and 5.5V, a maximum clock frequency of 48Mhz, and a maximum support of 128-KB FLASH, 16-KB SRAM, and 12-bit AD conversion controller. The chip has an integrated crystal oscillator, which does not require an external crystal oscillator. At the same time, it integrates a touch function, and can realize the touch function without a touch chip.
Add a 100nf capacitor to the power input part for power filtering. The VCL pin is used to stabilize the smoothing capacitor of the internal power supply. This pin needs to be connected to the 4.7uf capacitor to the VSS pin.

4.3. Reset circuit
Reset is also called restart. Press the RST button, the RST pin of the main control is pulled low, the system enters the reset state, release the RST button, the RST pin of the main control returns to a high level, the system resumes working state, and the reset is completed.

Figure 4-4 Reset circuit part
4.4. Boot mode selection circuit
When the BOOT1 button is not pressed, the BOOT pin is high, the microcontroller enters the Single-chip mode, that is, the normal working mode. When the button is pressed, the BOOT pin is low, and the microcontroller enters the SCI-BOOT mode, that is, the program download mode, so we can use this button to control the microcontroller to download the program or run normally.

Figure 4-5 Boot mode selection circuit
4.5. Touch control circuit
The R7FA2E1A72DFL main control chip has a touch function. Add a 560 ohm damping capacitor and an appropriate capacitor to stabilize the touch signal on the touch line. In fact, it is sensitive and accurate enough.

Figure 4-6 Touch control circuit
4.6. Independent button circuit
uses four buttons as clock control or other functions.

Figure 4-7 Independent button circuit
4.7, DHT11 temperature and humidity sensor circuit
uses DHT11 temperature and humidity sensor to detect environmental temperature and humidity. DHT11 is a single bus communication method, and a pull-up resistor needs to be connected to the bus. When the bus is idle, its state is high.

Figure 4-8 DHT11 temperature and humidity sensor circuit
4.8, Passive buzzer drive circuit
controls the negative pole of the passive buzzer through the NPN transistor. R7 is a current limiting resistor. The role of R8 is to provide a reliable potential when the chip is just powered on or off to prevent interference. The electromagnetic passive buzzer here is an inductive load. The D1 diode is added as a freewheeling diode to prevent burning.

Figure 4-9 Passive buzzer drive circuit
4.9, Four-digit digital tube drive circuit
uses a 0.56-inch common cathode digital tube to display time, temperature and humidity and other information.

Figure 4-10 Four-digit digital tube drive circuit
4.10, lithium battery charging and discharging part
First is the power switching circuit, which is composed of a P-channel MOS, a pull-down resistor and a diode. When the TYPE-C interface is connected, 5V comes in, and the voltage of the MOS tube G pole is 5V. After passing through a 1N5819 Schottky diode, the VCC voltage is 4.4V, that is, the S pole is 4.4V, which does not meet the conduction condition, and the battery power cannot come in. When the TYPE-C interface is disconnected, the G pole is pulled down to a low level, and the S pole will have a voltage of about 3.5V due to the presence of the body diode, which meets the conditions. At this time, the MOS tube is turned on, and the battery will power the subsequent circuit. Due to the presence of the 1N5819 Schottky diode, the current will not flow back in reverse.
The battery is charged through a TP5056 lithium battery charging chip. When the TYPE-C interface is connected, the lithium battery will be charged at the same time to ensure sufficient power. LED2 is used as the charging status indicator, and R11 is the charging current feedback resistor. By changing the resistance of R11, the overall charging current can be changed.

Figure 4-11 Lithium battery charging and discharging circuit
4.11. The serial port debugging interface
leads out the serial port pins through the 2.54*4P interface for serial port downloading and debugging.

Figure 4-12 Serial port debugging interface
4.12. The SWD debugging interface
leads out the SWD pins through the 2.54*4P interface for SWD mode downloading and debugging.

Figure 4-13 SWD debugging interface
4.13. The M3 copper pillar interface
is used to fix the board through four M3 screw holes.

Figure 4-14 M3 copper pillar interface
V. Precautions
5.1. When drawing the schematic diagram, pay attention to the following:
1. Draw according to the module circuit division and indicate the circuit function;
2. Fill in the name and other information just mentioned in the drawing attributes;
5.2. When purchasing materials, pay attention to the following:
1. Filter the materials in stock first, then filter the price and sort them for purchase;
2. Try to buy materials from the same warehouse and choose nearby warehouses to shorten delivery time;
3. When purchasing multiple orders, you can save shipping costs by binding orders;
5.3. Note in PCB Layout:
1. Routing should be at right angles first, and obtuse angles or arcs are mainly used where turns are required;
2. Add silk screen logos and annotate the interface functions;
3. JLCJLCJLCJLC designated customer silk screen can be hidden under the device, making the board beautiful;

Figure 5-1 PCB layout reference

Figure 5-2 PCB routing reference Figure
5.4. Note in welding:
1. When welding, you can click the welding auxiliary tool in the toolbar of Jiali Chuang EDA, and interact in real time to facilitate welding;
2. When welding the top layer, it is recommended to weld the main control chip first to avoid other devices affecting welding;
3. When welding the pin header, you can use an empty board or a perforated board to support it to prevent slanted welding and affect use;
4. The welding sequence should follow the principle of from low to high to avoid affecting the welding of small components;

Figure 6-3 PCB empty board - top layer

Figure 6-4 PCB empty board - bottom layer
5.5. Attention should be paid during debugging:
1. Before power-on debugging, check whether there are problems such as cold soldering and short circuit in welding. Only after checking that there are no problems can power on for testing;
2. Use the USB to TTL serial port burning tool to download the program to the microcontroller. The RXD end of the USB to TTL line is connected to the TXD end of the microcontroller, and the TXD end is connected to the RXD end of the microcontroller;