Application of special ports of HGI MCU [Notes]
[Copy link]
This application note mainly includes: RESET port multiplexing as I/O function; external crystal port multiplexing as I/O function; SWD programming port multiplexing as I/O function; UART programming port multiplexing as I/O function.
Note: - This application note is a supplementary application material for the HC32L110 / HC32F003 / HC32F005 series and cannot replace the user manual. Please refer to the user manual for specific functions, register operations and other related matters.
Function Introduction
GPIO is a general purpose input and output module. MCU can set an IO to analog mode as ADC input; set it to digital input and output, or peripheral port for specific peripherals. Before using the port function, you need to turn on the GPIO module clock control function.
The reusable special ports of this series of GPIOs include RESET, external crystal pins, SWD, UART programming interface, etc. Users need to choose different multiplexing methods according to the characteristics of these ports and application features in different applications.
Special port multiplexing function introduction
The RESET pin is multiplexed as an input port. When the external reset pin detects a low level, a system reset will be generated. The reset pin has a built-in pull-up resistor and an integrated glitch filter circuit.
The glitch filter circuit will filter out glitch signals less than 20uS (typical value), so the low-level signal added to the reset pin must be greater than 20uS to ensure reliable reset of the chip. The RESET pin can be reused as the input port P0.0.
If you want to use RESET as the input port P0.0, the reference process is as follows:
1. Enable the GPIO module clock control function: set PERI_CLKEN.GPIO to 1
2. RESET_USE_IO clock control bit of the system control register: SYSCTRL1. RES_UIO enable
Note: - When reusing the RESET pin as an input port, the design of the peripheral circuit must still be ensured. When power is turned on, the pin must not be at a low level (Low-Level), otherwise the program cannot run.
- This port has a built-in pull-up resistor, so even if this pin is used as an input port, it can only be used as an "input port with pull-up function".
External crystal port multiplexed as I/O port
When an external high-speed crystal or low-speed crystal is not used, the following ports can be multiplexed as I/O functions.
X32MOUT P0.1
X32MIN P0.2
X32KOUT P1.5
X32KIN P1.4
The multiplexing I/O function flow is as follows:
1. Enable the GPIO module clock control function: set PERI_CLKEN.GPIO to 1.
2. P0.1 and P0.2, P1.5 and P1.4 need to be configured as digital ports: the relevant bits of P0ADS and P1ADS are configured to 0.
3. Select the GPIO function in the function configuration register: set P01_SEL, P02_SEL, P15_SEL, and P14_SEL to 0.
4. Select the input and output direction: Set the relevant bits of P00DIR and P1DIR (0: output, 1: input)
SWD debugging programming port multiplexed as I/O function
SWD port is used as the debugging and download port of this series of MCUs. Users can choose whether to reserve this port for debugging or mass production programming according to actual needs. If you do not need to use the SWD port for debugging programming, SWCLK and SWDIO pins can be multiplexed as I/O pins. The
reference process for multiplexing I/O functions is as follows:
1. Enable the GPIO module clock control function: set PERI_CLKEN.GPIO to 1
2. Enable the SWD_USE_IO clock control bit of the system control register (SYSCTRL1. SWD_UIO)
3. Set P27_SEL.SEL and P31_SEL.SEL to 0
4. P2DIR.P27 and P3DIR.P31 are set as input or output
Note: - From power-on to the time when SWD is multiplexed and configured as an I/O port, the levels of the P27 and P31 pins are high by default. Therefore, you should pay attention to and avoid this in the design of peripheral circuits.
- When the SWD port is multiplexed as an I/O function, the online debugging and downloading functions through SWD will become invalid.
- When debugging, you can restore the SWD online debugging and downloading functions by erasing or downloading other programs that do not reuse SWD through the serial port, or add a few seconds of delay before reusing the SWD port in the application.
UART offline programming port multiplexed as I/O port
This series of MCU uses UART port P3.5 (TX) and P3.6 (RX) as offline programming function. Users can choose whether to reserve this port as the burning port for subsequent mass production download according to their needs in actual application.
To cooperate with our offline programmer to enter the download mode, the P3.5 (TX) port will output a high-level pulse of about 10ms as a handshake signal when the MCU is powered on. When the application needs to use this port (P3.5) as an output function, the hardware circuit should consider avoiding the impact of this pulse on the entire application, or try to avoid using this port as an output function.
Through the above introduction, combined with the user manual of the HC32L110 / HC32F003 / HC32F005 series, we can understand the methods and precautions of using the special ports of this series of MCUs, such as the Reset pin, external crystal pin, SWD pin, and UART download port, as I/O pins in applications.
|