GD32E50x User Manual Table of Contents Table of Contents......................... 2 List of Figures ........................21 List of Tables ........................31 1. System and me mory architecture ................36 1.1. ® Cortex ® -M33 processor.................. 36 1.2. System architecture ....................37 1.3.
Page 18
GD32E50x User Manual 27.4.20. MAC address 3 high register (ENET_MAC_ADDR3H) ..........1091 27.4.21. MAC address 3 low register (ENET_MAC_ADDR3L) ..........1092 27.4.22. MAC flow control threshold register (ENET_MAC_FCTH)......... 1092 27.4.23. MSC control register (ENET_MSC_CTL) ............... 1093 27.4.24. MSC receive interrupt flag register (ENET_MSC_RINTF) ......... 1094 27.4.25.
Page 19
GD32E50x User Manual 28.2. Main features ....................1124 28.3. Block diagram ....................1125 28.4. Signal description .................... 1125 28.5. Clock configuration ..................1125 28.6. Function overview ................... 1126 28.6.1. USB endpoints....................1126 28.6.2. Operation procedure................... 1129 28.6.3. USB events and interrupts ................... 1131 28.6.4.
Page 20
GD32E50x User Manual 29.7. Register definition ................... 1167 29.7.1. USBHS global registers..................1167 29.7.2. Host control and status registers................1196 29.7.3. Device control and status registers ............... 1210 29.7.4. Power and clock control register (USBHS_PWRCLKCTL) ........1239 Appendix ....................... 1241 List of abbreviations used in register .............
GD32E50x User Manual List of Figures ® Figure 1-1. The structure of the Cortex -M33 processor ...........37 Figure 1-2. GD32E50x system architecture ...............39 Figure 2-1. Process of page erase operation ..............51 Figure 2-2. Process of mass erase operation..............52 Figure 2-3. Process of word program operation..............54 Figure 4-1.
Page 22
GD32E50x User Manual Figure 13-7. Discontinuous operation mode ..............283 Figure 13-8. 12-bit data storage mode ................284 Figure 13-9. 6-bit data storage mode ................285 Figure 13-10. 20-bit to 16-bit re sult truncation ..............288 Figure 13-11. Numerical example with 5-bits shift and rounding........288 Figure 13-12.
Page 23
GD32E50x User Manual Figure 18-23. Hall sensor timing between two timers............378 Figure 18-24. Restart mode..................... 379 Figure 18-25. Pause mode ....................380 Figure 18-26. Event mode ....................380 Figure 18-27. Single pulse mode, TIMERx_CHxCV = 4, TIMERx_CAR=99 ......381 Figure 18-28.
Page 24
GD32E50x User Manual Figure 18-67. Basic timer block diagram................. 500 Figure 18-68. Timing chart of internal clock divided by 1 ..........501 Figure 18-69. Timing chart of PSC value change from 0 to 2........... 501 Figure 18-70. Timing chart of up counting mode, PSC=0/2 ..........502 Figure 18-71.
GD32E50x User Manual List of Tables Table 1-1. The interconnection relationship of the AHB interconnect matrix ....37 Table 1-2. Memory map of GD32E50x devices ..............40 Table 1-3. Boot modes......................44 Table 2-1. GD32E50x_HD and GD32E50x_CL base address and size for flash memory ..47 Table 2-2.
Page 32
GD32E50x User Manual Table 13-1. ADC internal input signals................277 Table 13-2. ADC input pins definition ................277 Table 13-3. External trigger source for ADC0 and ADC1 ..........285 Table 13-4. External trigger source for ADC2 ..............285 timings depending on resolution............287 Table 13-5.
Page 33
GD32E50x User Manual semiconductors) ..................... 750 Table 21-2. Event status flags ..................764 Table 21-3. Error flags ....................765 Table 21-4. Definition of I2C-bus terminology (refer to the I2C specification of Philips semiconductors) ..................... 781 Table 21-5. Data setup time and data hold time............... 786 Table 21-6.
Page 34
GD32E50x User Manual Table 24-25. Performance move field ................904 Table 24-26. AU_SIZE field ....................905 Table 24-27. Maximum AU size ..................905 Table 24-28. Erase size field ................... 905 Table 24-29. Erase timeout field ..................906 Table 24-30. Erase offset field..................906 Table 24-31.
Page 35
GD32E50x User Manual Table 28-6. Endpoint kind meaning ................1140 Table 28-7. Transmission status encoding ..............1141 Table 29-1. USBHS signal description ................1145 Table 29-2. USBHS supported speeds ................1146 Table 29-3. USBHS global interrupt ................1165 Table 30-1. List of abbreviations used in register ............1241 Table 30-2.
GD32E50x User Manual System and memory architecture The devices of GD32E50x series are 32-bit general-purpose microcontrollers based on the ® ® ® ® Cortex -M33 processor. The Arm Cortex -M33 processor includes two AHB buses ® ® known as Code and System buses. All memory accesses of the Arm Cortex -M33 processor are executed on these two buses according to the different purposes and the target memory...
GD32E50x User Manual ® Figure 1-1. The structure of the Cortex -M33 processor Cortex-M33 processor Cortex-M33 core Nested Interrupts Vectored Floating Point Interrupt Unit(FPU) Controller (NVIC) DSP Extension Data Breakpoint Memory Watchpoint Unit Protection And Trace (BPU) Unit(MPU) (DWT) Serial-Wire Or JTAG Instrumentation Trace Port...
Page 38
GD32E50x User Manual CBUS SBUS DMA0 DMA1 ENET OTGHS APB1 APB2 As is shown above, there are several masters connected with the AHB interconnect matrix, including CBUS, SBUS, DMA0, DMA1, ENET and OTGHS. CBUS is the code bus of the Cortex®-M33 core, which is used for any instruction fetch and data access to the Code region.
GD32E50x User Manual ® Additionally, a pre-defined memory map is provided by the Cortex -M33 processor to reduce the software complexity of repeated implementation of different device vendors. In the map, ® ® some regions are used by the Arm Cortex -M33 system peripherals which can not be modified.
GD32E50x User Manual Kbytes are called High-density devices (GD32E50x_HD). GD32E505xx and GD32E507xx microcontrollers are called connectivity line devices (GD32E50x_CL). Refer to Flash memory controller (FMC) Chapter for more details. Boot configuration 1.4. The GD32E50x devices provide three kinds of boot sources which can be selected by the BOOT0 and BOOT1 pins.
GD32E50x User Manual Memory density information 1.5.1. Base address: 0x1FFF F7E0 The value is factory programmed and can never be altered by user. SRAM_DENSITY[15:0] FLASH_DENSITY[15:0] Bits Fields Descriptions 31:16 SRAM_DENSITY SRAM density [15:0] The value indicates the on-chip SRAM density of the device in Kbytes. Example: 0x0080 indicates 128 Kbytes.
GD32E50x User Manual Bits Fields Descriptions 31:0 UNIQUE_ID[63:32] Unique device ID Base address: 0x1FFF F7F0 The value is factory programmed and can never be altered by user. UNIQUE_ID[95:80] UNIQUE_ID[79:64] Bits Fields Descriptions 31:0 UNIQUE_ID[95:64] Unique device ID System configuration registers 1.6.
GD32E50x User Manual Flash memory controller (FMC) Overview 2.1. The flash memory controller, FMC, provides all the necessary functions for the on-chip flash memory. A little waiting time is needed while CPU executes instructions stored from the 512K bytes of the flash. It also provides page erase, mass erase, and program operations for flash memory.
GD32E50x User Manual Block Nam e Address range Size(bytes) Information GD32E50x_HD 0x1FFF E000- 0x1FFF F7FF Boot loader area block GD32E50x_CL 0x1FFF B000- 0x1FFF F7FF 18KB Option bytes block Option bytes 0x1FFF F800 - 0x1FFF F80F One-time program block OTP bytes 0x1FFF_7000~0x1FFF_77FF Note: The information block stores the boot loader.
GD32E50x User Manual Current buffer: The current buffer is always enabled. Each time read from flash memory, 128-bit data get and store in current buffer. The CPU only need 32-bit or 16-bit in each read operation. So in the case of sequential code, the next data can get from current buffer without repeat fetch from flash memory.
GD32E50x User Manual operations to the FMC_KEY, will set the LK bit to 1, and lock the FMC_CTL register, and lead to a bus error. The OBPG bit and OBER bit in the FMC_CTL are still protected even the FMC_CTL is unlocked.
GD32E50x User Manual Figure 2-1. Process of page erase operation Start Is the LK bit is 0 Unlock the FMC_CTL Is the BUSY bit is 0 Set the PER bit, Write FMC_ADDR Send the command to FMC by set START bit Is the BUSY bit is 0 Finish Mass erase...
GD32E50x User Manual and an interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTL register is set. Since all flash data will be modified to a value of 0xFFFF_FFFF, the mass erase operation can be implemented using a program that runs in SRAM or using the debugging tool that accesses the FMC registers directly.
Page 53
GD32E50x User Manual Unlock the FMC_CTL register if necessary. Check the BUSY bit in the FMC_STAT register to confirm that no flash memory operation is in progress (BUSY equals to 0). Otherwise, wait until the operation has finished. ...
GD32E50x User Manual Figure 2-3. Process of word program operation Start Is the LK bit is 0 Unlock the FMC_CTL Is the BUSY bit is 0 Set the PG bit Perform word/half word write by DBUS Is the BUSY bit is 0 Finish Note: Reading the flash should be avoided when a program/erase operation is ongoing in the same bank.
GD32E50x User Manual Unlock the option bytes operation bits in the FMC_CTL register if necessary. Wait until the OBWEN bit is set in the FMC_CTL register. Set the OBER bit in the FMC_CTL register. Send the option bytes erase command to the FMC by setting the START bit in the FMC_CTL register.
GD32E50x User Manual Table 2-3. Option bytes Address Nam e Description option bytes security protection value 0xA5 : no security protection 0x1fff f800 any value except 0xA5 or 0xCC : protection level low 0xCC : protection level high 0x1fff f801 SPC_N SPC complement value [7:6]: BOR_TH (Brow n out reset threshold)
GD32E50x User Manual Page erase / program protection 2.3.11. The FMC provides page erase/program protection functions to prevent inadvertent operations on the flash memory. The page erase or program will not be accepted by the FMC on protected pages. If the page erase or program command is sent to the FMC on a protected page, the WPERR bit in the FMC_STAT register will be set by the FMC.
GD32E50x User Manual Protection level high: when setting SPC byte to 0xCC, protection level high performed. When this level is programmed, debug mode, boot from SRAM or boot from boot loader mode are disabled. The main flash block is accessible by all operations from user code. The SPC byte cannot be reprogrammed.
GD32E50x User Manual 1: Pre-fetch enable Reserved Must be kept at reset value. WSCNT[2:0] Wait state counter register These bits is set and reset by softw are. 000: 0 w ait state added 001: 1 w ait state added 010: 2 w ait state added 011: 3 w ait state added 100: 4 w ait state added 101 ~111: reserved...
GD32E50x User Manual Bits Fields Descriptions 31:0 OBKEY[31:0] FMC_CTL option bytes operation unlock register These bits are only be w ritten by softw are. Write OBKEY[31:0] w ith keys to unlock option bytes command in the FMC_CTL register. Status register (FMC_STAT) 2.4.4.
GD32E50x User Manual Control register (FMC_CTL) 2.4.5. Address offset: 0x10 Reset value: 0x0000 0080 This register has to be accessed by word (32-bit) Reserved Reserved ENDIE Reserved ERRIE OBWEN Reserved START OBER OBPG Reserved Bits Fields Descriptions 31:13 Reserved Must be kept at reset value. ENDIE End of operation interrupt enable bit This bit is set or cleared by softw are...
GD32E50x User Manual This bit is set or clear by softw are 0: no effect 1: option bytes program command Reserved Must be kept at reset value. Main flash mass erase command bit This bit is set or cleared by softw are 0: no effect 1: main flash mass erase command Main flash page erase command bit...
GD32E50x User Manual Reserved DATA[15:6] DATA[5:0] USER[7:0] OBERR Bits Fields Descriptions 31:26 Reserved Must be kept at reset value. 25:10 DATA[15:0] Store DATA[15:0] of option bytes block after system reset. USER[7:0] Store USER of option bytes block after system reset. Option bytes security protection code 0: no protection 1: protection...
Page 64
GD32E50x User Manual PID[31:16] PID[15:0] Bits Field Descriptions 31:0 PID[31:0] Product reserved ID code register These bits are read only by softw are. These bits are unchanged constant after pow er on. These bits are one time program w hen the chip produced.
GD32E50x User Manual Backup registers (BKP) Overview 3.1. The Backup registers are located in the Backup domain that remains powered-on by V even if V power is shut down, they are forty two 16-bit (84 bytes) registers for data protection of user application data, and the wake-up action from Standby mode or system reset do not affect these registers.
Page 66
GD32E50x User Manual and it can be independently enabled on TAMPER pin by setting corresponding TPEN bit in the BKP_TPCTL register. To prevent the tamper event from losing, the edge detection is logically ANDed with the TPEN bit, used for tamper detection signal. So the tamper detection configuration should be set before enable TAMPER pin.
GD32E50x User Manual Register definition 3.4. BKP base address: 0x4000 6C00 Backup data register x (BKP_DATAx) (x= 0..41) 3.4.1. Address offset: 0x04 to 0x28, 0x40 to 0xBC Reset value: 0x0000 This register can be accessed by half-word (16-bit) or word (32-bit). DATA [15:0] Bits Fields...
GD32E50x User Manual 0: RTC alarm pulse is selected as the RTC output 1: RTC second pulse is selected as the RTC output This bit is reset only by a Backup domain reset. ASOEN RTC alarm or second signal output enable 0: Disable RTC alarm or second output 1: Enable RTC alarm or second output When enable, the TAMPER pin w ill output the RTC output.
GD32E50x User Manual Tamper control and status register (BKP_TPCS) 3.4.4. Address offset: 0x34 Reset value: 0x0000 This register can be accessed by half-word (16-bit) or word (32-bit). Reserved Reserved TPIE Bits Fields Descriptions 15:10 Reserved Must be kept at reset value. Tamper interrupt flag 0: No tamper interrupt occurred 1: A tamper interrupt occurred...
GD32E50x User Manual Power management unit (PMU) Overview 4.1. The power consumption is regarded as one of the most important issues for the devices of GD32E50x series. According to the Power management unit (PMU), provides five types of power saving modes, including Sleep, Deep-sleep, Deep-sleep 1, Deep-sleep 2 and Standby mode.
GD32E50x User Manual time, the RTC alarm will wake up the device when the time match event occurs. The details of the RTC configuration and operation will be described in the Real-time clock (RTC). When the Backup domain is supplied by V pin is connected to V ), the following functions are available:...
GD32E50x User Manual Figure 4-2. Waveform of the POR / PDR 40mV hyst RSTTEMPO Power Reset (Active Low) The BOR circuit is used to detect V and generate the power reset signal which resets the whole chip except the Backup domain when the BOR_TH bits in option bytes is not 0b11 and the supply voltage is lower than the specified threshold which defined in the BOR_TH bits in option bytes.
GD32E50x User Manual domain The LVD is used to detect whether the V supply voltage is lower than a programmed threshold selected by the LVDT[2:0] bits in the Power control register(PMU_CTL0). The LVD is enabled by setting the LVDEN bit, and LVDF bit, which in the Power status register(PMU_CS0), indicates if V is higher or lower than the LVD threshold.
GD32E50x User Manual 1.1V power domain 4.3.3. ® The main functions that include Cortex -M33 logic, AHB/APB peripherals, the APB interfaces for the Backup domain and the V domain, etc, are located in this power domain. Once the 1.1V is powered up, the POR will generate a reset sequence on the 1.1V power domain. If need to enter the expected power saving mode, the associated control bits must be configured.
Page 76
GD32E50x User Manual ® According to the SLEEPONEXIT bit in the Cortex -M33 System Control Register, there are two options to select the Sleep mode entry mechanism. Sleep-now: if the SLEEPONEXIT bit is cleared, the MCU enters Sleep mode as soon as WFI or WFE instruction is executed.
Page 77
GD32E50x User Manual If not, the program will skip the entry process of Deep-sleep mode to continue to execute the following procedure. Deep-sleep 1 mode ® The Deep-sleep 1 mode is based on the SLEEPDEEP mode of the Cortex -M33. In Deep- sleep 1 mode, all clocks in the 1.1V domain are off, and all of IRC8M, IRC48M, HXTAL and PLLs are disabled.
GD32E50x User Manual system, refer to Cortex -M33 Technical Reference Manual). Waking up from Deep-sleep 2 ® mode needs an additional delay to power on COREOFF0/COREOFF1 domain. Notice that an additional wakeup delay will be incurred if the LDO operates in low power mode. The low-driver mode in Deep-sleep 2 mode can be entered by configuring the LDEN, LDNP , LDLP, LDOLP bits in the PMU_CTL0 register.
Page 79
GD32E50x User Manual Mode Sleep Deep-sleep Deep-sleep 1 Deep-sleep 2 Standby Entry WFI or WFE WFI or WFE WFI or WFE WFI or WFE WFI or WFE NRST Any interrupt for Any interrupt from EXTI Any interrupt from EXTI Any interrupt from lines for WFI lines for WFI EXTI lines for WFI...
GD32E50x User Manual Register definition 4.4. PMU base address: 0x4000 7000 Control register 0 (PMU_CTL0) 4.4.1. Address offset: 0x00 Reset value: 0x0000 C000 (reset by wakeup from Standby mode) This register can be accessed by half-word(16-bit) or word(32-bit). LDEN[1:0] Reserved HDEN Reserved LDNP...
Page 81
GD32E50x User Manual 1: Low -driver mode enabled w hen LDEN is 11 and use normal pow er LDO LDLP Low -driver mode w hen use low pow er LDO. 0: normal driver w hen use low pow er LDO 1: Low -driver mode enabled w hen LDEN is 11 and use low pow er LDO Reserved Must be kept at reset value.
GD32E50x User Manual Note: Some peripherals may w ork w ith the IRC8M clock in the Deep-sleep / Deep- sleep 1 / Deep-sleep 2 mode. In this case, the LDO automatically sw itches from the low pow er mode to the normal mode and remains in this mode until the peripheral stop w orking.
Page 83
GD32E50x User Manual Reserved Must be kept at reset value. WUPEN5 WKUP Pin5(PB5) Enable 0: Disable WKUP pin5 function 1: Enable WKUP pin5 function If WUPEN5 is set before entering the pow er saving mode, a rising edge on the WKUP pin5 w akes up the system from the pow er saving mode.
GD32E50x User Manual And set this bit w ill trigger a w akup event w hen the input is aready high. WUPEN6 WKUP Pin6(PB15) Enable 0: Disable WKUP pin6 function 1: Enable WKUP pin6 function If WUPEN6 is set before entering the pow er saving mode, a rising edge on the WKUP pin6 w akes up the system from the pow er saving mode.
GD32E50x User Manual DPMOD2 Deep-sleep 2 mode enable 0: Not care SLEEPDEEP bit is set and the STBMOD bit 1:Go to Deep-sleep 2 mode w hen is clear DPMOD1 Deep-sleep 1 mode enable 0: Not care the SLEEPDEEP bit is set and the STBMOD 1:Go to Deep-sleep 1 mode w hen bit is clear and the DPMOD2 bit is clear Control and status register 1 (PMU_CS1)
GD32E50x User Manual Reset and clock unit (RCU) High density reset and clock control unit (RCU) Reset control unit (RCTL) 5.1. Overview 5.1.1. GD32E50x reset control includes the control of three kinds of reset: power reset, system reset and backup domain reset. The power reset, known as a cold reset, resets the full system except the backup domain.
GD32E50x User Manual A system reset resets the processor core and peripheral IP components except for the SW- DP controller and the backup domain. A system reset pulse generator guarantees low level pulse duration of 20 μs for each reset source (external or internal reset).
GD32E50x User Manual The SDIO, EXMC are clocked by the clock of CK_AHB. The TIMERs are clocked by the clock divided from CK_APB2 and CK_APB1. The frequency of TIMERs clock is equal to CK_APBx(APB prescaler is 1), twice the CK_APBx(APB prescaler is not 1).
GD32E50x User Manual Figure 5-3. HXTAL clock source The HXTAL crystal oscillator can be switched on or off using the HXTALEN bit in the control register RCU_CTL. The HXTALSTB flag in control register RCU_CTL indicates if the high- speed external crystal oscillator is stable. When the HXTAL is powered up, it will not be released for use until this HXTALSTB bit is set by the hardware.
Page 91
GD32E50x User Manual The frequency accuracy of the IRC8M can be calibrated by the manufacturer, but its operating frequency is still less accurate than HXTAL. The application requirements, environment and cost will determine which oscillator type is selected. If the HXTAL or PLL is the system clock source, to minimize the time required for the system to recover from the Deep-sleep Mode, the hardware forces the IRC8M clock to be the system clock when the system initially wakes-up.
Page 92
GD32E50x User Manual drives the OSC32IN pin. Internal 40K RC oscillator (IRC40K) The internal RC oscillator has a frequency of about 40 kHz and is a low power clock source for the real time clock circuit or the rree watchdog timer. The IRC40K offers a low cost clock source as no external components are required.
GD32E50x User Manual Table 5-1. Clock output 0 source select Clock source 0 selection bits Clock source NO CLK CK_SYS CK_IRC8M CK_HXTAL CK_PLL/2 Voltage control The 1.1V domain voltage in Deep-sleep mode can be controlled by DSLPVS[2:0] bit in the Deep-sleep mode voltage register (RCU_DSV).
GD32E50x User Manual Register definition 5.3. RCU base address: 0x4002 1000 Control register (RCU_CTL) 5.3.1. Address offset: 0x00 Reset value: 0x0000 XX83 where X is undefined. This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). HXTALB HXTALST HXTALE Reserved PLLSTB Reserved CKMEN...
GD32E50x User Manual HXTALBPS High speed crystal oscillator (HXTAL) clock bypass mode enable The HXTALBPS bit can be w ritten only if the HXTALEN is 0. 0: Disable the HXTAL Bypass mode 1: Enable the HXTAL Bypass mode in w hich the HXTAL output clock is equal to the input clock.
Page 96
GD32E50x User Manual USBDPS ADCPSC[ PLLMF[5] Reserved PLLMF[4] CKOUT0SEL[2:0] USBDPSC[1:0] PLLMF[3:0] PREDV0 PLLSEL C[2] ADCPSC[1:0] APB2PSC[2:0] APB1PSC[2:0] AHBPSC[3:0] SCSS[1:0] SCS[1:0] Bits Fields Descriptions USBDPSC[2] Bit 2 of USBDPSC see bits 23:22 of RCU_CFG0 PLLMF[5] Bit 5 of PLLMF see bits 21:18 of RCU_CFG0 Reserved Must be kept at reset value.
Page 97
GD32E50x User Manual 000010: CK_SYS = CK_PLL x 4 000011: CK_SYS = CK_PLL x 5 000100: CK_SYS = CK_PLL x 6 000101: CK_SYS = CK_PLL x 7 000110: CK_SYS = CK_PLL x 8 000111: CK_SYS = CK_PLL x 9 001000: CK_SYS = CK_PLL x 10 001001: CK_SYS = CK_PLL x 11 001010: CK_SYS = CK_PLL x 12 001011: CK_SYS = CK_PLL x 13...
Page 98
GD32E50x User Manual clock of PLL 15:14 ADCPSC[1:0] ADC clock prescaler selection These bits, bit 28 of RCU_CFG0 and bit 29 of RCU_CFG1 are w ritten by softw are to define the ADC prescaler factor.Set and cleared by softw are. 0000: (CK_APB2 / 2) selected 0001: (CK_APB2 / 4) selected 0010: (CK_APB2 / 6) selected...
GD32E50x User Manual SCSS[1:0] System clock sw itch status Set and reset by hardw are to indicate the clock source of system clock. 00: Select CK_IRC8M as the CK_SYS source 01: Select CK_HXTAL as the CK_SYS source 10: Select CK_PLL as the CK_SYS source 11: Reserved SCS[1:0] System clock sw itch...
Page 100
GD32E50x User Manual 1: Reset PLLSTBIF flag HXTALSTBIC HXTAL stabilization interrupt clear Write 1 by softw are to reset the HXTALSTBIF flag. 0: Not reset HXTALSTBIF flag 1: Reset HXTALSTBIF flag IRC8MSTBIC IRC8M stabilization interrupt clear Write 1 by softw are to reset the IRC8MSTBIF flag. 0: Not reset IRC8MSTBIF flag 1: Reset IRC8MSTBIF flag LXTALSTBIC...
GD32E50x User Manual CKMIF HXTAL clock stuck interrupt flag Set by hardw are w hen the HXTAL clock is stuck. Reset w hen setting the CKMIC bit by softw are. 0: Clock operating normally 1: HXTAL clock stuck Reserved Must be kept at reset value. PLLSTBIF PLL stabilization interrupt flag Set by hardw are w hen the PLL is stable and the PLLSTBIE bit is set.
Page 102
GD32E50x User Manual This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). SHRTIME USART5 TIMER10 TIMER9 TIMER8 Reserved Reserved Reserved ADC2RS USART0 TIMER7R TIMER0R ADC1RS ADC0RS SPI0RST PGRST PFRST PERST PDRST PCRST PBRST PARST Reserved AFRST Bits Fields Descriptions 31:30 Reserved Must be kept at reset value.
Page 103
GD32E50x User Manual 0: No reset 1: Reset the USART0 TIMER7RST Timer 7 reset This bit is set and reset by softw are. 0: No reset 1: Reset the TIMER7 SPI0RST SPI0 reset This bit is set and reset by softw are. 0: No reset 1: Reset the SPI0 TIMER0RST...
GD32E50x User Manual This bit is set and reset by softw are. 0: No reset 1: Reset the GPIO port C PBRST GPIO port B reset This bit is set and reset by softw are. 0: No reset 1: Reset the GPIO port B PARST GPIO port A reset This bit is set and reset by softw are.
Page 105
GD32E50x User Manual 1: Reset pow er control unit BKPIRST Backup interface reset This bit is set and reset by softw are. 0: No reset 1: Reset backup interface CAN1RST CAN1 reset This bit is set and reset by softw are. 0: No reset 1: Reset the CAN1 CAN0RST...
Page 106
GD32E50x User Manual 0: No reset 1: Reset the USART2 USART1RST USART1 reset This bit is set and reset by softw are. 0: No reset 1: Reset the USART1 Reserved Must be kept at reset value. SPI2RST SPI2 reset This bit is set and reset by softw are. 0: No reset 1: Reset the SPI2 SPI1RST...
GD32E50x User Manual This bit is set and reset by softw are. 0: No reset 1: Reset the TIMER5 TIMER4RST TIMER4 reset This bit is set and reset by softw are. 0: No reset 1: Reset the TIMER4 TIMER3RST TIMER3 reset This bit is set and reset by softw are.
GD32E50x User Manual This bit is set and reset by softw are. 0: Disabled SDIO clock 1: Enabled SDIO clock Reserved Must be kept at reset value. EXMCEN EXMC clock enable This bit is set and reset by softw are. 0: Disabled EXMC clock 1: Enabled EXMC clock Reserved...
Page 109
GD32E50x User Manual SHRTIME USART5 TIMER10 TIMER9E TIMER8E Reserved Reserved Reserved USART0 TIMER7E TIMER0E ADC2EN SPI0EN ADC1EN ADC0EN PGEN PFEN PEEN PDEN PCEN PBEN PAEN Reserved AFEN Bits Fields Descriptions 31:30 Reserved Must be kept at reset value SHRTIMEREN SHRTIMER clock enable This bit is set and reset by softw are.
Page 110
GD32E50x User Manual 0: Disabled USART0 clock 1: Enabled USART0 clock TIMER7EN TIMER7 clock enable This bit is set and reset by softw are. 0: Disabled TIMER7 clock 1: Enabled TIMER7 clock SPI0EN SPI0 clock enable This bit is set and reset by softw are. 0: Disabled SPI0 clock 1: Enabled SPI0 clock TIMER0EN...
GD32E50x User Manual This bit is set and reset by softw are. 0: Disabled GPIO port C clock 1: Enabled GPIO port C clock PBEN GPIO port B clock enable This bit is set and reset by softw are. 0: Disabled GPIO port B clock 1: Enabled GPIO port B clock PAEN GPIO port A clock enable...
Page 112
GD32E50x User Manual 1: Enabled PMU clock BKPIEN Backup interface clock enable This bit is set and reset by softw are. 0: Disabled backup interface clock 1: Enabled backup interface clock CAN1EN clock enable This bit is set and reset by softw are. 0: Disabled CAN clock 1: Enabled CAN1 clock...
Page 113
GD32E50x User Manual 0: Disabled USART2 clock 1: Enabled USART2 clock USART1EN USART1 clock enable This bit is set and reset by softw are. 0: Disabled USART1 clock 1: Enabled USART1 clock Reserved Must be kept at reset value. SPI2EN SPI2 clock enable This bit is set and reset by softw are.
GD32E50x User Manual This bit is set and reset by softw are. 0: Disabled TIMER5 clock 1: Enabled TIMER5 clock TIMER4EN TIMER4 clock enable This bit is set and reset by softw are. 0: Disabled TIMER4 clock 1: Enabled TIMER4 clock TIMER3EN TIMER3 clock enable This bit is set and reset by softw are.
GD32E50x User Manual 0: No reset 1: Resets backup domain RTCEN RTC clock enable This bit is set and reset by softw are. 0: Disabled RTC clock 1: Enabled RTC clock 14:10 Reserved Must be kept at reset value. RTCSRC[1:0] RTC clock entry selection Set and reset by softw are to control the RTC clock source.
Page 116
GD32E50x User Manual reset by system reset. This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). WWDGT FWDGT BORRSTF RSTFC Reserved RSTF RSTF RSTF RSTF RSTF RSTF IRC40K Reserved IRC40KEN Bits Fields Descriptions LPRSTF Low -pow er reset flag Set by hardw are w hen Deep-sleep /standby reset generated.
GD32E50x User Manual 0: No external pin reset generated 1: External pin reset generated BORRSTF BOR reset flag Set by hardw are w hen a BOR reset generated. Reset by w riting 1 to the RSTFC bit. 0: No BOR reset generated 1: BOR reset generated RSTFC Reset flag clear...
GD32E50x User Manual 010: The core voltage is 0.8V in Deep-sleep mode 011: The core voltage is 0.7V in Deep-sleep mode 1xx: Reserved Additional clock control register (RCU_ADDCTL) 5.3.14. Address offset: 0xC0 Reset value: 0x8000 0000 This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). IRC48MS IRC48ME IRC48MCALIB[7:0]...
GD32E50x User Manual The spread spectrum modulation is available only for the main PLL clock The RCU_PLLSSCTL register must be written when the main PLL is disabled This register is used to configure the PLL spread spectrum clock generation according to the following formulas: MODCNT = round(f /4/f...
GD32E50x User Manual Bits Fields Descriptions 31:6 Reserved Must be kept at reset value. I2C2SEL[1:0] I2C2 Clock Source Selection Set and reset by softw are to control the I2C2 clock source. 00: APB1 clock selected as I2C2 source clock 01: System clock selected as I2C2 source clock 1x: CK_IRC8M clock selected as I2C2 source clock Reserved Must be kept at reset value.
Page 123
GD32E50x User Manual Reset value: 0x0000 0000 This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). Reserved Reserved Reserved Bits Fields Descriptions 31:28 Reserved Must be kept at reset value. CTCEN CTC clock enable This bit is set and reset by softw are. 0: Disabled CTC clock 1: Enabled CTC clock 26:0...
GD32E50x User Manual Connectivity line devices: reset and clock control unit (RCU) Reset control unit (RCTL) 5.4. Overview 5.4.1. GD32E50x reset control includes the control of three kinds of reset: power reset, system reset and backup domain reset. The power reset, known as a cold reset, resets the full system except the backup domain.
GD32E50x User Manual source (external or internal reset). Figure 5-5. The system reset circuit Backup domain reset A backup domain reset is generated by setting the BKPRST bit in the backup domain control register or backup domain power on reset (V or V power on, if both supplies have previously been powered off).
GD32E50x User Manual The I2C2 is clocked by IRC8M clock or system clock or APB1 clock, which selected by I2C2SEL bits in configuration register 2 (RCU_CFG2). The TIMERs are clocked by the clock divided from CK_APB2 and CK_APB1. The frequency of TIMERs clock is equal to CK_APBx(APB prescaler is 1), twice the CK_APBx(APB prescaler is not 1).
GD32E50x User Manual Function overview 5.5.3. High speed crystal oscillator (HXTAL) The high speed external crystal oscillator (HXTAL), which has a frequency from 4 to 32 MHz, produces a highly accurate clock source for use as the system clock. A crystal with a specific frequency must be connected and located close to the two HXTAL pins.
Page 129
GD32E50x User Manual Internal 8M RC oscillators (IRC8M) The internal 8M RC oscillator, IRC8M, has a fixed frequency of 8 MHz and is the default clock source selection for the CPU when the device is powered up. The IRC8M oscillator provides a lower cost type clock source as no external components are required.
Page 130
GD32E50x User Manual can be generated if the related interrupt enable bit, PLL1STBIE, in the RCU_INT Register, is set as the PLL1 becomes stable. The PLL2 can be switched on or off by using the PLL2EN bit in the RCU_CTL register. The PLL2STB flag in the RCU_CTL register will indicate if the PLL2 clock is stable.
GD32E50x User Manual register 0, RCU_CFG0. When the SCS value is changed, the CK_SYS will continue to operate using the original clock source until the target clock source is stable. When a clock source is directly or indirectly (by PLL) used as the CK_SYS, it is not possible to stop it. HXTAL clock monitor (CKM) The HXTAL clock monitor function is enabled by the HXTAL clock monitor rnable bit, CKMEN, in the control register (RCU_CTL).
GD32E50x User Manual Register definition 5.6. RCU base address: 0x4002 1000 Control register (RCU_CTL) 5.6.1. Address offset: 0x00 Reset value: 0x0000 XX83 where X is undefined. This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). HXTALB HXTALST HXTALE Reserved PLL2STB PLL2EN PLL1STB PLL1EN PLLSTB Reserved...
Page 134
GD32E50x User Manual 0: PLL is not stable 1: PLL is stable PLLEN PLL enable Set and reset by softw are. This bit cannot be reset if the PLL clock is used as the system clock. Reset by hardw are w hen entering Deep-sleep or Standby mode. 0: PLL is sw itched off 1: PLL is sw itched on 23:20...
GD32E50x User Manual Reserved Must be kept at reset value. IRC8MSTB IRC8M internal 8MHz RC oscillator stabilization flag Set by hardw are to indicate if the IRC8M oscillator is stable and ready for use. 0: IRC8M oscillator is not stable 1: IRC8M oscillator is stable IRC8MEN Internal 8MHz RC oscillator enable...
Page 136
GD32E50x User Manual 1001: CK_PLL2 clock divided by 2 selected 1010: EXT1 selected, to provide the external clock for ENET 1011: CK_PLL2 clock selected 1100: CK_IRC48M clock selected 1101: (CK_IRC48M / 8) clock selected 1110: (CK_PLLUSB / 32) clock selected 23:22 USBHSPSC[1:0] USBHS clock prescaler selection...
Page 137
GD32E50x User Manual 010111: (PLL source clock x 24) 011000: (PLL source clock x 25) 011001: (PLL source clock x 26) 011010: (PLL source clock x 27) 011011: (PLL source clock x 28) 011100: (PLL source clock x 29) 011101: (PLL source clock x 30) 011110: (PLL source clock x 31) 011111: (PLL source clock x 32) 100000: (PLL source clock x 33)
GD32E50x User Manual 100: (CK_AHB / 2) selected 101: (CK_AHB / 4) selected 110: (CK_AHB / 8) selected 111: (CK_AHB / 16) selected 10:8 APB1PSC[2:0] APB1 prescaler selection Set and reset by softw are to control the APB1 clock division ratio. 0xx: CK_AHB selected 100: (CK_AHB / 2) selected 101: (CK_AHB / 4) selected...
Page 139
GD32E50x User Manual Reset value: 0x0000 0000 This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). PLL2 PLL1 HXTAL IRC8M LXTAL IRC40K Reserved CKMIC STBIC STBIC STBIC STBIC STBIC STBIC STBIC PLL2 PLL1 HXTAL IRC8M LXTAL IRC40K PLL2 PLL1 HXTAL IRC8M LXTAL...
Page 140
GD32E50x User Manual 0: Not reset LXTALSTBIF flag 1: Reset LXTALSTBIF flag IRC40KSTBIC IRC40K stabilization interrupt clear Write 1 by softw are to reset the IRC40KSTBIF flag. 0: Not reset IRC40KSTBIF flag 1: Reset IRC40KSTBIF flag Reserved Must be kept at reset value. PLL2STBIE PLL2 stabilization interrupt enable Set and reset by softw are to enable/disable the PLL2 stabilization interrupt.
Page 141
GD32E50x User Manual 1: HXTAL clock stuck PLL2STBIF PLL2 stabilization interrupt flag Set by hardw are w hen the PLL2 is stable and the PLL2STBIE bit is set. Reset w hen setting the PLL2STBIC bit by softw are. 0: No PLL2 stabilization interrupt generated 1: PLL2 stabilization interrupt generated PLL1STBIF PLL1 stabilization interrupt flag...
GD32E50x User Manual APB2 reset register (RCU_APB2RST) 5.6.4. Address offset: 0x0C Reset value: 0x0000 0000 This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). SHRTIME USART5 TIMER10 TIMER9 TIMER8 CMPRST Reserved Reserved Reserved RRST ADC2RS USART0 TIMER7R TIMER0R ADC1RS ADC0RS SPI0RST PGRST...
Page 143
GD32E50x User Manual 0: No reset 1: Reset the TIMER8 18:16 Reserved Must be kept at reset value. ADC2RST ADC2 reset This bit is set and reset by softw are. 0: No reset 1: Reset the ADC2 USART0RST USART0 Reset This bit is set and reset by softw are.
GD32E50x User Manual 1: Reset the GPIO port F PERST GPIO port E reset This bit is set and reset by softw are. 0: No reset 1: Reset the GPIO port E PDRST GPIO port D reset This bit is set and reset by softw are. 0: No reset 1: Reset the GPIO port D PCRST...
Page 145
GD32E50x User Manual Bits Fields Descriptions 31:30 Reserved Must be kept at reset value. DACRST DAC reset This bit is set and reset by softw are. 0: No reset 1: Reset DAC unit PMURST Pow er control reset This bit is set and reset by softw are. 0: No reset 1: Reset pow er control unit BKPIRST...
Page 146
GD32E50x User Manual 0: No reset 1: Reset the UART4 UART3RST UART3 reset This bit is set and reset by softw are. 0: No reset 1: Reset the UART3 USART2RST USART2 reset This bit is set and reset by softw are. 0: No reset 1: Reset the USART2 USART1RST...
GD32E50x User Manual This bit is set and reset by softw are. 0: No reset 1: Reset the TIMER11 TIMER6RST TIMER6 reset This bit is set and reset by softw are. 0: No reset 1: Reset the TIMER6 TIMER5RST TIMER5 reset This bit is set and reset by softw are.
Page 148
GD32E50x User Manual Bits Fields Descriptions SQPIEN SQPI clock enable This bit is set and reset by softw are. 0: Disabled SQPI clock 1: Enabled SQPI clock TMUEN TMUEN clock enable This bit is set and reset by softw are. 0: Disabled TMUEN clock 1: Enabled TMUEN clock 29:17...
GD32E50x User Manual CRCEN CRC clock enable This bit is set and reset by softw are. 0: Disabled CRC clock 1: Enabled CRC clock Reserved Must be kept at reset value. FMCSPEN FMC clock enable w hen sleep mode This bit is set and reset by softw are to enable/disable FMC clock during Sleep mode. 0: Disabled FMC clock during Sleep mode 1: Enabled FMC clock during Sleep mode Reserved...
Page 150
GD32E50x User Manual This bit is set and reset by softw are. 0: Disabled CMP clock 1: Enabled CMP clock Reserved Must be kept at reset value SHRTIMEREN SHRTIMER clock enable This bit is set and reset by softw are. 0: Disabled SHRTIMER clock 1: Enabled SHRTIMER clock USART5EN...
Page 151
GD32E50x User Manual SPI0EN SPI0 clock enable This bit is set and reset by softw are. 0: Disabled SPI0 clock 1: Enabled SPI0 clock TIMER0EN TIMER0 clock enable This bit is set and reset by softw are. 0: Disabled TIMER0 clock 1: Enabled TIMER0 clock ADC1EN ADC1 clock enable...
GD32E50x User Manual 1: Enabled GPIO port B clock PAEN GPIO port A clock enable This bit is set and reset by softw are. 0: Disabled GPIO port A clock 1: Enabled GPIO port A clock Reserved Must be kept at reset value. AFEN Alternate function IO clock enable This bit is set and reset by softw are.
Page 153
GD32E50x User Manual CAN1EN CAN1 clock enable This bit is set and reset by softw are. 0: Disabled CAN1 clock 1: Enabled CAN1 clock CAN0EN CAN0 clock enable This bit is set and reset by softw are. 0: Disabled CAN0 clock 1: Enabled CAN0 clock I2C2EN I2C2 clock enable...
Page 154
GD32E50x User Manual SPI2EN SPI2 clock enable This bit is set and reset by softw are. 0: Disabled SPI2 clock 1: Enabled SPI2 clock SPI1EN SPI1 clock enable This bit is set and reset by softw are. 0: Disabled SPI1 clock 1: Enabled SPI1 clock 13:12 Reserved...
GD32E50x User Manual TIMER3EN TIMER3 clock enable This bit is set and reset by softw are. 0: Disabled TIMER3 clock 1: Enabled TIMER3 clock TIMER2EN TIMER2 clock enable This bit is set and reset by softw are. 0: Disabled TIMER2 clock 1: Enabled TIMER2 clock TIMER1EN TIMER1 clock enable...
GD32E50x User Manual 14:10 Reserved Must be kept at reset value. RTCSRC[1:0] RTC clock entry selection Set and reset by softw are to control the RTC clock source. Once the RTC clock source has been selected, it cannot be changed anymore unless the Backup domain is reset.
Page 157
GD32E50x User Manual IRC40K IRC40KE Reserved Bits Fields Descriptions LPRSTF Low -pow er reset flag Set by hardw are w hen Deep-sleep /standby reset generated. Reset by w riting 1 to the RSTFC bit. 0: No Low -pow er management reset generated 1: Low -pow er management reset generated WWDGTRSTF Window w atchdog timer reset flag...
GD32E50x User Manual 1: BOR reset generated RSTFC Reset flag clear This bit is set by softw are to clear all reset flags. 0: Not clear reset flags 1: Clear reset flags 23:2 Reserved Must be kept at reset value. IRC40KSTB IRC40K stabilization flag Set by hardw are to indicate if the IRC40K output clock is stable and ready for use.
GD32E50x User Manual This bit is set and reset by softw are. 0: No reset 1: Reset the ENET Reserved Must be kept at reset value. USBHSRST USBHS reset This bit is set and reset by softw are. 0: No reset 1: Reset the USBHS 11:0 Reserved...
Page 160
GD32E50x User Manual I2S2SEL I2S2 clock source selection Set and reset by softw are to control the I2S2 clock source. 0: System clock selected as I2S2 source clock 1: (CK_PLL2 x 2) selected as I2S2 source clock I2S1SEL I2S1 clock source selection Set and reset by softw are to control the I2S1 clock source.
Page 161
GD32E50x User Manual 111111: (PLL2 source clock x 80) 11:8 PLL1MF[3:0] The PLL1 clock multiplication factor Set and reset by softw are. 00xx: Reserve 010x: Reserve 0110: (PLL1 source clock x 8) 0111: (PLL1 source clock x 9) 1000 :(PLL1 source clock x 10) 1001: (PLL1 source clock x 11) 1010: (PLL1 source clock x 12) 1011: (PLL1 source clock x 13)
GD32E50x User Manual 0100: PREDV0 input source clock divided by 5 0101: PREDV0 input source clock divided by 6 0110: PREDV0 input source clock divided by 7 0111: PREDV0 input source clock divided by 8 1000: PREDV0 input source clock divided by 9 1001: PREDV0 input source clock divided by 10 1010: PREDV0 input source clock divided by 11 1011: PREDV0 input source clock divided by 12...
Page 163
GD32E50x User Manual IRC48MS IRC48ME IRC48MCALIB[7:0] Reserved PLLUSBS PLLUSBE USBSWE USBHSS Reserved USBHSDV[2:0] CK48MSEL[1:0] Bits Fields Descriptions 31:24 IRC48MCALIB [7:0] Internal 48MHz RC oscillator calibration value register These bits are load automatically at pow er on. 23:18 Reserved Must be kept at reset value. IRC48MSTB Internal 48MHz RC oscillator clock stabilization flag Set by hardw are to indicate if the IRC48M oscillator is stable and ready for use.
GD32E50x User Manual USBHSSEL USBHS clock source selection Set and reset by softw are to control the USBHS clock source. 0: 48M clock selected as USBHS source clock 1: 60M clock selected as USBHS source clock CK48MSEL[1:0] USB 48M clock source selection 00: not effect (select PLL/USBPRE) 01: CK_IRC48M select as CK48M clock source 10: CK_PLLUSB/USBHSDV select as CK48M clock source...
GD32E50x User Manual 0: CK_ HXTAL selected as PLLUSB source clock 1: CK_IRC48M output clock selected as PLLUSB source clock 15:4 Reserved Must be kept at reset value. PLLUSBPREDV[3:0] PLLUSBPREDV division factor This bit is set and reset by softw are. 0000: Reserved 0001: PLLUSBPREDV input source clock divided by 1 0010: PLLUSBPREDV input source clock divided by 2...
GD32E50x User Manual 1: Reset PLLUSBSTBIF flag IRC48MSTBIC Internal 48 MHz RC oscillator Stabilization interrupt clear Write 1 by softw are to reset the IRC48MSTBIF flag. 0: Not reset IRC48MSTBIF flag 1: Reset IRC48MSTBIF flag 21:16 Reserved Must be kept at reset value. PLLUSBSTBIE PLLUSB stabilization interrupt enable Set and reset by softw are to enable/disable the PLLUSB stabilization interrupt...
GD32E50x User Manual Where f represents the PLL input clock frequency, f represents the spread spectrum PLLIN modulation frequency, mdamp represents the spread spectrum modulation amplitude expressed as a percentage, PLLN represents the PLL clock frequency multiplication factor. SSCGO SS_TYP MODSTEP[14:3] Reserved MODSTEP[2:0]...
GD32E50x User Manual 00: APB1 clock selected as I2C2 source clock 01: System clock selected as I2C2 source clock 1x: CK_IRC8M clock selected as I2C2 source clock Reserved Must be kept at reset value. USART5SEL[1:0] USART5 clock source selection Set and reset by softw are to control the USART5 clock source. 00: CK_APB2 selected as USART5 source clock 01: CK_SYS selected as USART5 source clock 10: CK_LXTAL selected as USART5 source clock...
Page 169
GD32E50x User Manual This register can be accessed by byte(8-bit), half-word(16-bit) and word(32-bit). CAN2EN Reserved Reserved Reserved Bits Fields Descriptions CAN2EN CAN2 enable This bit is set and reset by softw are. 0: Disabled CAN clock 1: Enabled CAN clock 30:28 Reserved Must be kept at reset value.
GD32E50x User Manual Clock trim controller (CTC) Overview 6.1. The Clock Trim Controller (CTC) is used to trim internal 48MHz RC oscillator (IRC48M) automatically by hardware. The CTC unit trim the frequency of the IRC48M based on an external accurate reference signal source. It can automatically adjust the trim value to provide a precise IRC48M clock.
GD32E50x User Manual and then up- counting to 128 x CKLIM (defined in CTC_CTL1 register), and then stop until next REF sync pulse detected. If any REF sync pulse detected, the current CTC trim counter value is captured to REFCAP in status register (CTC_STAT), and the counter direction is captured to REFDIR in status register (CTC_STAT).
GD32E50x User Manual If the AUTOTRIM bit in CTC_CTL0 register set, the TRIMVALUE in CTC_CTL0 register is not changed. CKLIM ≤ Counter < 3 x CKLIM when REF sync pulse is detected. The CKOKIF in CTC_STAT register set, and an interrupt generated if CKOKIE bit in CTC_CTL0 register is 1.
Page 174
GD32E50x User Manual The typical step size is 0.12%. Where the F is the frequency of correct clock (IRC48M), clock the F is the frequency of reference sync pulse.
GD32E50x User Manual Register definition 6.4. CTC base address: 0x4000 C800 Control register 0 (CTC_CTL0) 6.4.1. Address offset: 0x00 Reset value: 0x0000 2000 This register has to be accessed by word (32-bit) Reserved SWREF AUTO CKWARN Reserved TRIMVALUE[5:0] CNTEN Reserved EREFIE ERRIE CKOKIE TRIM...
GD32E50x User Manual 01: LXTAL clock selected 10: Reserved. 11: Reserved Reserved Must be kept at reset value. 26:24 REFPSC[2:0] Reference signal source prescaler These bits are set and cleared by softw are 000: Reference signal not divided 001: Reference signal divided by 2 010: Reference signal divided by 4 011: Reference signal divided by 8 100: Reference signal divided by 16...
Page 178
GD32E50x User Manual REFDIR CTC trim counter direction w hen reference sync pulse When a reference sync pulse occurred during the counter is w orking, the CTC trim counter direction is captured to REFDIR bit. 0: Up-counting 1: Dow n-counting 14:11 Reserved Must be kept at reset value.
GD32E50x User Manual 0 : No Error occur 1: An error occur CKWARNIF Clock trim w arning interrupt flag This bit is set by hardw are w hen a clock trim w arning occurred. If the CTC trim counter greater or equal to 3 x CKLIM and smaller to 128 x CKLIM w hen a reference sync pulse detected, this bit w ill be set.
Page 180
GD32E50x User Manual REFMISS and CKERR bits in CTC_STAT register. Write 0 is no effect. CKWARNIC CKWARNIF interrupt clear bit This bit is w ritten by softw are and read as 0. Write 1 to clear CKWARNIF bit in CTC_STAT register. Write 0 is no effect. CKOKIC CKOKIF interrupt clear bit This bit is w ritten by softw are and read as 0.
GD32E50x User Manual Interrupt/event controller (EXTI) Overview 7.1. ® Cortex -M33 integrates the Nested Vectored Interrupt Controller (NVIC) for efficient exception and interrupts processing. NVIC facilitates low-latency exception and interrupt handling and power management controls. It’s tightly coupled to the processer core. You can read the -M33 for more details about NVIC.
GD32E50x User Manual ® Table 7-1. NVIC exception types in Cortex -M33 Vector Exception type priority (a) Vector address Description num ber 0x0000_0000 Reserved Reset 0x0000_0004 Reset 0x0000_0008 Non maskable interrupt. HardFault 0x0000_000C All class of fault MemManage Programmable 0x0000_0010 Memory management Prefetch fault, memory access BusFault...
Page 183
GD32E50x User Manual Interrupt Vector Non-connectivity devices Connectivity devices Vector address num ber num ber interrupt description interrupt description interrupt interrupt DMA0 channel4 global DMA0 channel4 global IRQ 15 0x0000_007C interrupt interrupt DMA0 channel5 global DMA0 channel5 global IRQ 16 0x0000_0080 interrupt interrupt...
Page 184
GD32E50x User Manual Interrupt Vector Non-connectivity devices Connectivity devices Vector address num ber num ber interrupt description interrupt description USBD w akeup from EXTI USBHS w akeup from EXTI IRQ 42 0x0000_00E8 interrupt interrupt TIMER7 break interrupt and TIMER7 break interrupt and IRQ 43 0x0000_00EC TIMER11 global interrupt...
Page 185
GD32E50x User Manual Interrupt Vector Non-connectivity devices Connectivity devices Vector address num ber num ber interrupt description interrupt description IRQ69 SHRTIMER_IRQ2 interrupt SHRTIMER_IRQ2 interrupt 0x0000_0154 IRQ70 SHRTIMER_IRQ3 interrupt SHRTIMER_IRQ3 interrupt 0x0000_0158 IRQ71 SHRTIMER_IRQ4 interrupt SHRTIMER_IRQ4 interrupt 0x0000_015C IRQ72 SHRTIMER_IRQ5 interrupt SHRTIMER_IRQ5 interrupt 0x0000_0160 IRQ73...
GD32E50x User Manual External interrupt and event (EXTI) block diagram 7.4. Figure 7-1. Block diagram of EXTI Polarity Software Control Trigger EXTI Line0~21 Edge detector To NVIC Interrupt Mask Control To Wakeup Unit Event Event Mask Generate Control External Interrupt and event function overview 7.5.
Page 187
GD32E50x User Manual Hardware trigger Hardware trigger may be used to detect the voltage change of external or internal signals. The software should follow these steps to use this function: Configure EXTI sources in AFIO module based on application requirement. Configure EXTI_RTEN and EXTI_FTEN to enable the rising or falling detection on related pins.
Page 188
GD32E50x User Manual EXTI Line Source Num ber RTC Alarm USB Wakeup Ethernet Wakeup I2C2 Wakeup USART5 Wakeup...
GD32E50x User Manual General-purpose and alternate-function I/Os (GPIO and AFIO) Overview 8.1. There are up to 112 general purpose I/O pins (GPIO), named PA0 ~ PA15, PB0 ~ PB15, PC0 ~ PC15, PD0 ~ PD15, PE0 ~ PE15, PF0 ~ PF15 and PG0 ~ PG15 for the device to implement logic input/output functions.
GD32E50x User Manual Table 8-1. GPIO configuration table Configuration m ode CTL[1:0] SPDy: MD[1:0] OCTL don’t care Analog don’t care Input floating Input x 00 Input pull-dow n Input pull-up x 00: Reserved Push-pull 0 or 1 General purpose x 01: Speed up to 10MHz Output (GPIO) Open-drain 0 or 1...
GD32E50x User Manual Floating PB3: JTDO in mode. The GPIO pins can be configured as inputs or outputs. When the GPIO pins are configured as input pins, all GPIO pins have an internal weak pull-up and weak pull-down which can be chosen.
GD32E50x User Manual Output configuration 8.3.5. When GPIO pin is configured as output: The schmitt trigger input is enabled. The weak pull-up and pull-down resistors are disabled. The output buffer is enabled. Open Drain Mode: The pad output low level when a “0” in the output control register; while the pad leaves Hi-Z when a “1”...
GD32E50x User Manual Alternate function (AF) configuration 8.3.7. To suit for different device packages, the GPIO supports some alternate functions mapped to some other pins by software. When be configured as alternate function: The output buffer is enabled in Open-Drain or Push-Pull configuration. ...
GD32E50x User Manual 0b10, or 0b11 and configuring CTLy bits of corresponding port in GPIOx_CTL0/GPIOx_CTL1 register to 0b10 (for AF push-pull output) or 0b11 (for AF open-drain output). Some alternate function need to configure, the configuration registers are AFIO_PCFA- AFIO_PCFE, and AFIO_PCFG. GPIO locking function 8.3.9.
GD32E50x User Manual JTAG/SWD alternate function remapping 8.4.3. The debug interface signals are mapped on the GPIO ports as shown in table below. Table 8-2. Debug interface signals Pin Nam e Function description PA13 JTMS / SWDIO PA14 JTCK / SWCLK PA15 JTDI JTDO / TRACESWO...
GD32E50x User Manual Register ADC0 ADC1 routine conversion is connected to TIMER7_TRGO ADC1 external signal trigger ADC1_ETRGRT_REMA P routine conversion is connected to EXTI11 ADC1_ETRGRT_REMA P ADC1 external signal trigger routine conversion is connected to TIMER7_TRGO Remap available only for High-density devices TIMER AF remapping 1.1.1.
GD32E50x User Manual Register definition 3.2. GPIOA base address: 0x4001 0800 GPIOB base address: 0x4001 0C00 GPIOC base address: 0x4001 1000 GPIOD base address: 0x4001 1400 GPIOE base address: 0x4001 1800 GPIOF base address: 0x4001 1C00 GPIOG base address: 0x4001 2000 AFIO base address: 0x4001 0000 Port control register 0 (GPIOx_CTL0, x=A..G) 3.2.1.
Page 206
GD32E50x User Manual 21:20 MD5[1:0] Port 5 mode bits These bits are set and cleared by softw are refer to MD0[1:0]description 19:18 CTL4[1:0] Port 4 configuration bits These bits are set and cleared by softw are refer to CTL0[1:0]description 17:16 MD4[1:0] Port 4 mode bits These bits are set and cleared by softw are...
GD32E50x User Manual 11: AFIO output w ith open-drain MD0[1:0] Port 0 mode bits These bits are set and cleared by softw are 00: Input mode (reset state) 01: Output mode(10MHz) 10: Output mode(2MHz) 11: Output mode(50MHz) Port control register 1 (GPIOx_CTL1, x=A..G) 3.2.2.
GD32E50x User Manual 19:18 CTL12[1:0] Port 12 configuration bits These bits are set and cleared by softw are refer to CTL0[1:0]description 17:16 MD12[1:0] Port 12 mode bits These bits are set and cleared by softw are refer to MD0[1:0]description 15:14 CTL11[1:0] Port 11 configuration bits These bits are set and cleared by softw are...
GD32E50x User Manual BOP15 BOP14 BOP13 BOP12 BOP11 BOP10 BOP9 BOP8 BOP7 BOP6 BOP5 BOP4 BOP3 BOP2 BOP1 BOP0 Bits Fields Descriptions 31:16 Port Clear bit y(y=0..15) These bits are set and cleared by softw are 0: No action on the corresponding OCTLy bit 1: Clear the corresponding OCTLy bit to 0 15:0 BOPy...
GD32E50x User Manual LK15 LK14 LK13 LK12 LK11 LK10 Bits Fields Descriptions 31:17 Reserved Must be kept at reset value Lock sequence key It can only be setted using the Lock Key Writing Sequence. And can alw ays be read. 0: GPIO_LOCK register is not locked and the port configuration is not locked.
GD32E50x User Manual Event control register (AFIO_EC) 3.2.9. Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved PORT[2:0] PIN[3:0] Bits Fields Descriptions 31:8 Reserved Must be kept at reset value Event output enable ®...
Page 214
GD32E50x User Manual ADC0_ETRGRT_RE ADC 0 external trigger routine conversion remapping This bit is set and reset by softw are. 0: Connect the ADC0 external signal trigger routine conversion to EXTI11. 1: Connect the ADC0 external signal trigger routine conversion to TIM7_TRGO. Reserved Must be kept at reset value.
Page 215
GD32E50x User Manual 10: not used Enable remapping function fully(TIMER1_CH0- TIMER1_ETI/PA 15, TIMER1_CH1/PB3, TIMER1_CH2/PB10, TIMER1_CH3/PB11) TIMER0_REMA P TIMER0 remapping [1:0] These bits are set and reset by softw are 00: Disable the remapping function(TIMER0_ETI / PA12, TIMER0_CH0 / PA8, TIMER0_CH1 / PA9, TIMER0_CH2 / PA10, TIMER0_CH3 / PA11, TIMER0_B K IN / PB12, TIMER0_CH0_ON / PB13, TIMER0_CH1_ON / PB14, TIMER0_CH2_ON / PB15) 01: Enable the remapping function partially(TIMER0_ETI / PA12, TIMER0_CH0 /...
Page 216
GD32E50x User Manual SPI0_REMA P SPI0 remapping This bit is set and cleared by softw are. 0: Disable the remapping function (SPI0_NSS/PA4, SPI0_SCK /PA5, SPI0_MISO /PA6,SPI0_MOSI /PA7) 1: Enable the remapping function (SPI0_NSS/PA15, SPI0_SCK /PB3, SPI0_MISO /PB4,SPI0_MOSI /PB5) Memory map and bit definitions for connectivity devices: TIMER1IT TIMER4C PTP_PPS...
Page 217
GD32E50x User Manual Other: Undefined ENET_PHY_SEL Ethernet MII or RMII PHY selection 0:Select an MII PHY 1: Select an RMII PHY CAN1_REMA P CAN1 I/O remapping 0: Disable the remapping function (CAN1_RX/PB12,CA N_TX/PB13) 1: Enable the remapping function (CAN1_RX/PB5,CAN_TX/PB6) ENET_REMA P Ethernet MAC I/O remapping 0: Disable the remapping function (RX_DV-CRS_DV/PA7, RXD0/PC4, RXD1/PC5, RXD2/PB0, RXD3/PB1)
Page 218
GD32E50x User Manual TIMER1_CH1/PA1, TIMER1_CH2/PA2, TIMER1_CH3/PA3) 01: Enable the remapping function partially 0 (TIMER1_CH0- TIMER1_ETI/PA 15, TIMER1_CH1/PB3, TIMER1_CH2/PA2, TIMER1_CH3/PA3) 10: Enable the remapping function partially 1 (TIMER1_CH0-TIMER1_ETI/ PA 0, TIMER1_CH1/PA1, TIMER1_CH2/PB10, TIMER1_CH3/PB11) 11: Enable the remapping function fully (TIMER1_CH0- TIMER1_ETI/PA 15, TIMER1_CH1/PB3, TIMER1_CH2/PB10, TIMER1_CH3/PB11) TIMER0_REMA P[1:0 TIMER0 remapping...
GD32E50x User Manual 0: Disable the remapping function (SPI0_NSS/PA4, SPI0_SCK /PA5, SPI0_MIS O /PA6, SPI0_MOSI /PA7) 1: Enable the remapping function (SPI0_NSS/PA15, SPI0_SCK /PB3, SPI0_MIS O /PB4, SPI0_MOSI /PB5) EXTI sources selection register 0 (AFIO_EXTISS0) 3.2.11. Address offset: 0x08 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
GD32E50x User Manual 0100: PE12 pin 0101: PF12 pin 0110: PG12 pin Other configurations are reserved. AFIO port configuration register 1 (AFIO_PCF1) 3.2.15. Address offset: 0x1C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved EXMC_N TIMER13_ IMER12_...
GD32E50x User Manual alternate function onto the GPIO ports 0: Disable the remapping function (PA6) 1: Enable the remapping function (PF8) TIMER10_REMA P TIMER10 remapping This bit is set and cleared by softw are, it controls the mapping of the TIMER10_ C H0 alternate function onto the GPIO ports 0: Disable the remapping function (PB9) 1: Enable the remapping function (PF7)
GD32E50x User Manual 1: I/O compensation cell is ready Reserved Must be kept at reset value. CPS_EN I/O compensation cell enable. When the port output speed is more than 50 MHz, the user should enable the compensation cell. 0: I/O compensation cell is pow er-dow n 1: I/O compensation cell is enable AFIO port configuration register A (AFIO_PCFA) 3.2.17.
Page 227
GD32E50x User Manual 10/11: Configure PA11 alternate function to SHRTIMER 21:20 PA10_AFCFG[1:0] PA10 AF function configuration bits These bits are set and cleared by softw are. 00: Do not configure PA10 alternate function to SHRTIMER/CA N2/CMP5 01: Configure PA10 alternate function to CAN2 10: Configure PA10 alternate function to CMP5 11: Configure PA10 alternate function to SHRTIMER Note: CAN2 is available only in connectivity line devices.
GD32E50x User Manual AFIO port configuration register B (AFIO_PCFB) 3.2.18. Address offset: 0x40 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). PB15_AF Reserved PB14_AFCFG[1:0] PB13_AFCFG[1:0] PB12_AFCFG[1:0] PB11_AFCFG[1:0] PB10_AFCFG[1:0] PB9_AFCFG[1:0] PB8_AFCFG[1:0] PB7_AFC PB6_AFC PB3_ PB0_ Reserved Reserved PB5_AFCFG[1:0] PB4_AFCFG[1:0]...
Page 229
GD32E50x User Manual 11: Configure PB11 alternate function to SHRTIMER Note: CAN2 is available only in connectivity line devices. 21:20 PB10_AFCFG[1:0] PB10 AF function configuration bits These bits are set and cleared by softw are. 00: Do not configure PB10 alternate function to SHRTIMER/USBHS/CA N2 01: Configure PB10 alternate function to CAN2 10: Configure PB10 alternate function to USBHS 11: Configure PB10 alternate function to SHRTIMER...
GD32E50x User Manual 10: Configure PB4 alternate function to I2C2 11: Configure PB4 alternate function to SHRTIMER Reserved Must be kept at reset value PB3_AFCFG PB3 AF function configuration bit This bit is set and cleared by softw are. 0: Do not configure PB3 alternate function to SHRTIMER 1: Configure PB3 alternate function to SHRTIMER PB2_AFCFG[1:0] PB2 AF function configuration bits...
Page 231
GD32E50x User Manual 31:25 Reserved Must be kept at reset value PC12_AFCFG PC12 AF function configuration bit This bit is set and cleared by softw are. 0: Do not configure PC12 alternate function to SHRTIMER 1: Configure PC12 alternate function to SHRTIMER 23:22 PC11_AFCFG[1:0] PC11 AF function configuration bits...
GD32E50x User Manual 0: Do not configure PC3 alternate function to USBHS 1: Configure PC3 alternate function to USBHS PC2_AFCFG[1:0] PC2 AF function configuration bits These bits are set and cleared by softw are. 00: Do not configure PC2 alternate function to USBHS/I2S1 01/11: Configure PC2 alternate function to I2S1 10: Configure PC2 alternate function to USBHS Reserved...
GD32E50x User Manual AFIO port configuration register E (AFIO_PCFE) 3.2.21. Address offset: 0x4C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). PE13_AF PE12_AF PE11_AF PE10_AF PE9_AFC PE8_AFC Reserved Reserved Reserved Reserved Reserved Reserved Reserved PE1_AFCFG[1:0] PE0_AFCFG[1:0] Bits Fields...
GD32E50x User Manual 1: Configure PE9 alternate function to CMP3 Reserved Must be kept at reset value PE8_AFCFG PE8 AF function configuration bit This bit is set and cleared by softw are. 0: Do not configure PE8 alternate function to CMP1 1: Configure PE8 alternate function to CMP1 15:4 Reserved...
Page 235
GD32E50x User Manual 1: Configure PG14 alternate function to USART5 Reserved Must be kept at reset value. PG13_AFCFG PG13 AF function configuration bit This bit is set and cleared by softw are. 0: Do not configure PG13 alternate function to SHRTIMER 1: Configure PG13 alternate function to SHRTIMER Reserved Must be kept at reset value.
Page 236
GD32E50x User Manual 1: Configure PG10 alternate function to SHRTIMER 11:0 Reserved Must be kept at reset value.
GD32E50x User Manual Cyclic redundancy checks management unit (CRC) Overview 3.3. A cyclic redundancy check management (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. This CRC management unit can be used to calculate 7/8/16/32 bit CRC code within user configurable polynomial.
GD32E50x User Manual Function overview 3.5. CRC management unit is used to calculate the 32-bit raw data, and CRC_DATA register will receive the raw data and store the calculation result. If the CRC_DATA register has not been cleared by setting the CRC_CTL register, the new input raw data will be calculated based on the result of previous value of CRC_DATA.
GD32E50x User Manual Register definition 3.6. CRC base address: 0x4002 3000 Data register (CRC_DATA) 3.6.1. Address offset: 0x00 Reset value: 0xFFFF FFFF This register has to be accessed by word (32-bit). DATA[31:16] DATA[15:0] Bits Fields Descriptions 31:0 DATA[31:0] CRC calculation result bits Softw are w rites and reads.
GD32E50x User Manual by any other peripheral. The CRC_CTL register w ill generate no effect to the byte. Control register (CRC_CTL) 9.1.1. Address offset: 0x08 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved REV_O REV_I[1:0] PS[1:0]...
GD32E50x User Manual This register has to be accessed by word (32-bit). IDATA[31:16] IDATA[15:0] Bits Fields Descriptions 31:0 IDATA[31:0] Configurable initial CRC data value When RST bit in CRC_CTL asserted, CRC_DATA w ill be programmed to this value. Polynomial register (CRC_POLY) 9.1.3.
GD32E50x User Manual Trigonometric Math Unit (TMU) Overview 10.1. The Trigonometric Math Unit (TMU) is a fully configurable block that execute common trigonometric and arithmetic operations. The TMU calculation unit can be used to calculate total 9 kinds of operations. The operation data must meet IEEE 32-Bit Single Precision Floating-Point Format.
GD32E50x User Manual Figure 10-1. Block diagram of Trigonometric Math Unit Data format 10.3.2. The operation data and calculation result data format is given in Table 10-2. IEEE 32-Bit Single Precision Floating-Point Format. They must meet IEEE 32 bit Single Precision Floating-Point.
GD32E50x User Manual in the given floating-point format. Under such cases, a positive or negtive Infinity value is returned. If a TMU operation generates an overflow condition, then the latched overflow flag (OVRF) is set to 1. The OVRF flag will remain latched until the next new operation is started. Rounding: There are various rounding formats supported by the IEEE standard.
GD32E50x User Manual If R0 result is too small for floating-point number (E < 0), R0 = 0.0, UDRF = 1. Mode 2 description 10.3.5. This operation is equivalent as R0 = √ x. x is the input operation data, R0 is the calculation result.
GD32E50x User Manual 2. R0 = cos(PerUnit * 2π). In control applications radians are usually normalized to the range of -1.0 to 1.0. It means that the range of PerUnit * 2π values is (-2π, 2π). So only the fraction part of operation data x is used in this mode. The x whole part has no effect on the result.
GD32E50x User Manual Mode 7 description 10.3.10. This operation is equivalent as R0 = x/y. x and y is the input operation data, R0 is the calculation result. This mode has both UDRF and OVRF. The UDRF and OVRF condition is as below table: Table 10-7.
GD32E50x User Manual TMU register 10.5. TMU base address: 0x4008 0000 Input data0 register (TMU_IDATA0) 10.5.1. Address offset: 0x00 Reset value: 0x3F80 0000 This register has to be accessed by word (32-bit). IDATA0[31:16] IDATA0[15:0] Bits Fields Descriptions 31:0 IDATA0[31:0] The value of input data Mode0~5: IDATA0 is the only operation data Mode6: IDATA0 is the X value Mode7: IDATA0 is the dividend...
GD32E50x User Manual mode7: IDATA1 is the divisor mode8: IDATA1 is the X value or Y value IDATA1 must meet IEEE 32-Bit Single Precision Floating-Point Format. Control register (TMU_CTL) 10.5.3. Address offset: 0x08 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved CFIF...
GD32E50x User Manual Data0 register (TMU_DATA0) 10.5.4. Address offset: 0x0C Reset value: 0x3400 0000 This register has to be accessed by word (32-bit). DATA0[31:16] DATA0[15:0] Bits Fields Descriptions 31:0 DATA0[31:0] The result of calculation Mode 0~5,7,8: TMU_DATA0 is the only result value Mode6: TMU_DATA0=Ratio of X and Y TMU_DATA0 must meet IEEE 32-Bit Single Precision Floating-Point Format.
Page 253
GD32E50x User Manual This register has to be accessed by word (32-bit). Reserved Reserve UDRF OVRF Bits Fields Descriptions 31:2 Reserved Must be kept at reset value. UDRF The flag of underflow 0: No underflow 1: Underflow This bit is set and cleared by hardw are. w hen the next TMU calculation is started, this bit is cleared by hardw are.
GD32E50x User Manual Direct memory access controller (DMA) Overview 11.1. The direct memory access (DMA) controller provides a hardware method of transferring data between peripherals and/or memory without intervention from the CPU, thereby freeing up bandwidth for other system functions. Data can be quickly moved by DMA between peripherals and memory as well as memory and memory without any CPU actions.
GD32E50x User Manual The DMA transmission is disabled by clearing the CHEvN bit in the DMA_CHxCTL register. If the DMA transmission is not completed when the CHEN bit is cleared, two situations may be occurred when restart this DMA channel: –...
GD32E50x User Manual channel number. Address generation 11.4.4. Two kinds of address generation algorithm are implemented independently for memory and peripheral, including the fixed mode and the increased mode. The PNAGA and MNAGA bit in the DMA_CHxCTL register are used to configure the next address generation algorithm of peripheral and memory.
GD32E50x User Manual transfer error interrupt in the DMA_CHxCTL register. Configure the DMA_CHxPADDR register for setting the peripheral base address. Configure the DMA_CHxMADDR register for setting the memory base address. Configure the DMA_CHxCNT register to set the total transfer data number. 10.
GD32E50x User Manual Table 11-3. DMA0 requests for each channel lists the support request from peripheral for each channel of DMA0, and Table 11-4. DMA1 requests for each channel lists the support request from peripheral for each channel of DMA1. Figure 11-4.
GD32E50x User Manual Register definition 11.5. DMA0 base address: 0x4002 0000 DMA1 base address: 0x4002 0400 Note: For DMA1 having 5 channels, all bits related to channel 5 and channel 6 in the following registers are not suitable for DMA1. Interrupt flag register (DMA_INTF) 11.5.1.
GD32E50x User Manual Interrupt flag clear register (DMA_INTC) 11.5.2. Address offset: 0x04 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). Reserved ERRIFC6 HTFIFC6 FTFIFC6 GIFC6 ERRIFC5 HTFIFC5 FTFIFC5 GIFC5 ERRIFC4 HTFIFC4 FTFIFC4 GIFC4 ERRIFC3 HTFIFC3 FTFIFC3 GIFC3 ERRIFC2 HTFIC2 FTFIFC2 GIFC2...
Page 265
GD32E50x User Manual Bits Fields Descriptions 31:15 Reserved Must be kept at reset value. Memory to Memory Mode Softw are set and cleared 0: Disable Memory to Memory Mode 1: Enable Memory to Memory mode This bit can not be w ritten w hen CHEN is ‘1’. 13:12 PRIO[1:0] Priority level...
GD32E50x User Manual CMEN Circular mode enable Softw are set and cleared 0: Disable circular mode 1: Enable circular mode This bit can not be w ritten w hen CHEN is ‘1’. Transfer direction Softw are set and cleared 0: Read from peripheral and w rite to memory 1: Read from memory and w rite to peripheral This bit can not be w ritten w hen CHEN is ‘1’.
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CNT[15:0] Transfer counter These bits can not be w ritten w hen CHEN in the DMA_CHxCTL register is ‘1’. This register indicates how many transfers remain. Once the channel is enabled, it is read-only, and decreases after each DMA transfer.
Page 268
GD32E50x User Manual MADDR[31:16] MADDR[15:0] Bits Fields Descriptions 31:0 MADDR[31:0] Memory base address These bits can not be w ritten w hen CHEN in the DMA_CHxCTL register is ‘1’. When MWIDTH in the DMA_CHxCTL register is 01 (16-bit), the LSB of these bits is ignored.
GD32E50x User Manual Debug (DBG) Introduction 12.1. The GD32E50x series provide a large variety of debug, trace and test features. They are implemented with a standard configuration of the Arm CoreSightTM module together with a ® daisy chained standard TAP controller. Debug and trace functions are integrated into the Arm ®...
GD32E50x User Manual PA15 : JTDI PA14 : JTCK/SWCLK PA13 : JTMS/SWDIO : NJTRST : JTDO By default, 5-pin standard JTAG debug mode is chosen after reset. Users can also use JT AG function without NJTRST pin, then the PB4 can be used to other GPIO functions (NJTRST tied to 1 by hardware).
GD32E50x User Manual When SLP_HOLD bit in DBG control register (DBG_CTL) is set and entering the sleep mode, the clock of AHB bus for CPU is not closed, and the debugger can debug in sleep mode. Debug support for TIMER, I2C, WWDGT, FWDGT and CAN 12.3.2.
GD32E50x User Manual DBG registers 12.4. DEBUG base address: 0xE0044000 ID code register (DBG_ID) 12.4.1. Address offset: 0x00 Read only This register has to be accessed by word (32-bit). ID_CODE[31:16] ID_CODE[15:0] Bits Fields Descriptions 31:0 ID_CODE[31:0] DBG ID code register These bits read by softw are.
Page 273
GD32E50x User Manual 1: Hold the TIMER10 counter for debug w hen core halted. TIMER9_HOLD TIMER9 hold bit This bit is set and reset by softw are. 0: no effect 1: Hold the TIMER9 counter for debug w hen core halted. TIMER8_HOLD TIMER8 hold bit This bit is set and reset by softw are.
Page 274
GD32E50x User Manual TIMER4_HOLD TIMER4 hold bit This bit is set and reset by softw are. 0: no effect 1: Hold the TIMER4 counter for debug w hen core halted. TIMER7_HOLD TIMER7 hold bit This bit is set and reset by softw are. 0: no effect 1: Hold the TIMER7 counter for debug w hen core halted.
Page 275
GD32E50x User Manual 1: Hold the WWDGT counter clock for debug w hen core halted. FWDGT_HOLD FWDGT hold bit This bit is set and reset by softw are. 0: no effect 1: Hold the FWDGT counter clock for debug w hen core halted. Reserved Must be kept at reset value.
GD32E50x User Manual Analog-to-digital converter (ADC) Introduction 13.1. A 12-bit successive approximation analog-to-digital converter module(ADC) is integrated on the MCU chip, which can sample analog signals from 16 external channels and 2 internal channels. The 18 ADC sampling channels all support a variety of operation modes. After sampling and conversion, the conversion results can be stored in the corresponding data registers according to the least significant bit alignment(LSB) or the most significant bit alignment(MSB).
GD32E50x User Manual Module supply requirements: the typical power supply voltage is 3.3V: – 1.62V to 2.4V, with ADC maximum frequency is 14MHz. – 2.4V to 3.6V, with ADC maximum frequency is 35MHz. ≤V ≤V Channel input range: V REF- REF+.
GD32E50x User Manual Set RSTCLB (optional). Set CLB=1. Wait until CLB=0. ADC clock 13.4.2. The CK_ADC clock is synchronous with the AHB and APB2 clock and provided by the clock controller. ADC clock can be divided and configured by RCU controller. ADCON enable 13.4.3.
GD32E50x User Manual Routine sequence 13.4.5. The channel management circuit can organize the sampling conversion channels into a sequence: routine sequence. The routine sequence supports up to 16 channels, and each channel is called routine channel. The RL[3:0] bits in the ADC_RSQ0 register specify the total conversion sequence length. The ADC_RSQ0~ADC_RSQ2 registers specify the selected channels of the routine sequence.
GD32E50x User Manual stored in the ADC_RDATA register. Figure 13-4. Continuous operation mode Software procedure for continuous conversion on a routine channel: Set the CTN bit in the ADC_CTL1 register. Configure RSQ0 with the analog channel number. Configure ADC_SAMPTx register. Configure ETERC and ETSRC bits in the ADC_CTL1 register if in need.
GD32E50x User Manual Figure 13-5. Scan operation mode, continuous operation mode disable Software procedure for scan conversion on a routine sequence: Set the SM bit in the ADC_CTL0 register and the DMA bit in the ADC_CTL1 register. Configure ADC_RSQx and ADC_SAMPTx registers. Configure ETERC and ETSRC bits in the ADC_CTL1 register if in need.
GD32E50x User Manual Configure ADC_RSQx and ADC_SAMPTx registers. Configure ETERC and ETSRC bits in the ADC_CTL1 register if in need. Prepare the DMA module to transfer data from the ADC_RDATA (refer to the spec of the DMA module). Set the SWRCST bit, or generate an external trigger for the routine sequence. Repeat step6 if in need.
GD32E50x User Manual 6-bit resolution data alignment is different from 12-bit/10-bit/8-bit resolution data alignment, shown as Figure 13-9. 6-bit data storage mode Figure 13-9. 6-bit data storage mode Sample time configuration 13.4.9. The number of CK_ADC cycles which is used to sample the input voltage can be specified by the SPTn[2:0] bits in the ADC_SAMPT0 and ADC_SAMPT1 registers.
GD32E50x User Manual ETSRC[3:0] Trigger Source Trigger Type 0011 TIMER7_CH0 0100 TIMER7_TRGO 0101 TIMER4_CH0 0110 TIMER4_CH2 0111 Softw are trigger SWRCST 1000~1111 reserved DMA request 13.4.11. The DMA request, which is enabled by the DMA bit of ADC_CTL1 register, is used to transfer data of routine sequence for conversion of more than one channel.
GD32E50x User Manual the datasheet. Avg_Slope: average slope for curve between temperature vs. internal temperature sensor output voltage, the typical value please refer to the datasheet. Programmable resolution (DRES) 13.4.13. The resolution is configured by programming the DRES[1:0] bits in the ADC_OVSAMPCTL register.
GD32E50x User Manual Figure 13-10. 20-bit to 16-bit result truncation Note: If the intermediate result after the shifting exceeds 16 bits, the upper bits of the result are simply truncated. Figure 13-11. Numerical example with 5-bits shift and rounding shows a numerical example of the processing, from a raw 20-bit accumulated data to the final 16-bit result.
GD32E50x User Manual Figure 13-13. Routine parallel mode on 10 channels Routine follow-up fast mode 13.5.3. The follow-up fast mode is applicable to sample the same channel of two ADCs. The source of external trigger comes from the ADC0 routine channel (selected by the ETSRC[2:0] bits in the ADC_CTL1 register).
GD32E50x User Manual Continuous operation mode can’t be used in this mode, because it continuously converts the routine channel. The behavior of follow-up slow mode shows in the Figure 13-15. Routine follow-up slow mode on routine sequence channel. After an EOC interrupt is generated by ADC0 (if EOCIE bit is set), we can use a 32-bit DMA, which transfers to SRAM the ADC_RDATA register containing the ADC1 converted data in the [31: 16] bits field and the ADC0 converted data in the [15: 0] bits field.
GD32E50x User Manual ADC registers 13.7. ADC0 base address: 0x4001 2400 ADC1 base address: 0x4001 2800 ADC2 base address: 0x4001 3C00 Status register (ADC_STAT) 13.7.1. Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). WDE2 WDE1 Reserved...
GD32E50x User Manual Set by hardw are at the end of a routine sequence conversion. Cleared by softw are writing 0 to it or by reading the ADC_RDATA register. WDE0 Analog w atchdog 0 event flag 0: Analog w atchdog 0 event is not happened 1: Analog w atchdog 0 event is happening Set by hardw are w hen the converted voltage crosses the values programmed in the ADC_WDLT0 and ADC_WDHT0 registers.
Page 295
GD32E50x User Manual any configuration change. 15:13 DISNUM[2:0] Number of conversions in discontinuous mode The number of channels to be converted after a trigger w ill be DISNUM+1 in routine sequence. Reserved Must be kept at reset value. DISRC Discontinuous mode on routine channels 0: Discontinuous operation mode on routine channels disable 1: Discontinuous operation mode on routine channels enable Reserved...
GD32E50x User Manual 10000: ADC channel16 10001: ADC channel17 Other values are reserved. Note: ADC0 analog inputs Channel16 and Channel17 are internally connected to the temperature sensor, and to V inputs. ADC1 analog inputs Channel16, and REFINT Channel17 are internally connected to V .
GD32E50x User Manual 1: Initialize calibration register start ADC calibration 0: Calibration done 1: Calibration start Continuous mode 0: Continuous operation mode disable 1: Continuous operation mode enable ADCON ADC ON. The ADC w ill be w ake up w hen this bit is changed from low to high and take a stabilization time.
GD32E50x User Manual 010: Channel sampling time is 13.5 cycles 011: Channel sampling time is 28.5 cycles 100: Channel sampling time is 41.5 cycles 101: Channel sampling time is 55.5 cycles 110: Channel sampling time is 71.5 cycles 111: Channel sampling time is 239.5 cycles Sample time register 1 (ADC_SAMPT1) 13.7.5.
GD32E50x User Manual 110: Channel sampling time is 71.5 cycles 111: Channel sampling time is 239.5 cycles Watchdog high threshold register 0 (ADC_WDHT0) 13.7.6. Address offset: 0x24 Reset value: 0x0000 0FFF This register has to be accessed by word(32-bit). Reserved Reserved WDHT0[11:0] Bits...
GD32E50x User Manual Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). Reserved RL[3:0] RSQ15[4:1] RSQ15[0] RSQ14[4:0] RSQ13[4:0] RSQ12[4:0] Bits Fields Descriptions 31:24 Reserved Must be kept at reset value. 23:20 RL[3:0] Routine sequence length. The total number of conversion in routine sequence equals to RL[3:0]+1. 19:15 RSQ15[4:0] refer to RSQ0[4:0] description...
GD32E50x User Manual 31:16 ADC1RDTR[15:0] ADC1 routine channel data In ADC0: In sync mode, these bits contain the routine data of ADC1. These bits are only used in ADC0. 15:0 RDATA[15:0] Routine channel data These bits contain the conversion result from routine channel, w hich is read only. Oversample control register (ADC_OVSAMPCTL) 13.7.12.
GD32E50x User Manual 0101: Shift 5-bits 0110: Shift 6-bits 0111: Shift 7-bits 1000: Shift 8-bits Other values are reserved. Note: The softw are allow s this bit to be w ritten only w hen ADCON=0 (this ensures that no conversion is in progress). OVSR[2:0] Oversampling ratio This bit filed defines the number of oversampling ratio.
GD32E50x User Manual 17:0 AWD1CS[17:0] Analog w atchdog 1 channel selection These bits are set and cleared by softw are. They enable and select the input channels to be guarded by the analog w atchdog 1. AWD1CS[n] = 0: ADC analog input channel n is not monitored by analog w atchdog AWD1CS[n] = 1: ADC analog input channel n is monitored by analog w atchdog 1 When AWD1CH[17:0] = 000..0, the analog w atchdog 1 is disabled Note:...
GD32E50x User Manual Reset value: 0x00FF 0000 This register has to be accessed by word(32-bit). Reserved WDHT1[7:0] Reserved WDLT1[7:0] Bits Fields Descriptions 31:24 Reserved Must be kept at reset value. 23:16 WDHT1[7:0] High threshold for analog w atchdog 1 These bits define the high threshold for the analog w atchdog 1. Note: Softw are is allow ed to w rite these bits only w hen the ADC is disabled (ADCON =0).
GD32E50x User Manual 15:8 Reserved Must be kept at reset value. WDLT2[7:0] Low threshold for analog w atchdog 2 These bits define the high threshold for the analog w atchdog 2. Note: Softw are is allow ed to w rite these bits only w hen the ADC is disabled (ADCON =0).
GD32E50x User Manual Digital-to-analog converter (DAC) Introduction 14.1. The Digital-to-analog converter converts 12-bit digital data to a voltage on the external pins. The digital data can be configured in 8-bit or 12-bit mode, left-aligned or right-aligned mode. DMA can be used to update the digital data on external triggers. The output voltage can be optionally buffered for higher drive capability.
GD32E50x User Manual The output buffer, which is turned on by default, can be turned off by setting the DBOFFx bits in the DAC_CTL0 register. DAC data configuration 14.3.3. The 12-bit DAC holding data (OUTx_DH) can be configured by writing any one of the OUTx_R12DH, OUTx_L12DH and OUTx_R8DH registers.
GD32E50x User Manual voltage and the analog output load. DAC output FIFO 14.3.6. There is a 4-depth data FIFO which is implemented between the data hold register and the output register. The FIFO can be enabled by setting the FIFOENx bit in the DAC_CTL1 register.
GD32E50x User Manual Figure 14-2. DAC LFSR algorithm Triangle noise mode: in this mode, a triangle signal is added to the OUTx_DH value, and then the result is stored into the OUTx_DO register. The minimum value of the triangle signal is 0, while the maximum value of the triangle signal is (2 <<...
GD32E50x User Manual occurs, a DAC DMA request will be generated. If a second external trigger arrives before the acknowledgement of the previous request, the new request will not be serviced, and an underrun error event occurs. The DDUDRx bit in the DAC_STAT0 register is set, an interrupt will be generated if the DDUDRIEx bit in the DAC_CTL0 register is set.
GD32E50x User Manual DAC registers 14.4. DAC base address: 0x4000 7400 Control register 0 (DAC_CTL0) 14.4.1. Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). DDUDR DTSEL1 DDMA Reserved DWBW1[3:0] DWM1[1:0] DTSEL1[2:0] DTEN1 DBOFF1 DEN1 DDUDR...
Page 315
GD32E50x User Manual 1001: The bit w idth of the w ave signal is 10 1010: The bit w idth of the w ave signal is 11 ≥1011: The bit w idth of the w ave signal is 12 23:22 DWM1[1:0] DAC_OUT1 noise w ave mode These bits specify the mode selection of the noise w ave signal of DAC_OUT1 w hen...
Page 316
GD32E50x User Manual 0: DAC_OUT0 DMA underrun interrupt enabled DDMAEN0 DAC_OUT0 DMA enable 0: DAC_OUT0 DMA mode disabled 1: DAC_OUT0 DMA mode enabled 11:8 DWBW0[3:0] DAC_OUT0 noise w ave bit w idth These bits specify bit w idth of the noise w ave signal of DAC_OUT0. These bits indicate that unmask LFSR bit [n-1, 0] in LFSR noise mode or the amplitude of the triangle is ((2<<(n-1))-1) in triangle noise mode, w here n is the bit w idth of w ave.
GD32E50x User Manual Reserved Reserved OUT0_DH[11:0] Bits Fields Descriptions 31:12 Reserved Must be kept at reset value. 11:0 OUT0_DH[11:0] DAC_OUT0 12-bit right-aligned data. These bits specify the data that is to be converted by DAC_OUT0. DAC_OUT0 12-bit left-aligned data holding register (OUT0_L12DH) 14.4.4.
GD32E50x User Manual Bits Fields Descriptions 31:8 Reserved Must be kept at reset value. OUT0_DH[7:0] DAC_OUT0 8-bit right-aligned data. These bits specify the MSB 8 bits of the data that is to be converted by DAC_OUT0. DAC_OUT1 12-bit right-aligned data holding register (OUT1_R12DH) 14.4.6.
GD32E50x User Manual Reserved Must be kept at reset value. DAC_OUT1 8-bit right-aligned data holding register (OUT1_R8DH) 14.4.8. Address offset: 0x1C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). Reserved Reserved OUT1_DH[7:0] Bits Fields Descriptions 31:8 Reserved Must be kept at reset value.
GD32E50x User Manual concurrent mode 12-bit left-aligned data holding register 14.4.10. (DACC_L12DH) Address offset: 0x24 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). OUT1_DH[11:0] Reserved OUT0_DH[11:0] Reserved Bits Fields Descriptions 31:20 OUT1_DH[11:0] DAC_OUT1 12-bit left-aligned data These bits specify the data that is to be converted by DAC_OUT1.
GD32E50x User Manual OUT0_DH[7:0] DAC_OUT0 8-bit right-aligned data These bits specify the MSB 8-bit of the data that is to be converted by DAC_OUT0. DAC_OUT0 data output register (OUT0_DO) 14.4.12. Address offset: 0x2C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). Reserved Reserved OUT0_DO [11:0]...
GD32E50x User Manual DAC Status register 0 (DAC_STAT0) 14.4.14. Address offset: 0x34 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). DDUDR1 Reserved Reserved rc_w1 DDUDR0 Reserved Reserved rc_w1 Bits Fields Descriptions 31:30 Reserved Must be kept at reset value. DDUDR1 DAC_OUT1 DMA underrun flag, set by hardw are, cleared by softw are write 1.
GD32E50x User Manual 0: DAC_OUT1 FIFO underflow interrupt disabled. 1: DAC_OUT1 FIFO underflow interrupt enabled. FIFOOVRIE1 DAC_OUT1 FIFO overflow interrupt enable. 0: DAC_OUT1 FIFO overflow interrupt disabled. 1: DAC_OUT1 FIFO overflow interrupt enabled. FIFOEN1 DAC_OUT1 data FIFO enable. The DTEN1 bit should be set and DDMAEN1 should be reset, w hen FIFOEN1 is set.
Page 325
GD32E50x User Manual 001: the number of data is 1 010: the number of data is 2 011: the number of data is 3 100: the number of data is 4 101~111: reserved FIFOUDR1 DAC_OUT1 FIFO underflow flag 0: DAC_OUT1 FIFO is not underflow. 1: DAC_OUT1 FIFO is underflow.
GD32E50x User Manual Comparator (CMP) The CMP is only available on CL series. Overview 15.1. The general purpose comparators, CMP1, CMP3 and CMP5, can work either standalone (all terminal are available on I/Os) or together with the timers. It blanking function can be used for false overcurrent detection in motor control applications. 15.2.
GD32E50x User Manual Figure 15-1. CMP block diagram of GD32E50x series CMP1MSEL[3:0] CMP1PL CMP1OSEL[3:0] CMP3MSEL[3:0] CMP3PL CMP3OSEL[3:0] CMP5MSEL[3:0] CMP5PL CMP5OSEL[3:0] Note: V is 1.2V. REFINT CMP I/O configuration 15.3.1. These I/Os must be configured in analog mode in the GPIOs registers before they are selected as CMPs inputs.
GD32E50x User Manual The CMP output can be redirected internally and externally simultaneously. . Table 15-1. CMP inputs and outputs summary CMP1 CMP3 CMP5 CMP non inverting inputs connected PB11 to I/Os CMP inverting inputs connected PA2/PA4/PA5 PB2/PA4/PA5 PB15/PA4/PA5 to I/Os REFINT REFINT REFINT...
GD32E50x User Manual Figure 15-2. The CMP outputs signal blanking Current threshold Current signal PWM signal Blanking window signal CMP outputs raw singal CMP outputs final singal CMP register write protection 15.3.3. The CMP control and status register (CMP_CS) can be protected from writing by setting CMPxLK bit to 1.
GD32E50x User Manual 17:16 Reserved Must be kept at reset value. CMP1PL Polarity of CMP1 output This bit is used to select the polarity of CMP1 output. 0 : Output is not inverted 1 : Output is inverted Reserved Must be kept at reset value 13:10 CMP1OSEL[3:0] Comparator 1 output selection...
Page 332
GD32E50x User Manual CMP3MS CMP3LK CMP3O Reserved Reserved CMP3BLK[2:0] Reserved EL[3] CMP3PL Reserved CMP3OSEL[3:0] Reserved CMP3MSEL[2:0] Reserved CMP3EN Bits Fields Descriptions CMP3LK CMP3 lock This bit allow s to have all control bits of CMP3 as read-only. It can only be set once by softw are and cleared by a system reset.
GD32E50x User Manual 0110: TIMER2 channel2 input capture 0111~1111: Reserved Reserved Must be kept at reset value CMP3MSEL[2:0] CMP3_IM input selection These bits, together w ith bit 22, are used to select the source connected to the CMP3_IM input of the CMP3. 0000: V REFINT 0001: V...
Page 334
GD32E50x User Manual This bit is a copy of CMP5 output state, w hich is read only. 0: Non-inverting input below inverting input and the output is low 1: Non-inverting input above inverting input and the output is high 29:23 Reserved Must be kept at reset value.
Page 335
GD32E50x User Manual 0111: PB15 1000~1111: Reserved Reserved Must be kept at reset value CMP5EN CMP5 enable 0: CMP5 disabled 1: CMP5 enabled...
GD32E50x User Manual Watchdog timer (WDGT) The watchdog timer (WDGT) is a hardware timing circuitry that can be used to detect system failures due to software malfunctions. There are two watchdog timer peripherals in the chip: free watchdog timer (FWDGT) and window watchdog timer (WWDGT). They offer a combination of a high safety level, flexibility of use and timing accuracy.
GD32E50x User Manual Figure 16-1. Free watchdog block diagram The free watchdog is enabled by writing the value (0xCCCC) to the control register (FWDGT_CTL), then the counter starts counting down. When the counter reaches the value (0x000), there will be a reset. The counter can be reloaded by writing the value (0xAAAA) to the FWDGT_CTL register at anytime.
Page 338
GD32E50x User Manual Min tim eout (m s) Max tim eout (m s) Prescaler divider PSC[2:0] bits RLD[11:0]=0x000 RLD[11:0]=0xFFF 1 / 128 0.025 13104.025 1 / 256 110 or 111 0.025 26208.025 The FWDGT timeout can be more accurate by calibrating the IRC40K. Note: When after the execution of watchdog reload operation, if the MCU needs enter the deepsleep / standby mode immediately, more than 3 IRC40K clock intervals must be inserted in the middle of reload and deepsleep / standby mode commands by software setting.
GD32E50x User Manual Register definition 16.1.4. FWDGT base address: 0x4000 3000 Control register (FWDGT_CTL) Address offset: 0x00 Reset value: 0x0000 0000 This register can be accessed by half-word (16-bit) or word (32-bit) access. Reserved CMD[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value.
Page 340
GD32E50x User Manual FWDGT_STAT register is set and the value read from this register is invalid. 000: 1 / 4 001: 1 / 8 010: 1 / 16 011: 1 / 32 100: 1 / 64 101: 1 / 128 110: 1 / 256 111: 1 / 256 If several prescaler values are used by the application, it is mandatory to w ait until...
Page 341
GD32E50x User Manual Reset value: 0x0000 0000 This register can be accessed by half-word(16-bit) or word(32-bit) access. Reserved Reserved Bits Fields Descriptions 31:2 Reserved Must be kept at reset value. Free w atchdog timer counter reload value update During a w rite operation to FWDGT_RLD register, this bit is set and the value read from FWDGT_RLD register is invalid.
GD32E50x User Manual Window watchdog timer (WWDGT) 16.2. Overview 16.2.1. The window watchdog timer (WWDGT) is used to detect system failures due to software malfunctions. After the window watchdog timer starts, the value of down counter reduces progressively. The watchdog timer causes a reset when the counter reached 0x3F (the CNT[6] bit has been cleared).
GD32E50x User Manual The window watchdog timer is always disabled after power on reset. The software starts the watchdog by setting the WDGTEN bit in the WWDGT_CTL register. When window watchdog timer is enabled, the counter counts down all the time, the configured value of the counter should be greater than 0x3F (it implies that the CNT[6] bit should be set).
GD32E50x User Manual Table 16-2. Min/max timeout value at 100 MHz (f PCLK1 Min tim eout value Max tim eout value Prescaler divider PSC[1:0] CNT[6:0]=0x40 CNT[6:0]=0x7F 40.96 μs 1 / 1 2.62 ms 81.92 μs 1 / 2 5.24 ms 163.84 μs 1 / 4 10.49 ms...
GD32E50x User Manual Register definition 16.2.4. WWDGT base address: 0x4000 2C00 Control register (WWDGT_CTL) Address offset: 0x00 Reset value: 0x0000 007F This register can be accessed by half-word (16-bit) or word (32-bit). Reserved Reserved WDGTEN CNT[6:0] Bits Fields Descriptions 31:8 Reserved Must be kept at reset value.
Page 346
GD32E50x User Manual reaches 0x40. It can be cleared by a hardw are reset or softw are reset by setting the WWDGTRST bit of the RCU module. A w rite operation of ‘0’ has no effect. PSC[1:0] Prescaler. The time base of the w atchdog timer counter 00: (PCLK1 / 4096) / 1 01: (PCLK1 / 4096) / 2 10: (PCLK1 / 4096) / 4...
GD32E50x User Manual Real-time clock (RTC) Overview 3.7. The RTC is usually used as a clock-calendar. The RTC circuits are located in two power supply domains. The ones in the Backup Domain consist of a 32-bit up-counter, an alarm, a prescaler, a divider and the RTC clock configuration register.
GD32E50x User Manual bit in the RTC_CTL register is used to indicate the configuration mode status. The write operation executes when the peripheral exit configuration mode, and it takes at least three RTCCLK cycles to complete. The value of the LWOFF bit in the RTC_CTL register set s to ‘1’, if the write operation finished.
GD32E50x User Manual Figure 17-3. RTC second and overflow waveform example (RTC_PSC= 3) RTCCLK RTC_ PSC RTC_Second FFFFFFFD FFFFFFFE FFFFFFFF RTC_ CNT RTC_ Overflow OVIF OVIF flag can be cleared by software...
GD32E50x User Manual Bits Fields Descriptions 31:6 Reserved Must be kept at reset value. LWOFF Last w rite operation finished flag 0: Last w rite operation on RTC registers did not finished. 1: Last w rite operation on RTC registers finished. Configuration mode flag 0: Exit configuration mode.
GD32E50x User Manual 31:4 Reserved Must be kept at reset value. PSC[19:16] RTC prescaler value high RTC prescaler low register (RTC_PSCL) 17.1.8. Address offset: 0x0C Reset value: 0x8000 This register can be accessed by half-word (16-bit) or word (32-bit) Reserved PSC[15:0] Bits Fields...
GD32E50x User Manual This register can be accessed by half-word (16-bit) or word (32-bit) Reserved DIV[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 DIV[15:0] RTC divider value low The RTC divider register is reloaded by hardw are w hen the RTC prescaler or RTC counter register updated.
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CNT[15:0] RTC counter value low RTC alarm high register (RTC_ALRMH) 17.1.13. Address offset: 0x20 Reset value: 0xFFFF This register can be accessed by half-word (16-bit) or word (32-bit) Reserved ALRM[31:16] Bits...
GD32E50x User Manual Advanced timer (TIMERx, x=0, 7) 18.1. Overview 18.1.1. The advanced timer module (Timer0&Timer7) is a four-channel timer that supports both input capture and output compare. They can generate PWM signals to control motor or be used for power management applications.
GD32E50x User Manual Figure 18-3. Timing chart of PSC value change from 0 to 2 TIMER_CK PSC value Prescaler shadow Prescaler CNT PSC_CLK CNT_REG Reload Pulse Counter up counting In this mode, the counter counts up continuously from 0 to the counter-reload value, which is defined in the TIMERx_CAR register, in a count-up direction.
GD32E50x User Manual Counter down counting In this mode, the counter counts down continuously from the counter-reload value, which is defined in the TIMERx_CAR register, to 0 in a count-down direction. Once the counter reaches to 0, the counter the counter will start counting down from the counter-reload value again and an underflow event will be generated.
GD32E50x User Manual of CREP is odd, and the counter is counting in center-aligned mode, the update event is generated (on overflow or underflow) depending on when the written CREP value takes effect. If an update event is generated by software after writing an odd number to CREP, the update events will be generated on the underflow.
GD32E50x User Manual Figure 18-11. Repetition timechart for down-counter TIMER_CK PSC_CLK CNT_REG Underflow Overflow TIMERx_CREP = 0x0 UPIF TIMERx_CREP = 0x1 UPIF TIMERx_CREP = 0x2 UPIF Input capture and output compare channels The advanced timer has four independent channels which can be used as capture inputs or compare match outputs.
GD32E50x User Manual and DMA request will be asserted based on the configuration of CHxIE and CHxDEN in TIMERx_DMAINTEN Direct generation: if you want to generate a DMA request or Interrupt, you can set CHxG by software directly. The channel input capture function can be also used for pulse width measurement from signals on the TIMERx_CHx pins.
GD32E50x User Manual (the output of CHx_O is enabled), If the output of OxCPRE is active(high) level, the output of CHx_O is active(high) level; If the output of OxCPRE is inactive(low) level, the output of CHx_O is active(low) level. 2) Configure CHxNP=0 (the active level of CHx_ON is low, contrary to OxCPRE), CHxNEN=1 (the output of CHx_ON is enabled), If the output of OxCPRE is active(high) level, the output of CHx_O is active(low) level;...
Page 370
GD32E50x User Manual Figure 18-15. Output-compare in three modes CNT_CLK CNT_REG Overflow match toggle OxCPRE match set OxCPRE match clear OxCPRE Output PWM function In the output PWM mode (by setting the CHxCOMCTL bits to 3’b110 (PWM mode0) or to 3’b 111(PWM mode1), the channel can generate PWM waveform according to the TIMERx_CAR registers and TIMERx_CHxCV registers.
GD32E50x User Manual Figure 18-16. Timing chart of EAPWM Figure 18-17. Timing chart of CAPWM CHxVAL PWM MODE0 Cx OUT PWM MODE1 Cx OUT Interrupt signal CAM=2'b01 down only CHxIF CAM=2'b10 up only CHxIF CAM=2'b11 up/down CHxIF Channel output prepare signal Figure 18-13.
Page 372
GD32E50x User Manual set to 0 by setting the CHxCOMCTL field to 0x02 or signal toggle by setting the CHxCOMCTL field to 0x03 when the counter value matches the content of the TIMERx_CHxCV register. The PWM mode 0 and PWM mode 1 outputs are also another kind of OxCPRE output which is setup by setting the CHxCOMCTL field to 0x06/0x07.
GD32E50x User Manual Insertion dead time for complementary PWM The dead time insertion is enabled when both CHxEN and CHxNEN are 1’b1, and set POEN is also necessary. The field named DTCFG defines the dead time delay that can be used for all channels expect for channel 3.
GD32E50x User Manual bit in TIMERx_CCHP. When a break occurs, the POEN bit is cleared asynchronously, the output CHx_O and CHx_ON are driven with the level programmed in the ISOx bit and ISOxN in the TIMERx_CTL1 register as soon as POEN is 0. If IOS is 0 then the timer releases the enable output else the enable output remains high.
GD32E50x User Manual Figure 18-22. Hall sensor is used to BLDC motor show how to connect. And we can see we need two timers. First TIMER_in (Advanced/GeneralL0 TIMER) should accept three HALL sensor signals. Each of the three input of HALL sensors provides a pulse that applied to an input capture pin, can then be analyzed and both speed and position can be deduced.
GD32E50x User Manual Figure 18-23. Hall sensor timing between two timers Advanced/General L0 TIMER_in under input capture mode CH0_INPUT CH1_INPUT CH2_INPUT CI0(OXR) Counter CH0VAL Advanced TIMER_out under output compare mode(PWM with Dead -time) CH0_O CH0_ON CH1_O CH1_ON CH2_O CH2_ON Master-slave management The TIMERx can be synchronized with a trigger in several modes including the restart mode, the pause mode and the event mode which is selected by the SMC [2:0] in the TIMERx_SMCFG register.
GD32E50x User Manual Mode Selection Source Selection Polarity Selection Filter and Prescaler 101: CI0FE0 If ETIFP is selected as prescaler can be 110: CI1FE1 the trigger source, used. 111: ETIFP configure the ETP for For the ETIFP, filter polarity selection and can be used by inversion.
GD32E50x User Manual Mode Selection Source Selection Polarity Selection Filter and Prescaler Figure 18-25. Pause m ode TIMER_CK CNT_REG CI0FE0 TRGIF Event m ode ETPSC = 1, ETI is The counter w ill start ETP = 0, the polarity TRGS[2:0] =3’b111 divided by 2.
GD32E50x User Manual counter. However, there exist several clock delays to perform the comparison result between the counter value and the TIMERx_CHxCV value. In order to reduce the delay to a minimum value, the user can set the CHxCOMFEN bit in each TIMERx_CHCTL0/1 register. After a trigger rising occurs in the single pulse mode, the OxCPRE signal will immediately be forced to the state which the OxCPRE signal will change to, as the compare match event occurs without taking the comparison result into account.
Page 382
GD32E50x User Manual Figure 18-28. Timer0 master/slave mode example TIMER 14 TIMER0 TRGS Master ITI0 TRGO mode Prescaler Counter control TIMER 1 Master ITI1 TRGO mode Prescaler Counter control TIMER 2 Trigger Master ITI2 selection TRGO mode Prescaler Counter control CI0F_ED CI0FE0 CI1FE1...
GD32E50x User Manual Select TIMER2 as TIMER0 input trigger source (TRGS=3’b010 in the TIMERx_SMCFG register). Configure TIMER0 in event mode (SMC=3’b110 in the TIMER0_SMCFG register). When the CI0 signal of TIMER2 generates a rising edge, two timer counters start counting synchronously with the internal clock and both TRGIF flags are set.
Page 384
GD32E50x User Manual Timer debug mode When the Cortex®-M33 halted, and the TIMERx_HOLD configuration bit in DBG_CTL0 register is set to 1, the TIMERx counter stops.
GD32E50x User Manual TIMERx registers(x=0, 7) 18.1.5. TIMER0 base address: 0x4001 2C00 TIMER7 base address: 0x4001 3400 Control register 0 (TIMERx_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved CKDIV[1:0] ARSE CAM[1:0] UPDIS...
Page 386
GD32E50x User Manual can be set. After the counter is enabled, cannot be sw itched from 0x00 to non 0x00. Direction 0: Count up 1: Count dow n If the timer w ork in center-aligned mode or quadrature decode mode, this bit is read only.
Page 387
GD32E50x User Manual Reserved Reserved ISO3 ISO2N ISO2 ISO1N ISO1 ISO0N ISO0 TI0S MMC[2:0] DMAS CCUC Reserved CCSE Bits Fields Descriptions 31:15 Reserved Must be kept at reset value. ISO3 Idle state of channel 3 output Refer to ISO0 bit ISO2N Idle state of channel 2 complementary output Refer to ISO0N bit...
Page 388
GD32E50x User Manual 001: Enable. When a conter start event occurs, a TRGO trigger signal is output. The counter start source : CEN control bit is set The trigger input in pause mode is high 010: When an update event occurs, a TRGO trigger signal is output. The update source depends on UPDIS bit and UPS bit.
Page 389
GD32E50x User Manual Reserved SMC1 ETPSC[1:0] ETFC[3:0] TRGS[2:0] Reserved SMC[2:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value External trigger polarity This bit specifies the polarity of ETI signal 0: ETI is active at rising edge or high level . 1: ETI is active at falling edge or low level .
Page 390
GD32E50x User Manual EXTFC[3:0] Tim es SAMP 4’b0000 Filter disabled. 4’b0001 4’b0010 TIMER_CK 4’b0011 4’b0100 DTS_CK 4’b0101 4’b0110 DTS_CK 4’b0111 4’b1000 DTS_CK 4’b1001 4’b1010 4’b1011 DTS_CK 4’b1100 4’b1101 4’b1110 DTS_CK 4’b1111 Master-slave mode This bit can be used to synchronize selected timers to begin counting at the same time.
Page 391
GD32E50x User Manual 010: Quadrature decoder mode 1.The counter counts on CI1FE1 edge, w hile the direction depends on CI0FE0 level. 011: Quadrature decoder mode 2.The counter counts on both CI0FE0 and CI1FE1 edge, w hile the direction depends on each other. 100: Restart mode.
Page 393
GD32E50x User Manual Reserved Reserved CH3OF CH2OF CH1OF CH0OF Reserved BRKIF TRGIF CMTIF CH3IF CH2IF CH1IF CH0IF UPIF rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 Bits Fields Descriptions 31:13 Reserved Must be kept at reset value. CH3OF Channel 3 over capture flag Refer to CH0OF description...
Page 394
GD32E50x User Manual Refer to CH0IF description Channel 2 ‘s capture/compare interrupt flag CH2IF Refer to CH0IF description Channel 1 ‘s capture/compare interrupt flag CH1IF Refer to CH0IF description Channel 0 ‘s capture/compare interrupt flag CH0IF This flag is set by hardw are and cleared by softw are. When channel 0 is in input mode, this flag is set w hen a capture event occurs.
Page 395
GD32E50x User Manual set, the TRGIF flag in TIMERx_INTF register is set, related interrupt or DMA transfer can occur if enabled. 0: No generate a trigger event 1: Generate a trigger event CMTG Channel commutation event generation This bit is set by softw are and cleared by hardw are automatically. When this bit is set, channel’s capture/compare control...
Page 396
GD32E50x User Manual Reserved CH1COM CH1COM CH1COM CH0COM CH0COM CH0COM CH1COMCTL[2:0] CH0COMCTL[2:0] CH1MS[1:0] CH0MS[1:0] CH1CAPFLT[3:0] CH1CAPPSC[1:0] CH0CAPFLT[3:0] CH0CAPPSC[1:0] Output com pare m ode: Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. CH1COMCEN Channel 1 output compare clear enable Refer to CH0COMCEN description 14:12 CH1COMCTL[2:0]...
Page 397
GD32E50x User Manual equals to the output compare register TIMERx_CH0CV. 010: Clear the channel output. O0CPRE signal is forced low w hen the counter is equals to the output compare register TIMERx_CH0CV. 011: Toggle on match. O0CPRE toggles w hen the counter is equals to the output compare register TIMERx_CH0CV.
Page 398
GD32E50x User Manual 11: Channel 0 is programmed as input mode, IS0 is connected to ITS Note: When CH0MS[1:0]=11, it is necessary to select an internal trigger input through TRGS bits in TIMERx_SMCFG register. Input capture m ode: Bits Fields Descriptions 31:16 Reserved...
Page 399
GD32E50x User Manual 00: Prescaler disable, input capture occurs on every channel input edge 01: The input capture occurs on every 2 channel input edges 10: The input capture occurs on every 4 channel input edges 11: The input capture occurs on every 8 channel input edges CH0MS[1:0] Channel 0 mode selection Same as Output compare mode...
Page 400
GD32E50x User Manual Note: When CH3MS[1:0]=11, it is necessary to select an internal trigger input through TRGS bits in TIMERx_SMCFG register. CH2COMCEN Channel 2 output compare clear enable. When this bit is set, if the ETIFP signal is detected as high level, the O2CPRE signal w ill be cleared.
Page 401
GD32E50x User Manual CH2COMFEN Channel 2 output compare fast enable When this bit is set, the effect of an event on the trigger in input on the capture/compare output w ill be accelerated if the channel is configured in PWM1 or PWM2 mode.
Page 402
GD32E50x User Manual 4’b0100 4’b0101 4’b0110 4’b0111 4’b1000 4’b1001 4’b1010 4’b1011 4’b1100 4’b1101 4’b1110 4’b1111 CH2CAPPSC[1:0] Channel 2 input capture prescaler This bit-field specifies the factor of the prescaler on channel 2 input. The prescaler is reset w hen CH2EN bit in TIMERx_CHCTL2 register is clear. 00: Prescaler disable, input capture occurs on every channel input edge 01: The input capture occurs on every 2 channel input edges 10: The input capture occurs on every 4 channel input edges...
Page 403
GD32E50x User Manual CH2NP Channel 2 complementary output polarity Refer to CH0NP description CH2NEN Channel 2 complementary output enable Refer to CH0NEN description CH2P Channel 2 capture/compare function polarity Refer to CH0P description CH2EN Channel 2 capture/compare function enable Refer to CH0EN description CH1NP Channel 1 complementary output polarity Refer to CH0NP description...
Page 404
GD32E50x User Manual trigger operation in slave mode. And CIxFE0 w ill not be inverted. [CH0NP==0, CH0P==1]: CIxFE0’s falling edge is the active signal for capture or trigger operation in slave mode. And CIxFE0 w ill be inverted. [CH0NP==1, CH0P==0]: Reserved. [CH0NP==1, CH0P==1]: Reserved.
Page 405
GD32E50x User Manual PSC[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 PSC[15:0] Prescaler value of the counter clock The TIMER_CK clock is divided by (PSC+1) to generate the counter clock. The value of this bit-filed w ill be loaded to the corresponding shadow register at every update event.
Page 406
GD32E50x User Manual 31:8 Reserved Must be kept at reset value. CREP[7:0] Counter repetition value This bit-filed specifies the update event generation rate. Each time the repetition counter counting dow n to zero, an update event is generated. The update rate of the shadow registers is also affected by this bit-filed w hen these shadow registers are enabled.
Page 407
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CH1VAL[15:0] Capture or compare value of channel1 When channel 1 is configured in input mode, this bit-filed indicates the counter value corresponding to the last capture event. And this bit-filed is read-only. When channel 1 is configured in output mode, this bit-filed contains value to be compared to the counter.
Page 408
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CH3VAL[15:0] Capture or compare value of channel 3 When channel3 is configured in input mode, this bit-filed indicates the counter value corresponding to the last capture event. And this bit-filed is read-only. When channel 3 is configured in output mode, this bit-filed contains value to be compared to the counter.
Page 409
GD32E50x User Manual This bit can be modified only w hen PROT [1:0] bit-filed in TIMERx_CCHP register is 00. BRKP Break input polarity This bit specifies the polarity of the BRKIN input signal. 0: BRKIN input active low 1; BRKIN input active high BRKEN Break input enable This bit can be set to enable the BRKIN and CKM clock failure event inputs.
Page 410
GD32E50x User Manual This bit-field can be w ritten only once after the reset. Once the TIMERx_ CCHP register has been w ritten, this bit-field w ill be w riting protected. DTCFG[7:0] Dead time configure The relationship betw een DTVAL value and the duration of dead-time is as follow : DTCFG[7:5] The duration of dead-time 3’b0xx...
Page 411
GD32E50x User Manual DMA transfer buffer register (TIMERx_DMATB) Address offset: 0x4C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved DMATB[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 DMATB[15:0] DMA transfer buffer When a read or w rite operation is assigned to this register, the register located at the address range (Start Addr + Transfer Timer* 4) w ill be accessed.
Page 412
GD32E50x User Manual 1: If POEN and IOS is 0, the output disabled 0: No effect...
GD32E50x User Manual General level0 timer (TIMERx, x=1, 2, 3, 4) 18.2. Overview 18.2.1. The general level0 timer module (Timer1, 2, 3, 4) is a four-channel timer that supports input capture, output compare. They can generate PWM signals to control motor or be used for power management applications.
GD32E50x User Manual Figure 18-31. Timing chart of internal clock divided by 1 CK_TIMER update event generate(UPG) Reload Pulse Update event (UPE) PSC_CLK = TIMER_CK CNT_REG SMC [2:0] == 3’b111( external clock mode 0 ). External input pin source The TIMER_CK, which drives counter’s prescaler to count, can be triggered by the event of rising or falling edge on the external pin TIMERx_CI0/TIMERx_CI1.
GD32E50x User Manual Figure 18-32. Timing chart of PSC value change from 0 to 2 TIMER_CK PSC value Prescaler shadow Prescaler CNT PSC_CLK CNT_REG Reload Pulse Counter up counting In this mode, the counter counts up continuously from 0 to the counter-reload value, which is defined in the TIMERx_CAR register, in a count-up direction.
GD32E50x User Manual Counter down counting In this mode, the counter counts down continuously from the counter-reload value, which is defined in the TIMERx_CAR register, to 0 in a count-down direction. Once the counter reaches to 0, the counter will start counting down from the counter-reload value. The update event is generated at each counter underflow.
GD32E50x User Manual And CHxIF is asserted. If the CHxIF is high, the CHxOF will be ass erted also. The interrupt and DMA request will be asserted based on the your configuration of CHxIE and CHxDEN in TIMERx_DMAINTEN Direct generation: If you want to generate a DMA request or interrupt, you can set CHxG by software directly.
GD32E50x User Manual So the process can be divided to several steps as below: Step1: Clock configuration. Such as clock source, clock prescaler and so on. Step2: Compare mode configuration. * Set the shadow enable mode by CHxCOMSEN * Set the output mode (Set/Clear/Toggle) by CHxCOMCTL. * Select the active high polarity by CHxP * Enable the output by CHxEN Step3: Interrupt/DMA-request enables configuration by CHxIE/CxCDE...
GD32E50x User Manual The EAPWM period is determined by TIMERx_CAR and duty cycle is by TIMERx_CHxCV. Figure 18-41. Timing chart of EAPWM shows the EAPWM output and interrupts waveform. The CAPWM period is determined by 2*TIMERx_CAR, and duty cycle is determined by 2*TIMERx_CHxCV.
GD32E50x User Manual Figure 18-42. Timing chart of CAPWM CHxVAL PWM MODE0 Cx OUT PWM MODE1 Cx OUT Interrupt signal CAM=2'b01 down only CHxIF CAM=2'b10 up only CHxIF CAM=2'b11 up/down CHxIF Channel output prepare signal (x=0,1,2,3), when the As is shown in Figure 18-39.
GD32E50x User Manual The OxCPRE signal can be forced to 0 when the ETIFE signal is derived from the external ETI pin and when it is set to a high level by setting the CHxCOMCEN bit to 1 in the TIMERx_CHCTL0 register.
GD32E50x User Manual Mode Selection Source Selection Polarity Selection Filter and Prescaler Figure 18-43. Restart m ode TIMER_CK CNT_REG UPIF ITI0 Internal sync delay TRGIF Pause m ode TI0S=0 (Non-xor) The counter w ill be [CH0NP=0, CH0P=0] paused w hen the TRGS[2:0]=3’b101 CI0FE0 does not Filter is bypassed in...
GD32E50x User Manual Mode Selection Source Selection Polarity Selection Filter and Prescaler Figure 18-45. Event m ode Single pulse mode Single pulse mode Refer to Timers interconnection Advanced timer (TIMERx, x=0, 7). Refer to Timer DMA mode Timer’s DMA mode is the function that configures timer’s register by DMA module. The relative registers are TIMERx_DMACFG and TIMERx_DMATB;...
GD32E50x User Manual TIMERx registers(x=1, 2, 3, 4) 18.2.5. TIMER1 base address: 0x4000 0000 TIMER2 base address: 0x4000 0400 TIMER3 base address: 0x4000 0800 TIMER4 base address: 0x4000 0C00 Control register 0 (TIMERx_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 430
GD32E50x User Manual center-aligned and channel is configured in output mode (CHxMS=00 TIMERx_CHCTL0 register). Both w hen counting up and counting dow n, CHxF bit can be set. After the counter is enabled, cannot be sw itched from 0x00 to non 0x00. Direction 0: Count up 1: Count dow n...
Page 431
GD32E50x User Manual This register has to be accessed by word (32-bit). Reserved Reserved TI0S MMC[2:0] DMAS Reserved Bits Fields Descriptions 31:8 Reserved Must be kept at reset value. TI0S Channel 0 trigger input selection 0: The TIMERx_CH0 pin input is selected as channel 0 trigger input. 1: The result of combinational XOR of TIMERx_CH0, CH1 and CH2 pins is selected as channel 0 trigger input.
Page 432
GD32E50x User Manual Reserved Must be kept at reset value. Slave mode configuration register (TIMERx_SMCFG) Address offset: 0x08 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved SMC1 ETPSC[1:0] ETFC[3:0] TRGS[2:0] Reserved SMC[2:0] Bits Fields Descriptions 31:16 Reserved...
Page 433
GD32E50x User Manual The external trigger can be filtered by digital filter and this bit-field configure the filtering capability. Basic principle of digital filter: continuously sample the external trigger signal according to f and record the number of times of the same level of the signal. SAMP After reaching the filtering capacity configured by this bit-field, it is considered to be an effective level.
Page 434
GD32E50x User Manual Reserved Must be kept at reset value. SMC[2:0] Slave mode control 000: Disable mode. The slave mode is disabled; The prescaler is clocked directly by the internal clock (TIMER_CK) w hen CEN bit is set high. 001: Quadrature decoder mode 0.The counter counts on CI0FE0 edge, w hile the direction depends on CI1FE1 level.
Page 436
GD32E50x User Manual Reserved Reserved CH3OF CH2OF CH1OF CH0OF Reserved TRGIF Reserved CH3IF CH2IF CH1IF CH0IF UPIF rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 Bits Fields Descriptions 31:13 Reserved Must be kept at reset value. CH3OF Channel 3 over capture flag Refer to CH0OF description CH2OF Channel 2 over capture flag...
Page 437
GD32E50x User Manual mode, this flag is set w hen a compare event occurs. If Channel0 is set to input mode, this bit w ill be reset by reading TIMERx_CH0CV. 0: No Channel 0 interrupt occurred 1: Channel 0 interrupt occurred UPIF Update interrupt flag This bit is set by hardw are on an update event and cleared by softw are.
Page 438
GD32E50x User Manual 0, it is automatically cleared by hardw are. When this bit is set, the CH1IF flag is set, the corresponding interrupt or DMA request is sent if enabled. In addition, if channel 1 is configured in input mode, the current value of the counter is captured in TIMERx_CH0CV register, and the CH0OF flag is set if the CH0IF flag w as already high.
Page 439
GD32E50x User Manual This bit-field specifies the direction of the channel and the input signal selection. This bit-field is w ritable only w hen the channel is not active. (CH1EN bit in TIMERx_CHCTL2 register is reset). 00: Channel 1 is programmed as output mode 01: Channel 1 is programmed as input mode, IS1 is connected to CI1FE1 10: Channel 1 is programmed as input mode, IS1 is connected to CI0FE1 11: Channel 1 is programmed as input mode, IS1 is connected to ITS.
Page 440
GD32E50x User Manual The PWM mode can be used w ithout verifying the shadow register only in single pulse mode (w hen SPM=1) CH0COMFEN Channel 0 output compare fast enable When this bit is set, the effect of an event on the trigger in input on the capture/compare output w ill be accelerated if the channel is configured in PWM0 or PWM1 mode.
Page 441
GD32E50x User Manual 4’b0010 4’b0011 4’b0100 4’b0101 4’b0110 4’b0111 4’b1000 4’b1001 4’b1010 4’b1011 4’b1100 4’b1101 4’b1110 4’b1111 CH0CAPPSC[1:0] Channel 2 input capture prescaler This bit-field specifies the factor of the prescaler on channel 2 input. The prescaler is reset w hen CH2EN bit in TIMERx_CHCTL2 register is clear. 00: Prescaler disable, input capture occurs on every channel input edge 01: The input capture occurs on every 2 channel input edges 10: The input capture occurs on every 4 channel input edges...
Page 442
GD32E50x User Manual Refer to CH0COMCEN description 14:12 CH3COMCTL[2:0] Channel 3 compare output control Refer to CH0COMCTL description CH3COMSEN Channel 3 output compare shadow enable Refer to CH0COMSEN description CH3COMFEN Channel 3 output compare fast enable Refer to CH0COMFEN description CH3MS[1:0] Channel 3 mode selection This bit-field specifies the direction of the channel and the input signal selection.
Page 443
GD32E50x User Manual than TIMERx_CH2CV, and high otherw ise. When counting dow n, O2CPRE is high w hen the counter is larger than TIMERx_CH2CV , and low otherw ise. If configured in PWM mode, the O2CPRE level changes only w hen the output compare mode is adjusted from “Timing”...
Page 444
GD32E50x User Manual CH2CAPFLT[3:0] Channel 2 input capture filter control The CI2 input signal can be filtered by digital filter and this bit-field configure the filtering capability. Basic principle of digital filter: continuously sample the CI2 input signal according to and record the number of times of the same level of the signal.
Page 445
GD32E50x User Manual CH3NP Reserved CH3P CH3EN CH2NP Reserved CH2P CH2EN CH1NP Reserved CH1P CH1EN CH0NP Reserved CH0P CH0EN Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. CH3NP Channel 3 complementary output polarity Refer to CH0NP description Reserved Must be kept at reset value.
Page 446
GD32E50x User Manual 0: Channel 0 high level is active level 1: Channel 0 low level is active level When channel 0 is configured in input mode, this bit specifies the CI0 signal polarity. [CH0NP, CH0P] w ill select the active trigger or capture polarity for CI0FE0 or CI1FE0.
Page 447
GD32E50x User Manual Reserved CNT[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CNT[15:0] This bit-filed indicates the current counter value. Writing to this bit-filed can change the value of the counter. Prescaler register (TIMERx_PSC) Address offset: 0x28 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 448
GD32E50x User Manual Bits Fields Descriptions 31:0 CARL[31:0] Counter auto reload value This bit-filed specifies the auto reload value of the counter. Counter auto reload register (TIMERx_CAR) (x=2,3,4) Address offset: 0x2C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved CARL[15:0] Bits...
Page 449
GD32E50x User Manual compared to the counter. When the corresponding shadow register is enabled, the shadow register updates every update event. Channel 0 capture/compare value register (TIMERx_CH0CV) (x=2,3,4) Address offset: 0x34 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved CH0VAL[15:0] Bits...
Page 450
GD32E50x User Manual When channel 1 is configured in output mode, this bit-filed contains value to be compared to the counter. When the corresponding shadow register is enabled, the shadow register updates every update event. Channel 1 capture/compare value register (TIMERx_CH1CV) (x=2,3,4) Address offset: 0x38 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 451
GD32E50x User Manual corresponding to the last capture event. And this bit-filed is read-only. When channel 2 is configured in output mode, this bit-filed contains value to be compared to the counter. When the corresponding shadow register is enabled, the shadow register updates every update event.
Page 452
GD32E50x User Manual When channel3 is configured in input mode, this bit-filed indicates the counter value corresponding to the last capture event. And this bit-filed is read-only. When channel 3 is configured in output mode, this bit-filed contains value to be compared to the counter.
Page 453
GD32E50x User Manual 31:13 Reserved Must be kept at reset value. 12:8 DMATC [4:0] DMA transfer count This filed defines the number(n) of the register that DMA w ill access(R/W), n = (DMATC [4:0] +1). DMATC [4:0] is from 5’b0_0000 to 5’b1_0001. Reserved Must be kept at reset value.
Page 454
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 DMATB[15:0] DMA transfer buffer When a read or w rite operation is assigned to this register, the register located at the address range (Start Addr + Transfer Timer* 4) w ill be accessed. The transfer Timer is calculated by hardw are, and ranges from 0 to DMATC.
GD32E50x User Manual General level1 timer (TIMERx, x=8, 11) 18.3. Overview 18.3.1. The general level1 timer module (Timer8, 11) is a two-channel timer that supports input capture, output compare. They can generate PWM signals to control motor or be used for power management applications.
GD32E50x User Manual Figure 18-47. Timing chart of internal clock divided by 1 CK_TIMER update event generate(UPG) Reload Pulse Update event (UPE) PSC_CLK = TIMER_CK CNT_REG SMC [2:0] == 3’b111 ( external clock mode 0 ). External input pin source The TIMER_CK, driven counter’s prescaler to count, can be triggered by the event of rising or falling edge on the external pin TIMERx_CI0/TIMERx_CI1.
GD32E50x User Manual Figure 18-48. Timing chart of PSC value change from 0 to 2 TIMER_CK PSC value Prescaler shadow Prescaler CNT PSC_CLK CNT_REG Reload Pulse Counter up counting In this mode, the counter counts up continuously from 0 to the counter-reload value, which is defined in the TIMERx_CAR register, in a count-up direction.
GD32E50x User Manual Input capture and output compare channels The general level1 timer has two independent channels which can be used as capture inputs or compare match outputs. Each channel is built around a channel capture compare register including an input stage, channel controller and an output stage. ...
GD32E50x User Manual Rising or falling edge, choose one by CHxP/CHxNP. Step3: Capture source selection. (CHxMS in TIMERx_CHCTL0) As soon as you select one input capture source by CHxMS, you have set the channel to input mode (CHxMS!=0x0) and TIMERx_CHxCV cannot be written any more. Step4: Interrupt enable.
GD32E50x User Manual If the output of OxCPRE is active(high) level, the output of CHx_O is active(high) level; If the output of OxCPRE is inactive(low) level, the output of CHx_O is active(low) level. In Output Compare mode, the TIMERx can generate timed pulses with programmable position, polarity, duration, and frequency.
GD32E50x User Manual Output PWM function In the output PWM function (by setting the CHxCOMCTL bits to 3’b110 (PWM mode0) or to 3’b 111(PWM mode1), the channel can generate PWM waveform according to the TIMERx_CAR registers and TIMERx_CHxCV registers. The period is determined by TIMERx_CAR and duty cycle is determined by TIMERx_CHxCV. Figure 18-54.
GD32E50x User Manual Another special function of the OxCPRE signal is a forced output which can be achieved by setting the CHxCOMCTL field to 0x04/0x05. Here the output can be forced to an inactive/active level irrespective of the comparison condition between the counter and the TIMERx_CHxCV values.
GD32E50x User Manual Mode Selection Source Selection Polarity Selection Filter and Prescaler and it w ill start w hen rising edge only. the trigger input is high. Figure 18-56. Pause m ode TIMER_CK CNT_REG CI0FE0 TRGIF Event m ode CH0P=0, The counter w ill start CI0FE0 does not TRGS[2:0]=3’b101...
GD32E50x User Manual a pulse and then keep the CEN bit at a high state until the update event occurs or the CEN bit is written to 0 by software. If the CEN bit is cleared to 0 using software, the counter will be stopped and its value held.
GD32E50x User Manual TIMERx registers(x=8, 11) 18.3.5. TIMER8 base address: 0x4001 4C00 TIMER11 base address: 0x4000 1800 Control register 0 (TIMERx_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved CKDIV[1:0] ARSE Reserved UPDIS...
Page 468
GD32E50x User Manual The counter generates an overflow or underflow event UPDIS Update disable. This bit is used to enable or disable the update event generation. 0: Update event enable. When an update event occurs, the corresponding shadow registers are loaded w ith their preloaded values. These events generate update event: The UPG bit is set The counter generates an overflow or underflow event...
Page 469
GD32E50x User Manual synchronize the counter. 000: ITI0 001: ITI1 010: ITI2 011: ITI3 100: CI0F_ED 101: CI0FE0 110: CI1FE1 111: Reserved. These bits must not be changed w hen slave mode is enabled. Reserved Must be kept at reset value. SMC[2:0] Slave mode control 000: Disable mode.
Page 471
GD32E50x User Manual trigger input can generates a trigger event. 0: No trigger event occurred. 1: Trigger interrupt occurred. Reserved Must be kept at reset value. Channel 1 ‘s capture/compare interrupt flag CH1IF Refer to CH0IF description Channel 0 ‘s capture/compare interrupt flag CH0IF This flag is set by hardw are and cleared by softw are.
Page 472
GD32E50x User Manual Channel 1’s capture or compare event generation CH1G Refer to CH0G description Channel 0’s capture or compare event generation CH0G This bit is set by softw are in order to generate a capture or compare event in channel 0, it is automatically cleared by hardw are.
Page 473
GD32E50x User Manual This bit-field specifies the direction of the channel and the input signal selection. This bit-field is w ritable only w hen the channel is not active. (CH1EN bit in TIMERx_CHCTL2 register is reset). 00: Channel 1 is programmed as output mode 01: Channel 1 is programmed as input mode, IS1 is connected to CI1FE1 10: Channel 1 is programmed as input mode, IS1 is connected to CI0FE1 11: Channel 1 is programmed as input mode, IS1 is connected to ITS.
Page 474
GD32E50x User Manual capture/compare output w ill be accelerated if the channel is configured in PWM0 or PWM1 mode. The output channel w ill treat an active edge on the trigger input as a compare match, and CH0_O is set to the compare level independently from the result of the comparison.
Page 475
GD32E50x User Manual 4’b0110 4’b0111 4’b1000 4’b1001 4’b1010 4’b1011 4’b1100 4’b1101 4’b1110 4’b1111 CH0CAPPSC[1:0] Channel 0 input capture prescaler This bit-field specifies the factor of the prescaler on channel 0 input. The prescaler is reset w hen CH0EN bit in TIMERx_CHCTL2 register is clear. 00: Prescaler disable, input capture occurs on every channel input edge 01: The input capture occurs on every 2 channel input edges 10: The input capture occurs on every 4 channel input edges...
Page 476
GD32E50x User Manual CH1EN Channel 1 capture/compare function enable Refer to CH1EN description CH0NP Channel 0 complementary output polarity When channel 0 is configured in output mode, this bit should be keep reset value. When channel 0 is configured in input mode, together w ith CH0P, this bit is used to define the polarity of CI0.
Page 477
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CNT[15:0] This bit-filed indicates the current counter value. Writing to this bit-filed can change the value of the counter. Prescaler register (TIMERx_PSC) Address offset: 0x28 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 478
GD32E50x User Manual This bit-filed specifies the auto reload value of the counter. Channel 0 capture/compare value register (TIMERx_CH0CV) Address offset: 0x34 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved CH0VAL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value.
Page 479
GD32E50x User Manual When channel 1 is configured in output mode, this bit-filed contains value to be compared to the counter. When the corresponding shadow register is enabled, the shadow register updates every update event. Configuration register (TIMERx_CFG ) Address offset: 0xFC Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
GD32E50x User Manual General level2 timer (TIMERx, x=9, 10, 12, 13) 18.4. Overview 18.4.1. The general level2 timer module (Timer9, 10, 12, 13) is a one-channel timer that supports input capture, output compare. They can generate PWM signals to control motor or be used for power management applications.
GD32E50x User Manual Figure 18-60. Timing chart of internal clock divided by 1 CK_TIMER update event generate(UPG) Reload Pulse Update event (UPE) PSC_CLK = TIMER_CK CNT_REG Clock prescaler The counter clock (PSC_CK) is obtained by the TIMER_CK through the prescaler, and the prescale factor can be configured from 1 to 65536 through the prescaler register (TIMERx_PSC).
GD32E50x User Manual Counter up counting In this mode, the counter counts up continuously from 0 to the counter-reload value, which is defined in the TIMERx_CAR register, in a count-up direction. Once the counter reaches the counter reload value, the counter will start counting up from 0 again. The update event is generated at each counter overflow.
GD32E50x User Manual Figure 18-64. Channel input capture principle Edge Detector Synchronizer Edge selector &inverter Based on Filter CH0P&CH0NP TIMER_CK CI0FE0 Rising/Falling Capture Clock presclare Register Processer (CH0VAL) CH0IF CH0CAPPSC CH0_CC_I CH0IE CH0MS TIMERx_CC_INT Capture INT From Other Channal First, the channel input signal (CIx) is synchronized to TIMER_CK domain, and then sampled by a digital filter to generate a filtered input signal.
GD32E50x User Manual software directly. The channel input capture function can be also used for pulse width measurement from signals on the TIMERx_CHx pins. For example, PWM signal connect to CI0 input. Select channel 0 capture signals to CI0 by setting CH0MS to 2’b01 in the channel control register (TIMERx_CHCTL0) and set capture on rising edge.
GD32E50x User Manual * Select the active high polarity by CHxP/CHxNP * Enable the output by CHxEN Step3: Interrupt/DMA-request enables configuration by CHxIE Step4: Compare output timing configuration by TIMERx_CAR and TIMERx_CHxCV. About the CHxVAL, you can change it on the go to meet the waveform you expected. Step5: Start the counter by CEN.
Page 488
GD32E50x User Manual relative bit definition. Another special function of the OxCPRE signal is a forced output which can be achieved by setting the CHxCOMCTL field to 0x04/0x05. Here the output can be forced to an inactive/active level irrespective of the comparison condition between the counter and the TIMERx_CHxCV values.
GD32E50x User Manual TIMERx registers(x=9, 10, 12, 13) 18.4.5. TIMER9 base address: 0x4001 5000 TIMER10 base address: 0x4001 5400 TIMER12 base address: 0x4000 1C00 TIMER13 base address: 0x4000 2000 Control register 0 (TIMERx_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 490
GD32E50x User Manual UPDIS Update disable. This bit is used to enable or disable the update event generation. 0: Update event enable. When an update event occurs, the corresponding shadow registers are loaded w ith their preloaded values. These events generate update event: The UPG bit is set The counter generates an overflow or underflow event...
Page 491
GD32E50x User Manual The trigger input in pause mode is high 010: When an update event occurs, a TRGO trigger signal is output. The update source depends on UPDIS bit and UPS bit. 011: When a capture or compare pulse event occurs in channel0, a TRGO trigger signal is output.
Page 492
GD32E50x User Manual Reserved CH0OF Reserved. CH0IF UPIF rc_w0 rc_w0 rc_w0 Bits Fields Descriptions 31:10 Reserved Must be kept at reset value. CH0OF Channel 0 over capture flag When channel 0 is configured in input mode, this flag is set by hardw are w hen a capture event occurs w hile CH0IF flag has already been set.
Page 493
GD32E50x User Manual Channel 0’s capture or compare event generation CH0G This bit is set by softw are in order to generate a capture or compare event in channel 0, it is automatically cleared by hardw are. When this bit is set, the CH1IF flag is set, the corresponding interrupt or DMA request is sent if enabled.
Page 494
GD32E50x User Manual compare register TIMERx_CH0CV. 100: Force low . O0CPRE is forced to low level. 101: Force high. O0CPRE is forced to high level. 110: PWM mode0. When counting up, O0CPRE is high w hen the counter is smaller than TIMERx_CH0CV, and low otherw ise.
Page 495
GD32E50x User Manual filtering capability. Basic principle of digital filter: continuously sample the CI0 input signal according to and record the number of times of the same level of the signal. After reaching SAMP the filtering capacity configured by this bit, it is considered to be an effective level. The filtering capability configuration is as follow s: CH0CAPFLT [3:0] Tim es...
Page 496
GD32E50x User Manual Reserved.. CH0NP Reserved CH0P CH0EN Bits Fields Descriptions 31:4 Reserved Must be kept at reset value. CH0NP Channel 0 complementary output polarity When channel 0 is configured in output mode, this bit specifies the complementar y output signal polarity. 0: Channel 0 complementary output high level is active level 1: Channel 0 complementary output low level is active level When channel 0 is configured in input mode, together w ith CH0P, this bit is used to...
Page 497
GD32E50x User Manual Reserved CNT[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CNT[15:0] This bit-filed indicates the current counter value. Writing to this bit-filed can change the value of the counter. Prescaler register (TIMERx_PSC) Address offset: 0x28 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 498
GD32E50x User Manual CARL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CARL[15:0] Counter auto reload value This bit-filed specifies the auto reload value of the counter. Channel 0 capture/compare value register (TIMERx_CH0CV) Address offset: 0x34 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 499
GD32E50x User Manual Bits Fields Descriptions 31:2 Reserved Must be kept at reset value. CHVSEL Write CHxVAL register selection This bit-field set and reset by softw are. 1: If w rite the CHxVAL register, the w rite value is same as the CHxVAL value, the w rite access ignored 0: No effect Reserved...
GD32E50x User Manual Basic timer (TIMERx, x=5, 6) 18.5. Overview 18.5.1. The basic timer module (Timer5, 6) reference is a 16-bit counter that can be used as an unsigned counter. The basic timer can be configured to generate DMA request and TRGO to DAC.
GD32E50x User Manual Figure 18-68. Timing chart of internal clock divided by 1 CK_TIMER update event generate(UPG) Reload Pulse Update event (UPE) PSC_CLK = TIMER_CK CNT_REG Clock prescaler The counter clock (PSC_CK) is obtained by the TIMER_CK through the prescaler, and the prescale factor can be configured from 1 to 65536 through the prescaler register (TIMERx_PSC).
GD32E50x User Manual Counter up counting In this mode, the counter counts up continuously from 0 to the counter-reload value, which is defined in the TIMERx_CAR register, in a count-up direction. Once the counter reaches the counter reload value, the counter will start counting up from 0 again. The update event is generated at each counter overflow.
GD32E50x User Manual TIMERx registers(x=5, 6) 18.5.5. TIMER5 base address: 0x4000 1000 TIMER6 base address: 0x4000 1400 Control register 0 (TIMERx_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved ARSE Reserved UPDIS Bits...
Page 505
GD32E50x User Manual The counter generates an overflow or underflow event The restart mode generates an update event. 1: Update event disable. Note: When this bit is set to 1, setting UPG bit or the restart mode does not generate an update event, but the counter and prescaler are initialized.
Page 506
GD32E50x User Manual Interrupt enable register (TIMERx_DMAINTEN) Address offset: 0x0C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved UPDEN Reserved UPIE Bits Fields Descriptions 31:9 Reserved Must be kept at reset value. UPDEN Update DMA request enable 0: disabled 1: enabled...
Page 507
GD32E50x User Manual 1: Update interrupt occurred Software event generation register (TIMERx_SWEVG) Address offset: 0x14 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved Bits Fields Descriptions 31:1 Reserved Must be kept at reset value. This bit can be set by softw are, and cleared by hardw are automatically.
Page 508
GD32E50x User Manual Prescaler register (TIMERx_PSC) Address offset: 0x28 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved PSC[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 PSC[15:0] Prescaler value of the counter clock The TIMER_CK clock is divided by (PSC+1) to generate the counter clock.
GD32E50x User Manual Super High-Resolution Timer (SHRTIMER) 19.1. Overview SHRTIMER has a super high-resolution counting clock and can be used for high-precision timing. It can generate 10 super high resolution and flexible digital signals to control motor or be used for power management applications. The 10 digital signals can be output independently or coupled into 5 pairs of complementary signals.
GD32E50x User Manual below: CNTCKDIV[2:0]+1 SHRTIMER_PSCCK SHRTIMER_HPCK When the CNTCKDIV[3] bit in SHRTIMER_MTACTL register is ‘1’, the CNTCKDIV[2:0] bit- filed can only be configured with ‘3’b000’ and the frequency relationship between SHRTIMER_PSCCK and SHRTIMER_HPCK can be expressed below: SHRTIMER_PSCCK SHRTIMER_HPCK Note: The clock division CNTCKDIV[3:0] cannot be modified once the Master_TIMER is enabled.
GD32E50x User Manual In single pulse mode, after setting the bit MTCEN in SHRTIMER_MTCTL0 register, the first reset event will start the counter. When counting up to the counter-reload value, the counter stops and generates a period event. Then the other reset event will reset and restart the counter.
GD32E50x User Manual Repetition counter When MTCEN bit in SHRTIMER_MTCTL0 register is set to 1, the repetition counter load the value of SHRTIMER_MTCREP register. The repetition counter is decremented when the counter is cleared due to either a roll-over event in continuous mode or a reset event. When the repetition counter has reached zero, the coming roll-over event in continuous mode or reset event will generate a repetition event and reload the value of SHRTIMER_MTCREP register.
GD32E50x User Manual shows repetition counter operation diagram in single pulse mode with CNTRSTM = 1. Figure 19-8. Repetition counter behavior in single pulse mode with CNTRSTM = 1 MTCEN or STxCEN(x=0..4) Reset event CARL CARL Counter when CTNM = 0 CNTRSTM = 1 CREP[7:0] 0x03...
GD32E50x User Manual the counter value matches the compare registers value, a coincident compare event is generated. The compare event will set the corresponding compare interrupt flag to 1 (CMPxIF bit in SHRTIMER_MTINTF where x=0..3), and a compare interrupt or DMA request is issued if enabled (CMPxIE = 1 or CMPxDEN = 1 bits in SHRTIMER_MTDMAINTEN register where x=0..3).
Page 517
GD32E50x User Manual Table 19-3. Master_TIMER shadow registers and update event Registers Shadow registers Update event. that contain shadow registers enable bit SHRTIMER_MTDMAINTEN Software(MTSUP bit) SHRTIMER_MTCAR Repetition event(UPREP = 1) DMA mode end SHRTIMER_MTCREP SHWEN bit in event(UPSEL[1:0] = 2’b01) SHRTIMER_MT SHRTIMER_MTCMP0V CTL0 register...
GD32E50x User Manual Slave_TIMERx(x=0..4) unit 19.4.2. The SHRTIMER has 5 slave timers with similar structure: Slave_TIMERx(x=0..4). Each unit is built around the following components: 16-bit counter. Auto reload register: counting period. Repetition counter. Compare y (y=0..3) register. ...
GD32E50x User Manual counter clock division below 64 (CNTCKDIV[3:0] < 4’b0101 or CNTCKDIV[3:0] =4’b1000), Table the least significant bits are not significant. They cannot be written and read 0. Refer to 19-4. The limitations of counter and capture y(y=0,1) value registers. Table 19-4.
Page 520
GD32E50x User Manual the SHRTIMER_STxCAR register. There are two counter operating modes: single pulse mode (CTNM = 0 in SHRTIMER_STxCTL0 register) and continuous mode (CTNM = 1 in SHRTIMER_STxCTL0 register). In single pulse mode, after setting the bit STxCEN in SHRTIMER_MTCTL0 register, the first reset event will start the counter.
Page 521
GD32E50x User Manual All these sources are logical ORed, they can be valid simultaneously. If multiple reset events occur in the same t cycle, only the last one is valid. The counter reset requests are SHRTIMER_CK taken into account only once the related Slave_TIMERx are enabled Note: If the external events is configured with level sensitivity, only one external events can be enabled in the SHRTIMER_STxCNTRST register.
GD32E50x User Manual The capture 0 trigger events are defined in SHRTIMER_STxCAP0TRG register and the capture 1 trigger events are defined in SHRTIMER_STxCAP1TRG register. All the trigger events are logical ORed and they are all valid when multiple trigger events are selected. Note: If the external events is configured with level sensitivity, only one external events can be enabled in the SHRTIMER_STxCAPyTRG(y=0,1) register.
GD32E50x User Manual Figure 19-12.Compare 1 behavior with STxCAR=0x8, STxCMP1V=0x02 Cleared by CMP1IFC Cleared by CMP1IFC Half mode When HALFM bit in SHRTIMER_STxCTL0 is set to 1, the half mode is enabled. This mode forces the value of compare 0 active register to be half of the counter-reload value, but the value of SHRTIMER_STxCMP0V register is not updated with the SHRTIMER_MTCAR/2 value.
GD32E50x User Manual generated. Once the relative capture is triggered, the value in compare y active register is summed with the relative SHRTIMER_STxCAP0V/ SHRTIMER_STxCAP1V, and it is compared to the counter. Compare 1 is associated with capture 0 and compare 0/2, while compare 3 is associated with capture 1 and compare 0/2.
GD32E50x User Manual Compare 1 event occurs as soon as the counter value is equal to the recomputed compare 1 value. If capture 0 trigger occurs first, the later compare 0 event is ignored. If compare 0 event occurs first, the capture 0 trigger after the compare 1 event is ignored. Refer to Figure 19-15.
GD32E50x User Manual Figure 19-16. Compare delayed mode with SHWEN = 0 MTCEN or STxCEN(x=0..4) previous+ C1 C2+ C1 update event Counter when CTNM = 1 Preload=previous Active=previous + C1 Capture event C a p t u r e C a p t u r e previous register register...
GD32E50x User Manual Output prepare signal Slave_TIMERx has a set/reset output module. The module can generate two output prepare signals: O0PRE and O1PRE. O0PRE is controlled by SHRTIMER_STxCH0SET and SHRTIMER_STxCH0RST registers. O1PRE is controlled by SHRTIMER_STxCH1SET and SHRTIMER_STxCH1RST registers. The high level of OyPRE(y=0,1) is active level, while the low level is inactive level.
GD32E50x User Manual Slave_TIMERx interconnection event: there are 9 interconnect events from other Slave_TIMERy (for instance x=1, then y=0, 2..4). Refer to Table 19-5. Slave_TIMER interconnection event External event y(y=0..9): EXEVy conditioned by external event filter in Slave_TIMERx ...
GD32E50x User Manual Figure 19-19. Arbitration The arbitration process for each type of event is shown in mechanism during each tSHRTMER_CK period Figure 19-19. Arbitration mechanism during each t period SHRTMER_CK Arbiter0: Arbiter0: STx interconnection Arbiter1: only one event Arbiter1: Arbiter2: CMP3>...
GD32E50x User Manual Figure 19-21. A pulse of 1 t period SHRTMER_CK SHRTIMER_CK SHRTIMER_CK OxPRE postponed super high- resolution SHRTIMER_CK OxPRE super high- anticipated resolution super high- OxPRE postponed resolution SHRTIMER_CK super high- OxPRE SHRTIMER_CK resolution anticipated Legend: set request reset request If the “set and reset requests”...
GD32E50x User Manual active edge of the SHRTIMER_PSCCK, even if the arbitration is still performed every cycle. SHRTIMER_CK When “set and reset requests” from different event sources simultaneously occur in a tSHRTIMER_CK cycle, the “reset request” has the highest priority. In SHRTIMER_PSCCK cycle, subsequent requests override previous requests, and only the last request of that cycle Figure 19-24.
Page 533
GD32E50x User Manual O0PRE will be set to high level. SHRTIMER_STxCH0RST = 0x0000 0010: compare 1 event produces “reset request” and O0PRE will be set to low level. SHRTIMER_STxCMP0V = 0x0060 SHRTIMER_STxCMP1V = 0x00E0 Figure 19-25. C0OPRE wave in regular mode SHRTIMER_CK 0x00 0x20...
GD32E50x User Manual When the Slave_TIMERx(x=0..4) runs in the RUN or IDEL state and the C0OPRE goes from active to inactive level, CH0ONAIF bit in SHRTIMER_STxINTF register will be set to 1, and a output inactive interrupt or a DMA request is issued if enabled (CH0ONAIE = 1 or CH0ONADEN = 1 bit in SHRTIMER_STxDMAINTEN register).
GD32E50x User Manual inactive level (low level). When the output of toggle logic module is 0(low level), C1OPRE is connected to O1PRE and C0OPRE is set to inactive level (low level). It is advised to make SHRTIMER_STxCH0SET = SHRTIMER_STxCH1SET and SHRTIMER_STxCH0RST = SHRTIMER_STxCH1RST, in order to achieve a balanced operation with identical waveforms.
GD32E50x User Manual Table 19-7. Request to enter in IDLE and SHRTIMER_STxCHOCTL register. Refer to exit IDLE state. ISOy define the CHyOPRE level in IDLE state. The IDLE mode is permanently maintained but the counter continues to run, until the output is re-enabled to exit delayed IDLE.
GD32E50x User Manual Figure 19-30. ISO0 = 0 and CHOP = 0 in delayed IDLE SHRTIMER_STxCMP1V active value Conuter SHRTIMER_STxCMP0V active value C0OPRE re-enable EXEV6 ISO0 = 0 CH0P = 0 CH0OPRE RUN State RUN State IDLE State re-enable EXEV6 ISO0 = 0 CH0P = 0 CH0OPRE...
GD32E50x User Manual Figure 19-32. ISO0 = 0 and CHOP = 1 in delayed IDLE SHRTIMER_STxCMP1V active value Conuter SHRTIMER_STxCMP0V active value C0OPRE re-enable EXEV6 ISO0 = 0 CH0P = 1 CH0OPRE RUN State RUN State IDLE State re-enable EXEV6 ISO0 = 0 CH0P = 1 CH0OPRE...
GD32E50x User Manual When the selected event arrives, the CHyOPRE (y=0,1) enters IDLE state and takes the level defined by ISOy bits in the SHRTIMER_STxCHOCTL register. Meanwhile the DLYIIF in SHRTIMER_STxINTF register is set to 1.The selected external event triggers a capture of the counter value into the compare 3 active register (this value is not user-accessible).
GD32E50x User Manual Balanced IDLE can be used together with the bunch mode under the following conditions: BMSTx bit must be reset (counter clock(SHRTIMER_PSCCK) is maintained and the counter operates normally) No balanced IDLE are triggered while the outputs are in IDLE state controlled by bunch mode.
GD32E50x User Manual Table 19-9. Output stage status programming (x=0..4, y=0,1) STxCHyEN STxCHyDISF output stage status Run state Idle state Fault state Note: “×” means “0/1”. Writing 1 to STxCHyDIS in SHRTIMER_CHOUTDIS register will disable output and make output stage enters the Idle state. The priority order of the three states is: Idle state > Fault state >...
GD32E50x User Manual 19-36. Carrier-signal structure diagram. Figure 19-36. Carrier-signal structure diagram Carrier-signal generator 0 CH0CSEN Carrier-signal generator 1 O0PRE CH1CSEN SHRTIMER_CSGCK O1PRE prescaler: CH1CSEN/ CH0CSEN SHRTIMER_CK IDLE CH0OPRE CH1OPRE In carrier-signal mode, it is possible to define a specific pulse width before the beginning of the carrier-signal.
GD32E50x User Manual (logic ANDed). The carrier-signal signal is stopped as soon as the OyPRE(y=0,1) is inactive, Figure 19-37. SHRTIMER even if the current carrier period is not completed. Refer to output with carrier-signal mode enabled. Figure 19-37. SHRTIMER output with carrier-signal mode enabled Compare 1 active value Slave_TIMER0...
GD32E50x User Manual active register and take effect immediately on update event. Table 19-10. Slave_TIMERx shadow registers and update event lists the registers that contain shadow registers and corresponding update events. Table 19-10. Slave_TIMERx shadow registers and update event Registers Shadow registers Update event.
GD32E50x User Manual Windowing mode: external events that occur within a specified time are taken into account. Figure 19-38. Blanking mode and windowing mode Refer to Figure 19-38. Blanking mode and windowing mode EXEVyC EXEVyC EXEVy EXEVy Blanking mode Windowing mode Windowing signal Blanking signal...
GD32E50x User Manual DAC trigger When the Slave_TIMERx update event occurs with DACTRGS[1:0] != 2’b00 in SHRTIMER_STxCTL0 register, a DAC trigger request can be generated SHRTIMER_DACTRIGOy(y=0..3). If DACTRGS[1:0] = 2’b00 in SHRTIMER_STxCTL0 register, Slave_TIMERx won’t generate trigger request. SHRTIMER_DACTRIGOy(y=0..3) is the internal signal connected from Slave_TIMERx to the DAC module.
GD32E50x User Manual the counter-reload value (SHRTIMER_BMCAR), the BM-counter is stopped. When counts up to the counter-reload value (SHRTIMER_BMCAR), BMPERIF in SHRTIMER_INTF register is set to 1 and bunch mode controller generates a bunch mode period interrupt request if BMPERIE=1 in SHRTIMER_INTEN register. The BMPERIF bit can be cleared by writing 1 to BMPERIFC bit in SHRTIMER_INTC register.
GD32E50x User Manual the SHRTIMER_BMCMPV compare register is written. Bunch mode entry There are 32 events defined in SHRTIMER_BMSTRG register can be used to trigger the bunch mode operation. These trigger events can be selected simultaneously and are logic ORed. During BM-counter counting process, these trigger events are ignored. These trigger events are divided into seven categories: 1.
Page 552
GD32E50x User Manual Figure 19-40. Regular entry for bunch mode Compare 1 active value Slave_TIMER0 OyPRE(y=0,1) EXEV Bunch mode termination. CHyOPRE(y=0,1) IDLE in bunch mode RUN in bunch mode ISOy=0 RUN state Bunch mode operation RUN state EXEV Bunch mode termination.
GD32E50x User Manual Period event is used to produce “set request”. Write two 32-bit data to the SHRTIMER_STxCMP0CP register consecutively using DMA (upon repetition event), as below: SHRTIMER_STxCMP0CP = {CREP[7:0] = (RUN number of periods - 1); CMP0VAL[15:0] = duty cycle} SHRTIMER_STxCMP0CP = {CREP[7:0] = (IDLE number of periods - 1);...
GD32E50x User Manual is re-started after having reached the period value in single pulse mode, a reset which occurs during the counting with CTNM or CNTRSTM bits set to 1. 2’b01: Master_TIMER compare 0 event 2’b10: Slave_TIMER0 reset and start event. It is similar to Master_TIMER start event, except for the following: counter roll-over in continuous mode, discarded reset request in single pulse mode with CNTRSTM=0.
GD32E50x User Manual external event y(y=5..9) are configured using the SHRTIMER_EXEVCFG0 and SHRTIMER_EXEVDFCTL registers. The process by which external event y(y=0..4) are processed is shown in Figure 19-43. Extern event y(y=0..4) processed diagram. Figure 19-43. Extern event y(y=0..4) processed diagram configuration of external event y(y=0..4) is as follows:...
GD32E50x User Manual The digital filters sampling clock f is defined with EXEVFDIV[2:0] bit-field in SHRTIMER_EXEVFCK SHRTIMER_EXEVDFCTL register. These external events sources EXEVySRCz(y=0..9,z=0..4) can come from comparators, digital input pins, ADC’s analog watchdogs and TIMER_TRGO. Refer to Table 19-15. External events mapping. Table 19-15.
GD32E50x User Manual Fault channel FLTyINSRC = 0 (input pin) FLTyINSRC = 1(com parator) Fault channel 4 PC7/PG10 Note: “×” means not available. The polarity of the signal can be configured by the FLTyINP polarity bit in SHRTIMER_FLTINCFG0 and SHRTIMER_FLTINCFG1 registers. If FLTyINP = 0, the signal is active at low level;...
GD32E50x User Manual Figure 19-46. Trigger to ADC selection overview SHRTIMER SHRTIMER_ADCTRIG0 SHRTIMER_ADCTRIGS0 SHRTIMER_ADCTRIGS1 SHRTIMER_ADCTRIG1 SHRTIMER_ADCTRIG2 SHRTIMER_ADCTRIGS2 SHRTIMER_ADCTRIGS3 SHRTIMER_ADCTRIG3 There are up to 32 events which can be combined (ORed) for each trigger output. They are defined in SHRTIMER_ADCTRIGSy(y=0..3) registers. SHRTIMER_ADCTRIGSy(y=0..3) registers are preloaded and can be updated synchronously with the timer they are related to.
GD32E50x User Manual Figure 19-47. Trigger to DAC selection overview Master_TIMER No trigger Update event SHRTIMER_DACTRIG0 DACTRGS[1:0] in SHRTIMER_MTCTL0 SHRTIMER_DACTRIG1 Slave_TIMERx No trigger SHRTIMER_DACTRIG2 Update event DACTRGS[1:0] in SHRTIMER_STxCTL0 Interrupt 19.4.10. Most events can generate interrupt requests. All interrupt requests are grouped in 7 vectors (SHRTIMER_IRQy,y=0..6).Refer to Table 19-17.
GD32E50x User Manual Interrupt Num ber Event Control bit Repetition event REPIE in SHRTIMER_STx DMA INTEN Slave_TIMER4: Compare 3 event CMP3IE in SHRTIMER_STx DMA INTEN SHRTIMER_IRQ5 Compare 2 event CMP2IE in SHRTIMER_STx DMA INTEN Compare 1 event CMP1IE in SHRTIMER_STx DMA INTEN Compare 0 event CMP0IE in SHRTIMER_STx DMA INTEN Bunch mode period event...
GD32E50x User Manual DMA mode 19.4.12. Timer’s DMA mode is the function that configures SHRTIMER’s multiple registers by DMA module with a single DMA request. The relative registers (7 registers in total) are as follows: SHRTIMER_DMAUPMTR: Defines which registers in the Master_TIMER are updated. Most of Master_TIMER control and data registers are associated with a selection bit.
GD32E50x User Manual Figure 19-48. DMA mode operation flowchart The DMA request to write SHRTIMER_DMATB Parse SHRTIMER_DMAUPSTyR(Y=1..3) register and The process is similar to Parse SHRTIMER_DMAUPST0R register Data is transferred to Data is transferred to MTCTL0 bit SHRTIMER_MTCTL0 ST0CTL0bit SHRTIMER_ST0CTL0 and trigger a new DMA is 1? is 1?
GD32E50x User Manual The registers can be segmented for ease of addressing: SHRTIMER Master_TIMER registers base address: 0x4001 7400 SHRTIMER Slave_TIMER0 registers base address: 0x4001 7480 SHRTIMER Slave_TIMER1 registers base address: 0x4001 7500 SHRTIMER Slave_TIMER2 registers base address: 0x4001 7580 SHRTIMER Slave_TIMER3 registers base address: 0x4001 7600 SHRTIMER Slave_TIMER4 registers base address: 0x4001 7680 SHRTIMER Common registers base address: 0x4001 7780...
Page 566
GD32E50x User Manual Note: UPREP can be set only if UPSEL[1:0] = 2’b00 or 2’b01. Reserved Must be kept at reset value SHWEN Shadow registers enable 0: The shadow registers are disabled 1: The shadow registers are enabled 26:25 DACTRGS[1:0] Trigger source to DAC The timer can also generate a DAC trigger event w hen an update event occurs.
Page 567
GD32E50x User Manual This bit-field specifies the event to be sent to the synchronization output pad SHRTIMER_SCOUT. 00: Master_TIMER start event. 01: Master_TIMER compare 0 event 10: Slave_TIMER0 reset and start event 11: Slave_TIMER0 compare 0 event 13:12 SYNOPLS[1:0] Synchronization output pulse This bit-field specifies...
Page 568
GD32E50x User Manual 1: The counter can be reset at any time (running or stopped). CTNM Continuous mode 0: Single pulse mode. The counter stops by hardw are w hen it reaches the SHRTIMER_MTCA R value. 1: Continuous mode. The counter rolls over to zero and count continuously w hen it reaches the SHRTIMER_MTCA R value CNTCKDIV[2:0] Counter clock division...
Page 569
GD32E50x User Manual This flag is set by hardw are w hen an update event occurs. 0: No update interrupt occurred 1: Update interrupt occurred SYNIIF Synchronization input interrupt flag This flag is set by hardw are w hen synchronization input occurs. 0: No synchronization input interrupt occurred 1: Synchronization input interrupt occurred REPIF...
Page 570
GD32E50x User Manual Bits Fields Descriptions 31:7 Reserved Must be kept at reset value UPIFC Clear update interrupt flag 0: No effect 1: Clear update interrupt flag SYNIIFC Clear synchronization input interrupt flag 0: No effect 1: Clear synchronization input interrupt flag REPIFC Clear repetition interrupt flag 0: No effect...
Page 571
GD32E50x User Manual Bits Fields Descriptions 31:23 Reserved Must be kept at reset value UPDEN Update DMA request enable 0: disabled 1: enabled SYNIDEN Synchronization input DMA request enable 0: disabled 1: enabled REPDEN Repetition DMA request enable 0: disabled 1: enabled CMP3DEN Compare 3 DMA request enable...
Page 572
GD32E50x User Manual 1: enabled CMP2IE Compare 2 interrupt enable 0: disabled 1: enabled CMP1IE Compare 1 interrupt enable 0: disabled 1: enabled CMP0IE Compare 0 interrupt enable 0: disabled 1: enabled SHRTIMER Master_TIMER counter register (SHRTIMER_MTCNT) Address offset: 0x10 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit) Reserved...
Page 573
GD32E50x User Manual This register has to be accessed by word (32-bit) Reserved CARL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CARL[15:0] Counter auto reload value This bit-field specifies the auto reload value of the counter. This register has a shadow register.
Page 574
GD32E50x User Manual shadow register. SHRTIMER Master_TIMER compare 0 value register (SHRTIMER_MTCMP0V) Address offset: 0x1C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit) Reserved CMP0VAL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value 15:0 CMP0VAL[15:0] Compare 0 value...
Page 575
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value 15:0 CMP1VAL[15:0] Compare 1 value This bit-field contains value to be compared to the counter. This register has a shadow register. If the shadow register is disabled (SHWEN = 0), it holds the content of the active register;...
Page 576
GD32E50x User Manual Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved CMP3VAL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value 15:0 CMP3VAL[15:0] Compare 3 value This bit-field contains value to be compared to the counter. This register has a shadow register.
GD32E50x User Manual super high resolution clock (SHRTIMER_HPCK) the counter clock (SHRTIMER_PSCCK). When the CNTCKDIV[3] is ‘0’, f CNTCKDIV[2:0]+1 SHRTIMER_PSCCK SHRTIMER_HPCK When the CNTCKDIV[3] bit in the SHRTIMER_MTACTL is ‘1’ and CNTCKDIV[2:0] can only be configured w ith ‘3’b000’: f SHRTIMER_PSSCK SHRTIMER_HPCK Note: The CNTCKDIV[3:0] bit-field cannot be modified once the timer is enabled...
Page 578
GD32E50x User Manual 0110: Update event generated on the update event follow ing the rising edge of STxUPIN0. 0111: Update event generated on the update event follow ing the rising edge of STxUPIN1. 1000: Update event generated on the update event follow ing the rising edge of STxUPIN2.
Page 579
GD32E50x User Manual Note: This bit does not exist in Slave_TIMER3. UPBST2 Update by Slave_TIMER2 update event When the bit is set, the Slave_TIMERx(x=0,1,3,4) update event are synchronized w ith Slave_TIMER2 update event and the active registers of them are updated by the Slave_TIMER2 update event 0: The active registers is not update by Slave_TIMER2.
Page 580
GD32E50x User Manual value for capture 1 event, or compare 3 active register value + compare 0 value for compare 0 event). Compare match occurs as soon as the counter equals the recalculated value. 11: Compare 3 delayed mode 2. After a capture 1 event or compare 2 event, the recalculated value of compare 3 is: (compare 3 active register value + capture 1 value for capture 1 event, or compare 3 active register value + compare 2 value for compare 2 event).
Page 581
GD32E50x User Manual in SHRTIMER_MTCTL0 register). HALFM Half mode When the bit is set, SHRTIMER_STx CMP0V active register is alw ays the half of counter auto-reload value (SHRTIMER_STx CAR). 0: Half mode disable. 1: Half mode enable. CNTRSTM Counter reset mode This bit defines the behavior of the timer counter in single pulse mode.
Page 582
GD32E50x User Manual Reserved CH1F CH0F Reserved BLNIF CBLNF CH1ONAI CH0ONAI Reserved DLYIIF RSTIF CH1OAIF CH0OAIF CAP1IF CAP0IF UPIF Reserved REPIF CMP3IF CMP2IF CMP1IF CMP0IF Bits Fields Descriptions 31:22 Reserved Must be kept at reset value CH1F Channel 1 output flag This bit indicates the output level state of channel 1.
Page 583
GD32E50x User Manual 0: No counter reset or roll-over interrupt occurred 1: Counter reset or roll-over interrupt occurred CH1ONAIF Channel 1 output inactive interrupt flag Refer to CH0ONAIF description. CH1OAIF Channel 1 output active interrupt flag Refer to CH0OAIF description. CH0ONAIF Channel 0 output inactive interrupt flag This flag is set by hardw are w hen channel 0 output inactive (C0OPRE from active...
Page 584
GD32E50x User Manual This flag is set by hardw are w hen a compare 2 event occurs. 0: No compare 2 interrupt occurred 1: Compare 2 interrupt occurred CMP1IF Compare 1 interrupt flag This flag is set by hardw are w hen a compare 1 event occurs. 0: No compare 1 interrupt occurred 1: Compare 1 interrupt occurred CMP0IF...
Page 585
GD32E50x User Manual Clear CH1OAIF in SHRTIMER_STx INTF register. Refer to CH0OAIFC description. CH0ONAIFC Clear channel 0 output inactive interrupt flag 0: No effect Clear channel output inactive interrupt flag (CH0ONAIF SHRTIMER_STx INTF register) CH0OAIFC Clear channel 0 output active interrupt flag 0: No effect 1: Clear channel 0 output inactive interrupt flag (CH0OAIF in SHRTIMER_STx INT F register)
Page 586
GD32E50x User Manual SHRTIMER Slave_TIMERx interrupt enable register (SHRTIMER_STxDMAINTEN) Address offset: 0x0C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) CH1ONAD CH1OADE CH0ONAD CH0OADE Reserved DLYIDEN RSTDEN CAP1DEN CAP0DEN UPDEN Reserved REPDEN CMP3DEN CMP2DEN CMP1DEN CMP0DEN CH1ONAI CH0ONAI Reserved...
Page 587
GD32E50x User Manual 1: enabled UPDEN Update DMA request enable 0: disabled 1: enabled Reserved Must be kept at reset value REPDEN Repetition DMA request enable 0: disabled 1: enabled CMP3DEN Compare 3 DMA request enable 0: disabled 1: enabled CMP2DEN Compare 2 DMA request enable 0: disabled...
Page 588
GD32E50x User Manual 1: enabled CAP1IE Capture 1 interrupt enable 0: disabled 1: enabled CAP0IE Capture 0 interrupt enable 0: disabled 1: enabled UPIE Update interrupt enable 0: disabled 1: enabled Reserved Must be kept at reset value REPIE Repetition interrupt enable 0: disabled 1: enabled CMP3IE...
Page 589
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 CNT[15:0] The current counter value. Writing to it can change the value of the counter only w hen the Slave_TIMERx is stopped (STxCEN = 0 in SHRTIMER_STx CTL0 register). Note: (1) For counter clock division below 64 (CNTCKDIV[3:0] <...
Page 590
GD32E50x User Manual SHRTIMER Slave_TIMERx counter repetition register (SHRTIMER_STxCREP) Address offset: 0x18 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved Reserved CREP[7:0] Bits Fields Descriptions 31:8 Reserved Must be kept at reset value. CREP[7:0] Counter repetition value This bit-field specifies the repetition event generation rate.
Page 591
GD32E50x User Manual 0), it holds the content of the active register; otherw ise, it holds the content of the shadow register. Note: (1) The minimum value must be greater than or equal to 3 t . For example: SHRTIMER_CK CARL[15:0] >= 0x60 w hen CNTCKDIV[3:0] = 4’b0000.
Page 592
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value 15:0 CMP1VAL[15:0] Compare 1 value This bit-field contains value to be compared to the counter. This register has a shadow register. If the shadow register is disabled (SHWEN = 0), it holds the content of the active register;...
Page 593
GD32E50x User Manual SHRTIMER Slave_TIMERx compare 3 value register (SHRTIMER_STxCMP3V) Address offset: 0x2C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved CMP3VAL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value 15:0 CMP3VAL[15:0] Compare 3 value This bit-field contains value to be compared to the counter.
Page 594
GD32E50x User Manual 31:16 Reserved Must be kept at reset value 15:0 CAP0VAL[15:0] Capture 0 value This bit-field indicates the counter value corresponding to the last capture event. And this bit-field is read-only. Note: For counter clock division below 64 (CNTCKDIV[3:0] < 5), the least significant bits of the counter are not significant.
Page 595
GD32E50x User Manual DTRSVP DTRSPR DTGCKDIV[3:0] DTRS DTRCFG[8:0] Bits Fields Descriptions DTFSVPROT Dead-time falling edge protection for value and sign This bit-field specifies the w rite protection for dead-time falling edge (value and sign). 0: Protect disable. DTFS and DTFCFG[15:0] are w ritable. 1: Protect enable.
Page 596
GD32E50x User Manual DTRSPROT Dead-time rising edge protection for sign This bit-field specifies the w rite protection for dead-time rising edge (only sign). 0: protect disable. DTRS in SHRTIMER_STx DTCTL register is w ritable. 1: protect enable. DTRS in SHRTIMER_STx DTCTL register is read-only. Note: This bit is not preloaded 13:10 DTGCKDIV[3:0]...
Page 597
GD32E50x User Manual SHRTIMER Slave_TIMERx channel request register (SHRTIMER_STxCH0SET) Address offset: 0x3C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SEXE CH0SSTE CH0SSTE CH0SSTE CH0SSTE CH0SSTE CH0SUP CH0SST CH0SSTE CH0SSTE...
Page 598
GD32E50x User Manual Refer to CH0SEXEV0 description. External event 0 generates channel 0 “set request” CH0SEXEV0 When this bit is set, external event 0 can generate “set request”. 0: The event cannot generate “set request”. 1: The event can generate “set request”. Slave_TIMERx interconnection event 8 generates channel 0 “set request”...
Page 599
GD32E50x User Manual 1: The event can generate “set request”. Master_TIMER compare 0 event generates channel 0 “set request” CH0SMTCMP0 When this bit is set, Master_TIMER compare 0 event can generate “set request”. 0: The event cannot generate “set request”. 1: The event can generate “set request”.
Page 600
GD32E50x User Manual set, it can generate channel 0 “set request”. 0: The event cannot generate “set request”. 1: The event can generate “set request”. Note: This bit is not preloaded SHRTIMER Slave_TIMERx channel reset request register (SHRTIMER_STxCH0RST) Address offset: 0x40 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) CH0RSU...
Page 602
GD32E50x User Manual When this bit is set, Master_TIMER compare 2 event can generate channel “reset request”. 0: The event cannot generate “reset request”. 1: The event can generate “reset request”. Master_TIMER compare 1 event generates channel 0 “reset request” CH0RSMTCMP1 When this bit is set, Master_TIMER compare 1 event can generate channel “reset request”.
Page 603
GD32E50x User Manual Slave_TIMERx period event generates channel 0 “reset request” CH0RSPER When this bit is set, Slave_TIMERx period event can generate channel “reset request”. 0: The event cannot generate “reset request”. 1: The event can generate “reset request”. Slave_TIMERx reset event generates channel 0 “reset request” CH0RSRST When this bit is set, Slave_TIMERx reset event from synchronous input and softw are can generate channel “reset request”.
Page 604
GD32E50x User Manual Refer to CH1SEXEV0 description. External event 8 generates channel 1 “set request” CH1SEXEV8 Refer to CH1SEXEV0 description. External event 7 generates channel 1 “set request” CH1SEXEV7 Refer to CH1SEXEV0 description. External event 6 generates channel 1 “set request” CH1SEXEV6 Refer to CH1SEXEV0 description.
Page 605
GD32E50x User Manual Slave_TIMERx interconnection event 1 generates channel 1 “set request” CH1SSTEV1 Refer to CH1SSTEV0 description. Slave_TIMERx interconnection event 0 generates channel 1 “set request” CH1SSTEV0 When this bit is set, Slave_TIMERx interconnection event 0 can generate “set request”. Refer to Table 19-5.
Page 606
GD32E50x User Manual 0: The event cannot generate “set request”. 1: The event can generate “set request”. Slave_TIMERx compare 0 event generates channel 1 “set request” CH1SCMP0 When this bit is set, Slave_TIMERx compare 0 event can generate “set request”. 0: The event cannot generate “set request”.
Page 607
GD32E50x User Manual Update event generates channel 1 “reset request” CH1RSUP When this bit is set, update event can generate “reset request”. 0: The event cannot generate “reset request”. 1: The event can generate “reset request”. External event 9 generates channel 1 “reset request” CH1RSEXEV9 Refer to CH1RSEXEV0 description.
Page 609
GD32E50x User Manual request”. 0: The event cannot generate “reset request”. 1: The event can generate “reset request”. Slave_TIMERx compare 2 event generates channel 1 “reset request” CH1RSCMP2 When this bit is set, Slave_TIMERx compare 2 event can generate channel “reset request”.
Page 610
GD32E50x User Manual SHRTIMER Slave_TIMERx external event filter configuration register 0 (SHRTIMER_STxEXEVFCFG0) Address offset: 0x4C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) EXEV4FM[3:0] EXEV4ME EXEV3FM[3:0] EXEV3ME EXEV2FM Reserved Reserved Reserved EXEV0ME EXEV1FM[3:0] EXEV1ME EXEV0FM[3:0] EXEV0M EXEV2FM[2:0] Reserved Reserved...
Page 611
GD32E50x User Manual Reserved Must be kept at reset value EXEV0FM[3:0] External event 0 filter mode In blanking mode, the external event is ignored if it occurs during a blank. In w indow ing mode, the external event is taken into account only if it occurs w ithin a given time w indow .
Page 612
GD32E50x User Manual SHRTIMER Slave_TIMERx external event filter configuration register 1 (SHRTIMER_STxEXEVFCFG1) Address offset: 0x50 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) EXEV9FM[3:0] EXEV9ME EXEV8FM[3:0] EXEV8ME EXEV7FM Reserved Reserved Reserved EXEV7ME EXEV6FM[3:0] EXEV6ME EXEV5FM[3:0] EXEV5M EXEV7FM[2:0] Reserved Reserved...
Page 613
GD32E50x User Manual Reserved Must be kept at reset value EXEV5FM[3:0] External event 5 filter mode Refer to EXEV0FM[3:0] in SHRTIMER_STx EXEVFCFG0 description. EXEV5MEEN External event 0 memorized enable Refer to EXEV0MEEN in SHRTIMER_STx EXEV FCFG0 description. SHRTIMER Slave_TIMERx counter reset register (SHRTIMER_STxCNTRST) Address offset: 0x54 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit)
Page 614
GD32E50x User Manual counter. 0: Slave_TIMER3 compare 0 event do not reset counter 1: Slave_TIMER3 compare 0 event resets counter ST2CMP3RST Slave_TIMER2 compare 3 event resets counter Refer to ST2CMP0RST description. ST2CMP1RST Slave_TIMER2 compare 1 event resets counter Refer to ST2CMP0RST description. ST2CMP0RST Slave_TIMER2 compare 0 event resets counter This bit specifies w hether the Slave_TIMER2 compare 0 event can reset the...
Page 615
GD32E50x User Manual Refer to EXEV0RST description. EXEV1RST External event 1 resets counter Refer to EXEV0RST description. EXEV0RST External event 0 resets counter This bit specifies w hether the External event 0 can reset the counter. 0: External event 0 do not reset counter. 1: External event 0 resets counter.
Page 616
GD32E50x User Manual ST4CMP3 ST4CMP1 ST4CMP0 ST3CMP3 ST3CMP1 ST3CMP0 ST2CMP3 ST2CMP1 ST2CMP0 ST0CMP3 ST0CMP1 ST0CMP0 EXEV9RS EXEV8RS EXEV7RS Reserved EXEV6R EXEV5RS EXEV4RS EXEV3RS EXEV2RS EXEV1RS EXEV0RS MTCMP3 MTCMP2 MTCMP1 MTCMP0 MTPERRS CMP3RST CMP1RST UPRST Reserved Bits Fields Descriptions Reserved Must be kept at reset value ST4CMP3RST Slave_TIMER4 compare 3 event resets counter Refer to ST4CMP0RST description.
Page 617
GD32E50x User Manual Refer to ST0CMP0RST description. ST0CMP1RST Slave_TIMER0 compare 1 event resets counter Refer to ST0CMP0RST description. ST0CMP0RST Slave_TIMER0 compare 0 event resets counter This bit specifies w hether the Slave_TIMER0 compare 0 event can reset the counter. 0: Slave_TIMER0 compare 0 event do not reset counter 1: Slave_TIMER0 compare 0 event resets counter EXEV9RST External event 9 resets counter...
Page 618
GD32E50x User Manual MTCMP0RST Master_TIMER compare 0 event resets counter This bit specifies w hether the Master_TIMER compare 0 event can reset the counter. 0: Master_TIMER compare 0 event do not reset counter 1: Master_TIMER compare 0 event resets counter MTPERRST Master_TIMER period event resets counter This bit specifies w hether the Master_TIMER period event can reset the counter.
Page 619
GD32E50x User Manual This bit specifies w hether the Slave_TIMER4 compare 0 event can reset the counter. 0: Slave_TIMER4 compare 0 event do not reset counter 1: Slave_TIMER4 compare 0 event resets counter ST3CMP3RST Slave_TIMER3 compare 3 event resets counter Refer to ST3CMP0RST description.
Page 620
GD32E50x User Manual EXEV6RST External event 6 resets counter Refer to EXEV0RST description. EXEV5RST External event 5 resets counter Refer to EXEV0RST description. EXEV4RST External event 4 resets counter Refer to EXEV0RST description. EXEV3RST External event 3 resets counter Refer to EXEV0RST description. EXEV2RST External event 2 resets counter Refer to EXEV0RST description.
Page 621
GD32E50x User Manual UPRST Slave_TIMER2 update event resets counter This bit specifies w hether the update event can reset the counter. 0: Update event do not reset counter 1: Update event resets counter Reserved Must be kept at reset value For Slave_TIMER3 ST4CMP3 ST4CMP1...
Page 622
GD32E50x User Manual Refer to ST1CMP0RST description. ST1CMP1RST Slave_TIMER1 compare 1 event resets counter Refer to ST1CMP0RST description. ST1CMP0RST Slave_TIMER1 compare 0 event resets counter This bit specifies w hether the Slave_TIMER1 compare 0 event can reset the counter. 0: Slave_TIMER1 compare 0 event do not reset counter 1: Slave_TIMER1 compare 0 event resets counter ST0CMP3RST Slave_TIMER0 compare 3 event resets counter...
Page 623
GD32E50x User Manual This bit specifies w hether the External event 0 can reset the counter. 0: External event 0 do not reset counter. 1: External event 0 resets counter. MTCMP3RST Master_TIMER compare 3 event resets counter Refer to MTCMP0RST description MTCMP2RST Master_TIMER compare 2 event resets counter Refer to MTCMP0RST description...
Page 624
GD32E50x User Manual EXEV6R EXEV5RS EXEV4RS EXEV3RS EXEV2RS EXEV1RS EXEV0RS MTCMP3 MTCMP2 MTCMP1 MTCMP0 MTPERRS CMP3RST CMP1RST UPRST Reserved Bits Fields Descriptions Reserved Must be kept at reset value ST3CMP3RST Slave_TIMER3 compare 3 event resets counter Refer to ST3CMP0RST description. ST3CMP1RST Slave_TIMER3 compare 1 event resets counter Refer to ST3CMP0RST description.
Page 625
GD32E50x User Manual ST0CMP0RST Slave_TIMER0 compare 0 event resets counter This bit specifies w hether the Slave_TIMER0 compare 0 event can reset the counter. 0: Slave_TIMER0 compare 0 event do not reset counter 1: Slave_TIMER0 compare 0 event resets counter EXEV9RST External event 9 resets counter Refer to EXEV0RST description.
Page 626
GD32E50x User Manual 1: Master_TIMER compare 0 event resets counter MTPERRST Master_TIMER period event resets counter This bit specifies w hether the Master_TIMER period event can reset the counter. 0: Master_TIMER period event do not reset counter 1: Master_TIMER period event resets counter CMP3RST Slave_TIMER4 compare 3 event resets counter Refer to CMP1RST description...
Page 627
GD32E50x User Manual … 1110: t = 15*t CSFSTPW SHRTIMER_CSGCK 1111: t = 16*t CSFSTPW SHRTIMER_CSGCK CSDTY[2:0] Carrier signal duty cycle This bit-field defines the duty cycle of carrier signal (except the first pulse) w hich is equal to CSDTY[2:0]/8. 000: 0%(only the first pulse is present).
Page 628
GD32E50x User Manual This bit reserved only in Slave_TIMER4. Refer to CP0BST0CMP0 description. CP0BST4NA Capture 0 triggered by ST4CH0_O output active to inactive transition This bit reserved only in Slave_TIMER4. Refer to CP0BST0NA description. CP0BST4A Capture 0 triggered by ST4CH0_O output inactive to active transition This bit reserved only in Slave_TIMER4.
Page 629
GD32E50x User Manual Refer to CP0BST0CMP0 description. CP0BST1NA Capture 0 triggered by ST1CH0_O output active to inactive transition This bit reserved only in Slave_TIMER1. Refer to CP0BST0NA description. CP0BST1A Capture 0 triggered by ST1CH0_O output inactive to active transition This bit reserved only in Slave_TIMER1. Refer to CP0BST0A description.
Page 630
GD32E50x User Manual Refer to CP0BEXEV0 description. CP0BEXEV3 Capture 0 triggered by external event 3 Refer to CP0BEXEV0 description. CP0BEXEV2 Capture 0 triggered by external event 2 Refer to CP0BEXEV0 description. CP0BEXEV1 Capture 0 triggered by external event 1 Refer to CP0BEXEV0 description. CP0BEXEV0 Capture 0 triggered by external event 0 When the bit is set, capture 0 is triggered by external event 0...
Page 631
GD32E50x User Manual Refer to CP1BST0CMP1 description. CP1BST4CMP0 Capture 1 triggered by compare 0 event of Slave_TIMER4 This bit reserved only in Slave_TIMER4. Refer to CP1BST0CMP0 description. CP1BST4NA Capture 1 triggered by ST4CH0_O output active to inactive transition. This bit reserved only in Slave_TIMER4. Refer to CP1BST0NA description.
Page 632
GD32E50x User Manual CP1BST1CMP0 Capture 1 triggered by compare 0 event of Slave_TIMER1 This bit reserved only in Slave_TIMER1. Refer to CP1BST0CMP0 description. CP1BST1NA Capture 1 triggered by ST1CH0_O output active to inactive transition This bit reserved only in Slave_TIMER1. Refer to CP1BST0NA description.
Page 633
GD32E50x User Manual Refer to CP1BEXEV0 description. CP1BEXEV4 Capture 1 triggered by external event 4 Refer to CP1BEXEV0 description. CP1BEXEV3 Capture 1 triggered by external event 3 Refer to CP1BEXEV0 description. CP1BEXEV2 Capture 1 triggered by external event 2 Refer to CP1BEXEV0 description. CP1BEXEV1 Capture 1 triggered by external event 1 Refer to CP1BEXEV0 description.
Page 634
GD32E50x User Manual Bits Fields Descriptions 31:24 Reserved Must be kept at reset value BMCH1DTI Channel 1 dead-time insert in bunch mode In bunch mode, a dead-time can be inserted before output entering the IDLE state. 0: The output enter IDLE immediately. 1: Dead-time is inserted before entering the IDLE state.
Page 635
GD32E50x User Manual 16:13 Reserved Must be kept at reset value 12:10 DLYISCH[2:0] Delayed IDLE source and channel This bit-field specifies the source and channel on w hich the delayed IDLE state mode are enabled (DLYISMEN = 1). In SHRTIMER_STy CHOCTL(y=0,1,2) register: 000: channel 0 output delayed IDLE on external event 5 001: channel 1 output delayed IDLE on external event 5 010: channel 0 and channel 1 output delayed IDLE on external event 5...
Page 636
GD32E50x User Manual by DTRCFG[15:0] Note: (1) This bit must not be modified once the counter is enabled (STxCEN bit set). (2) This bit can be set only if one of the output idle state is active (ISO0 = 1, y=0,1) during IDLE in bunch mode, and the dead-time value is positive (DTFSPROT / DTRSPROT set to 0).
Page 637
GD32E50x User Manual This register has to be accessed by word(32-bit) FLTENP Reserved Reserved FLT4EN FLT3EN FLT2EN FLT1EN FLT0EN Bits Fields Descriptions FLTENPROT Protect fault enable This bit-field specifies w hether the w rite protection function is enable or not. This bit is w rite-once.
Page 638
GD32E50x User Manual DTFCFG[15:9] Reserved CNTCKDI DTRCFG[15:9] Reserved Reserved V[3] Bits Fields Descriptions 31:25 DTFCFG[15:9] Falling edge dead-time value configure This bit-field controls the value of the dead-time follow ing a falling edge of output prepare signal (OyPRE,y=0,1): DTFvalue = DTFCFG[15:0]x SHRTIMER_DTGCK = 1/ f SHRTIMER_DTGCK...
GD32E50x User Manual Common registers 19.5.3. SHRTIMER Master_TIMER registers base address: 0x4001 7780 SHRTIMER control register 0 (SHRTIMER_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved ADTG3USRC[2:0] ADTG2USRC [2:0] ADTG1USRC [2:0] ADTG0USRC [2:0] Reserved ST4UPDIS ST3UPDIS ST2UPDIS ST1UPDIS ST0UPDIS MTUPDIS Bits...
Page 640
GD32E50x User Manual 000: Master_TIMER update event 001: Slaver_TIMER0 update event 010: Slaver_TIMER1 update event 011: Slaver_TIMER2 update event 100: Slaver_TIMER3 update event 101: Slaver_TIMER4 update event Other values are reserved 18:16 ADTG0USRC[2:0] SHRTIMER_A DCTRIG0 update source This bit-field can be configured by softw are to specify the the source to update the SHRTIMER_A DCTRIGS0 register.
Page 641
GD32E50x User Manual 0: Update event enable. 1: Update event disable. SHRTIMER control register 1 (SHRTIMER_CTL1) Address offset: 0x04 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved Reserved ST4SRST ST3SRST ST2SRST ST1SRST ST0SRST MTSRST Reserved ST4SUP ST3SUP ST2SUP ST1SUP ST0SUP MTSUP Bits...
Page 642
GD32E50x User Manual bit is set, the counter is reset. 0: No effect. 1: The counter is reset. MTSRST Master_TIMER softw are reset This bit can be set by softw are, and cleared by hardw are automatically. When this bit is set, the counter is reset. 0: No effect.
Page 643
GD32E50x User Manual This bit can be set by softw are, and cleared by hardw are automatically. When this bit is set, the content of shadow register is transferred to the active register and any pending update request is cancelled. 0: No effect.
Page 644
GD32E50x User Manual FLT3IF Fault 3 interrupt flag Refer to FLT0IF description. FLT2IF Fault 2 interrupt flag Refer to FLT0IF description. FLT1IF Fault 1 interrupt flag Refer to FLT0IF description. FLT0IF Fault 0 interrupt flag This flag is set by hardw are w hen the fault 0 occurred. It is cleared by softw are w riting it at 1.
Page 645
GD32E50x User Manual Writing 1 to this bit clears the SYSFLTIF in SHRTIMER_INTF register. 0: No effect 1: Clear system fault completed interrupt flag FLT4IFC Clear fault 4 interrupt flag Writing 1 to this bit clears the FLT4IF in SHRTIMER_INTF register. Refer to FLT0IF description.
Page 646
GD32E50x User Manual 0: disabled 1: enabled 15:6 Reserved Must be kept at reset value SYSFLTIE System fault interrupt enable 0: disabled 1: enabled Reserved Must be kept at reset value SHRTIMER channel output enable register (SHRTIMER_CHOUTEN) Address offset: 0x14 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved...
Page 647
GD32E50x User Manual by ST3CH0DISF bit in the SHRTIMER_CHOUTDISF register. ST2CH1EN Slave_TIMER2 channel 1 output (ST2CH1_O) enable Refer to ST0CH0EN description. Note: The disable status corresponds to both Idle and Fault states w hich is given by ST2CH1DISF bit in the SHRTIMER_CHOUTDISF register. ST2CH0EN Slave_TIMER2 channel 0 output (ST2CH0_O) enable Refer to ST0CH0EN description.
Page 648
GD32E50x User Manual ST4CH1DI ST4CH0DI ST3CH1DI ST3CH0DI ST2CH1DI ST2CH0DI ST1CH1DI ST1CH0DI ST0CH1DI ST0CH0DI Reserved Bits Fields Descriptions 31:10 Reserved Must be kept at reset value ST4CH1DIS Slave_TIMER4 channel 1 output (ST4CH1_O) disable. Refer to ST0CH0DIS description. ST4CH0DIS Slave_TIMER4 channel 0 output (ST4CH0_O) disable. Refer to ST0CH0DIS description.
Page 649
GD32E50x User Manual This register has to be accessed by word(32-bit) Reserved ST4CH1DI ST4CH0DI ST3CH1DI ST3CH0DI ST2CH1DI ST2CH0DI ST1CH1DI ST1CH0DI ST0CH1DI ST0CH0DI Reserved Bits Fields Descriptions 31:10 Reserved Must be kept at reset value ST4CH1DISF Slave_TIMER4 channel 1 output (ST4CH1_O) disable flag. Refer to ST0CH0DISF description.
Page 650
GD32E50x User Manual SHRTIMER bunch mode control register (SHRTIMER_BMCTL) Address offset: 0x20 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) BMOPTF Reserved BMST4 BMST3 BMST2 BMST1 BMST0 BMMT rc_w0 Reserved BMSE BMPSC[3:0] BMCLKS[3:0] BMCTN BMEN Bits Fields Descriptions BMOPTF...
Page 651
GD32E50x User Manual is reset Note: (1) This bit cannot be changed w hile the bunch mode is enabled. (2) This bit must not be set w hen the balanced IDLE mode is active (DLYISCH[2:0] = 3’bx11 in SHRTIMER_STx CHOCTL register). BMST1 Slave_TIMER1 bunch mode 0: Slave_TIMER1 counter clock(SHRTIMER_PSCCK) is maintained and the...
Page 652
GD32E50x User Manual 0000: f SHRTIMER_BMCNTCK SHRTIMER_CK 0001: f SHRTIMER_BMCNTCK SHRTIMER_CK 0010: f SHRTIMER_BMCNTCK SHRTIMER_CK 0011: f SHRTIMER_BMCNTCK SHRTIMER_CK 0100: f SHRTIMER_BMCNTCK SHRTIMER_CK 0101: f SHRTIMER_BMCNTCK SHRTIMER_CK 0110: f SHRTIMER_BMCNTCK SHRTIMER_CK 0111: f /128 SHRTIMER_BMCNTCK SHRTIMER_CK 1000: f /256 SHRTIMER_BMCNTCK SHRTIMER_CK 1001: f /512...
Page 653
GD32E50x User Manual the bit is set. Writing this bit to 0 w ill terminate bunch mode. 0: Bunch mode disable. 1: Bunch mode enable. SHRTIMER bunch mode start trigger register (SHRTIMER_BMSTRG) Address offset: 0x24 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) ST3EXEV ST0EXEV CISGN...
Page 654
GD32E50x User Manual operation. 0:No effect on bunch mode operation. 1:Slave_TIMER0 period event follow ing external event 6 is starting bunch mode operation. ST4CMP1 Slave_TIMER4 compare 1 event triggers bunch mode operation Refer to MTCMP1 description. ST4CMP0 Slave_TIMER4 compare 0 event triggers bunch mode operation Refer to MTCMP0 description.
Page 655
GD32E50x User Manual Refer to MTRST description. ST0CMP1 Slave_TIMER0 compare 1 event triggers bunch mode operation Refer to MTCMP1 description. ST0CMP0 Slave_TIMER0 compare 0 event triggers bunch mode operation Refer to MTCMP0 description. ST0REP Slave_TIMER0 repetition event triggers bunch mode operation Refer to MTREP description.
Page 656
GD32E50x User Manual Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved BMCMPVAL[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value 15:0 BMCMPVAL[15:0] Bunch mode compare value This bit-field contains value to be compared to the BM-counter and defines the duration of the IDLE.
Page 657
GD32E50x User Manual SHRTIMER external event configuration register 0 (SHRTIMER_EXEVCFG0) Address offset: 0x30 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) EXEV2EG Reserved EXEV4EG[1:0] EXEV4P EXEV4SRC[1:0] Reserved EXEV3EG[1:0] EXEV3P EXEV3SRC[1:0] Reserved EXEV2E EXEV2P EXEV2SRC[1:0] Reserved EXEV1EG[1:0] EXEV1P EXEV1SRC[1:0] Reserved...
Page 658
GD32E50x User Manual Reserved Must be kept at reset value 10:9 EXEV1EG[1:0] External event 1 edge sensitivity Refer to EXEV0EG[1:0] description. EXEV1P External event 1 polarity Refer to EXEV0P description. EXEV1SRC[1:0] External event 1 source Refer to EXEV0SRC[1:0] description. Reserved Must be kept at reset value EXEV0EG[1:0] External event 0 edge sensitivity...
Page 659
GD32E50x User Manual Bits Fields Descriptions 31:29 Reserved Must be kept at reset value 28:27 EXEV9EG[1:0] External event 9 edge sensitivity Refer to EXEV0EG[1:0] in SHRTIMER_EXEV CFG0 register description. EXEV9P External event 9 polarity Refer to EXEV0P in SHRTIMER_EXEV CFG0 register description. 25:24 EXEV9SRC[1:0] External event 9 source...
Page 660
GD32E50x User Manual Refer to EXEV0P in SHRTIMER_EXEV CFG0 register description. EXEV5SRC[1:0] External event 5 source Refer to EXEV0SRC[1:0] in SHRTIMER_EXEVCFG0 register description. SHRTIMER external event digital filter control register (SHRTIMER_EXEVDFCTL) Address offset: 0x38 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) EXEVFDIV[2:0] Reserved EXEV9FC[3:0]...
Page 661
GD32E50x User Manual 11:10 Reserved Must be kept at reset value EXEV6FC[3:0] External event 6 filter control Refer to EXEV5FC[3:0] description. Reserved Must be kept at reset value EXEV5FC[3:0] External event 5 filter control An event counter is used in the digital filter, in w hich a transition on the output occurs after N input events.
Page 662
GD32E50x User Manual TRG0ST4PER SHRTIMER_A DCTRIG0 on Slave_TIMER4 period event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG0. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER4 period event. 1: ADC trigger event generated on SHRTIMER Slave_TIMER4 period event.
Page 663
GD32E50x User Manual Refer to TRG0ST2C1 description. TRG0ST2C1 SHRTIMER_A DCTRIG0 on Slave_TIMER2 compare 1 event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG0. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER2 compare 1 event.
Page 664
GD32E50x User Manual TRG0ST0C2 SHRTIMER_A DCTRIG0 on Slave_TIMER0 compare 2 event Refer to TRG0ST0C1 description. TRG0ST0C1 SHRTIMER_A DCTRIG0 on Slave_TIMER0 compare 1 event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG0. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER0 compare 1 event.
Page 665
GD32E50x User Manual SHRTIMER trigger source 1 to ADC register (SHRTIMER_ADCTRIGS1) Address offset: 0x40 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit) TRG1ST4 TRG1ST4 TRG1ST4 TRG1ST4 TRG1ST3 TRG1ST3 TRG1ST3 TRG1ST3 TRG1ST3 TRG1ST2 TRG1ST2 TRG1ST2 TRG1ST2 TRG1ST2 TRG1ST1 TRG1ST1...
Page 666
GD32E50x User Manual 0: No ADC trigger event generated on SHRTIMER Slave_TIMER3 period event. 1: ADC trigger event generated on SHRTIMER Slave_TIMER3 period event. TRG1ST3C3 SHRTIMER_A DCTRIG1 on Slave_TIMER3 compare 3 event Refer to TRG1ST3C1 description. TRG1ST3C2 SHRTIMER_A DCTRIG1 on Slave_TIMER3 compare 2 event Refer to TRG1ST3C1 description.
Page 667
GD32E50x User Manual Refer to TRG1ST1C1 description. TRG1ST1C2 SHRTIMER_A DCTRIG1 on Slave_TIMER1 compare 2 event Refer to TRG1ST1C1 description. TRG1ST1C1 SHRTIMER_A DCTRIG1 on Slave_TIMER1 compare 1 event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG1. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER1 compare 1 event.
Page 668
GD32E50x User Manual The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG1. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Master_TIMER period event. 1: ADC trigger event generated on SHRTIMER Master_TIMER period event. TRG1MTC3 SHRTIMER_A DCTRIG1 on Master_TIMER compare 3 event Refer to TRG1MTC0 description.
Page 669
GD32E50x User Manual Refer to TRG2ST4C1 description. TRG2ST4C2 SHRTIMER_A DCTRIG2 on Slave_TIMER4 compare 2 event Refer to TRG2ST4C1 description. TRG2ST4C1 SHRTIMER_A DCTRIG2 on Slave_TIMER4 compare 1 event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG2. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER4 compare 1 event.
Page 670
GD32E50x User Manual 1: ADC trigger event generated on SHRTIMER Slave_TIMER2 compare 1 event. TRG2ST1RST SHRTIMER_A DCTRIG2 on Slave_TIMER1 reset The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG2. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER1 reset .
Page 671
GD32E50x User Manual event. 1: ADC trigger event generated on SHRTIMER Slave_TIMER0 compare 1 event. TRG2EXEV4 SHRTIMER_A DCTRIG2 on external event 4 Refer to TRG2EXEV0 description. TRG2EXEV3 SHRTIMER_A DCTRIG2 on external event 3 Refer to TRG2EXEV0 description. TRG2EXEV2 SHRTIMER_A DCTRIG2 on external event 2 Refer to TRG2EXEV0 description.
Page 672
GD32E50x User Manual This register has to be accessed by word (32-bit) TRG3ST4 TRG3ST4 TRG3ST4 TRG3ST4 TRG3ST3 TRG3ST3 TRG3ST3 TRG3ST3 TRG3ST3 TRG3ST2 TRG3ST2 TRG3ST2 TRG3ST2 TRG3ST2 TRG3ST1 TRG3ST1 TRG3ST1 TRG3ST1 TRG3ST0 TRG3ST0 TRG3ST0 TRG3ST0 TRG3EXE TRG3EXE TRG3EXE TRG3EXE TRG3EXE TRG3MTP TRG3MTC TRG3MTC TRG3MTC...
Page 673
GD32E50x User Manual Refer to TRG3ST3C1 description. TRG3ST3C1 SHRTIMER_A DCTRG3 on Slave_TIMER3 compare 1 event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRG3. This bit specifies w hether the event can generate the ADC trigger event. 0: No ADC trigger event generated on SHRTIMER Slave_TIMER3 compare 1 event.
Page 674
GD32E50x User Manual 0: No ADC trigger event generated on SHRTIMER Slave_TIMER1 compare 1 event. 1: ADC trigger event generated on SHRTIMER Slave_TIMER1 compare 1 event. TRG3ST0PER SHRTIMER_A DCTRG3 on Slave_TIMER0 period event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRG3. This bit specifies w hether the event can generate the ADC trigger event.
Page 675
GD32E50x User Manual TRG3MTC2 SHRTIMER_A DCTRG3 on Master_TIMER compare 2 event Refer to TRG3MTC0 description. TRG3MTC1 SHRTIMER_A DCTRG3 on Master_TIMER compare 1 event Refer to TRG3MTC0 description. TRG3MTC0 SHRTIMER_A DCTRG3 on Master_TIMER compare 0 event The SHRTIMER can generate an ADC trigger event on SHRTIMER_A DCTRIG3. This bit specifies w hether the event can generate the ADC trigger event.
Page 676
GD32E50x User Manual Writing 1 to the bit starts the DLL calibration w hen CLBPEREN = 0. This bit is w rite- only. 0: No effect. 1: DLL calibration start once. Note: CLBPEREN bit and CLBSTRT bit must not be set simultaneously. SHRTIMER fault input configuration register 0 (SHRTIMER_FLTINCFG0) Address offset: 0x50 Reset value: 0x0000 0000...
Page 677
GD32E50x User Manual FLT2INP Fault 2 input polarity Refer to FLT0INP description. FLT2INEN Fault 2 input enable Refer to FLT0INEN description. FLT1INPROT Protect fault 1 input configuration Refer to FLT0INPROT description. 14:11 FLT1INFC[3:0] Fault 1 input filter control Refer to FLT0INFC[3:0] description. FLT1INSRC Fault 1 input source Refer to FLT0INSRC description.
Page 678
GD32E50x User Manual 1110: f /32, N=6. SAMP SHRTIMER_FLTFCK 1111: f /32, N=8. SAMP SHRTIMER_FLTFCK Note: (1) This bit-field can be w ritten only w hen FLT0INEN bit is reset. (2) This bit-field cannot be modified w hen FLT0INPROT has been programmed. FLT0INSRC Fault 0 input source 0: The source of fault 0 input is chip external pin.
Page 679
GD32E50x User Manual 00: f SHRTIMER_FLTFCK SHRTIMER_CK 01: f SHRTIMER_FLTFCK SHRTIMER_CK 10: f SHRTIMER_FLTFCK SHRTIMER_CK 11: f SHRTIMER_FLTFCK SHRTIMER_CK Note: This bit must be configured before setting any FLTyINEN(y=0..4). 23:8 Reserved Must be kept at reset value FLT4INPROT Protect fault 4 input configuration Refer to FLT0INPROT in SHRTIMER_FLTINCFG0 register description.
Page 680
GD32E50x User Manual Refer to MTCTL0 description. MTCMP1V SHRTIMER_MTCMP1V update by DMA mode Refer to MTCTL0 description. MTCMP0V SHRTIMER_MTCMP0V update by DMA mode Refer to MTCTL0 description. MTCREP SHRTIMER_MTCREP update by DMA mode Refer to MTCTL0 description. MTCAR SHRTIMER_MTCA R update by DMA mode Refer to MTCTL0 description.
Page 681
GD32E50x User Manual Refer to STxCTL0 bit description. 30:21 Reserved Must be kept at reset value STxFLTCTL SHRTIMER_STx FLTCTL update by DMA mode Refer to STxCTL0 bit description. STxCHOCTL SHRTIMER_STx CHOCTL update by DMA mode Refer to STxCTL0 bit description. STxCSCTL SHRTIMER_STx CSCTL update by DMA mode Refer to STxCTL0 bit description.
Page 682
GD32E50x User Manual Refer to STxCTL0 bit description. STxCNT SHRTIMER_STx CNT update by DMA mode Refer to STxCTL0 bit description. STxDMAINTEN SHRTIMER_STx DMAINTEN update by DMA mode Refer to STxCTL0 bit description. STxINTC SHRTIMER_STx INTC update by DMA mode Refer to STxCTL0 bit description. STxCTL0 SHRTIMER_STx CTL0 update by DMA mode This bit defines if the SHRTIMER_STxCTL0 register is updated by the DMA mode.
GD32E50x User Manual Universal synchronous/asynchronous receiver /transmitter (USART) Universal synchronous/asynchronous receiver /transmitter 20.1. (USARTx, x=0..4) Overview 20.1.1. The USART provides a flexible serial data exchange interface. Data frames can be transferred in full duplex or half duplex mode, synchronously or asynchronously through this interface. A programmable baud rate generator divides the UCLK(PCLK1 or PCLK2) to produce a dedicated baud rate clock for the USART transmitter and receiver.
GD32E50x User Manual Synchronous mode and transmitter clock output for synchronous transmission. ISO 7816-3 compliant smartcard interface. – Character mode (T=0). – Block mode (T=1). – Direct and inverse convention. Multiprocessor communication. – Enter into mute mode if address match does not occur. –...
GD32E50x User Manual Figure 20-1. USART module block diagram CPU/DMA Transmit Shift Register SW_RX IrDA USART Data Register Block Receive Shift Register USART Guard Time and Prescaler Register nRTS Hardware CK Controler Flow nCTS Controler USART Control Registers USART Address Transmitter Transimit clock...
Page 686
GD32E50x User Manual STB[1:0] stop bit length (bit) usage description Smartcard mode for receiving Normal USART and single-w ire modes Smartcard mode for transmitting and receiving In an idle frame, all the frame bits are logic 1. The frame length is equal to the normal USART frame.
GD32E50x User Manual can be output through the CK pin. After the TEN bit is set, an idle frame will be sent. The TEN bit should not be cleared while the transmission is ongoing. After power on, the TBE bit is high by default. Data can be written to the USART_DATA when the TBE bit in the USART_STAT0 register is asserted.
GD32E50x User Manual USART receiver After power on, the USART receiver can be enabled by the following procedure: Set the UEN bit in USART_CTL0 to enable the USART. Write the WL bit in USART_CTL0 to set the data bits length. Set the STB[1:0] bits in USART_CTL1 to configure the number of stop bits.
Page 689
GD32E50x User Manual the parity check function is enabled by setting the PCEN bit in the USART_CTL0 register, the receiver calculates the expected parity value while receiving a frame. The received parity bit will be compared with this expected value. If they are not the same, the parity error (PERR) bit in USART_STAT0 register will be set.
GD32E50x User Manual Figure 20-5. Configuration step when using DMA for USART transmission Clear the TC bit in USART_STAT Set the address of USART_DATA as the DMA destination address Set the address of data in internal sram as the DMA source address Set the number of data as the DMA transfer number Set other configurations of DMA,...
GD32E50x User Manual Figure 20-6. Configuration steps when using DMA for USART reception Set the address of USART_DATA as the DMA source address Set the address of the buffer in internal sram as the DMA destination address Set the number of data as the DMA transfer number Set other configurations of DMA, interrupt enable, priority, etc...
GD32E50x User Manual data frame is received, the nRTS signal goes high to prevent the transmitter from sending next frame. The nRTS signal keeps high when the receive buffer is full, and can be cleared by reading the USART_DATA register. CTS flow control The USART transmitter monitors the nCTS input pin to decide whether a data frame can be transmitted.
GD32E50x User Manual an address frame differ from the ADDR[3:0] bits in the USART_CTL1 register, the hardware sets the RWU bit and enters mute mode automatically. In this situation, the RBNE bit is not set. If the address match method is selected, the receiver does not check the parity value of an address frame by default.
GD32E50x User Manual Synchronous mode The USART can be used for full-duplex synchronous serial communications only in master mode, by setting the CKEN bit in USART_CTL1. The LMEN bit in USART_CTL1 and SCEN, HDEN, IREN bits in USART_CTL2 should be cleared in synchronous mode. The CK pin is the clock output of the synchronous USART transmitter, and can be only activated when the TEN bit is enabled.
GD32E50x User Manual In IrDA mode, the USART transmission data frame is modulated in the SIR transmit encoder and transmitted to the infrared LED through the TX pin. The SIR receive decoder receives the modulated signal from the infrared LED through the RX pin, and puts the demodulated data frame to the USART receiver.
GD32E50x User Manual division ratio is configured by the PSC[7:0] bits in USART_GP register. The pulse width on the TX pin is 3 cycles of this low speed period. The receiver decoder works in the same manner as the normal IrDA mode. Half-duplex communication mode The half-duplex communication mode is enabled by setting the HDEN bit in USART_CTL2.
Page 697
GD32E50x User Manual Character (T=0) mode Comparing to the timing in normal operation, the transmission time from transmit shift register to the TX pin is delayed by half baud clock, and the TC flag assertion time is delayed by a guard time that is configured by the GUAT[7:0] bits in USART_GP.
GD32E50x User Manual The USART uses a block length counter, which is reset when the USART is transmitting (TBE=0), to count the number of received characters. The length of the block, which must be programmed to the BL[7:0] bits in the USART_RT register, is received from the smartcard in the third byte of the block (prologue field).
GD32E50x User Manual Enable Interrupt event Event flag Control register Control bit Reception errors (noise flag, NERR or ORERR or overrun error, framing error) in USART_CTL2 ERRIE FERR DMA reception Collision detected USART_GDCTL CDIE All of the interrupt events are ORed together before being sent to the interrupt controller, so the USART can only generate a single interrupt request to the controller at any given time.
Page 700
GD32E50x User Manual Register definition 20.1.4. USART0 base address: 0x4001 3800 USART1 base address: 0x4000 4400 USART2 base address: 0x4000 4800 UART3 base address: 0x4000 4C00 UART4 base address: 0x4000 5000 Status register 0 (USART_STAT0) Address offset: 0x00 Reset value: 0x0000 00C0 This register has to be accessed by word (32-bit).
Page 701
GD32E50x User Manual 1: Transmit data buffer is empty. Transmission complete This bit is set after pow er on. If the TBE bit has been set, this bit is set w hen the transmission of current data is complete. An interrupt occurs if the TCIE bit in USART_CTL0 is set.
Page 702
GD32E50x User Manual registers one by one. 0: The USART does not detect a framing error. 1: The USART has detected a framing error. PERR Parity error flag This bit is set w hen the parity bit of a receive frame does not match the expected parity value.
Page 703
GD32E50x User Manual INTDIV [11:0] FRADIV[3:0] Bits Fields Descriptions 31:16 Reserved Must be kept the reset value. 15:4 INTDIV[11:0] Integer part of baud-rate divider. FRADIV[3:0] Fraction part of baud-rate divider. Control register 0 (USART_CTL0) Address offset: 0x0C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit).
Page 704
GD32E50x User Manual 1: Parity check function enabled. Parity mode 0: Even parity. 1: Odd parity. PERRIE Parity error interrupt enable. If this bit is set, an interrupt occurs w hen the PERR bit in USART_STAT0 is set. 0: Parity error interrupt is disabled. 1: Parity error interrupt is enabled.
Page 705
GD32E50x User Manual 1: Receiver in mute mode. SBKCMD Send break command Softw are can set this to send a break frame. Hardw are resets this bit automatically w hen the break frame has been transmitted. 0: Do not transmit a break frame. 1: Transmit a break frame.
Page 706
GD32E50x User Manual This bit specifies the phase of the CK pin in synchronous mode. 0: The capture edge of the LSB bit is the first edge of CK pin. 1: The capture edge of the LSB bit is the second edge of CK pin. This bit is reserved for UART3/4.
Page 707
GD32E50x User Manual This bit selects the sample method. The noise detection flag (NF) is disabled w hen the one sample bit method is selected. 0: Three sample bit method. 1: One sample bit method. CTSIE CTS interrupt enable If this bit is set, an interrupt occurs w hen the CTSF bit in USART_STAT0 is set. 0: CTS interrupt is disabled.
Page 708
GD32E50x User Manual 1: Half duplex mode is enabled. IRLP IrDA low -pow er This bit selects low -pow er mode of IrDA mode. 0: Normal mode. 1: Low -pow er mode. IREN IrDA mode enable This bit enables the IrDA mode of USART. 0: IrDA disabled.
Page 709
GD32E50x User Manual 11111111: divides by 255 When the USART w orks in IrDA normal mode, these bits must be set to 00000001. When the USART smartcard mode is enabled, the PSC [4:0] bits specify the division factor that is used to divide the peripheral clock (APB1/APB2) to generate the smartcard clock (CK).
Page 710
GD32E50x User Manual This bit field cannot be w ritten w hen the USART is enabled (UEN=1). RINV RX pin level inversion This bit specifies the polarity of the RX pin. 0: RX pin signal values are not inverted. 1: RX pin signal values are inverted. This bit field cannot be w ritten w hen the USART is enabled (UEN=1).
Page 711
GD32E50x User Manual RT[15:0] Bits Fields Descriptions 31:24 BL[7:0] Block Length These bits specify the block length in Smartcard T=1 Reception. Its value equals to the number of information characters + the length of the Epilogue Field (1-LEC/2- CRC) - 1. This value, w hich must be programmed only once per received block, can be programmed after the start of the block reception (using the data from the LEN character in the Prologue Field).
Page 712
GD32E50x User Manual Busy flag This bit is set w hen the USART is receiving a data frame. 0: USART reception path is idle. 1: USART reception path is w orking. 15:13 Reserved Must be kept the reset value. End of block flag This bit is set w hen the number of received bytes (from the start of the block, including the prologue) is equal or greater than BLEN + 4.
Page 713
GD32E50x User Manual 0: no collision detected. 1: collision detected in halfduplex mode. Reserved Forced by hardw are to 0. CDEN Collision detection enable 0: disable 1: enable Reserved Forced by hardw are to 0.
Page 714
GD32E50x User Manual Universal synchronous/asynchronous receiver /transmitter 20.2. (USARTx, x=5) Overview 20.2.1. The Universal Synchronous/Asynchronous Receiver/Transmitter (USART) provides a flexible serial data exchange interface. Data frames can be transferred in full duplex or half duplex mode, synchronously or asynchronously through this interface. A programmable baud rate generator divides the UCLK(PCLK2, CK_USART5) to produce a dedicated wide range baud rate clock for the USART transmitter and receiver.
GD32E50x User Manual IrDA support Synchronous mode and transmitter clock output for synchronous transmission ISO 7816-3 compliant smartcard interface – Character mode (T=0) – Block mode (T=1) – Direct and inverse convention Multiprocessor communication – Enter into mute mode if address match does not occur –...
GD32E50x User Manual Figure 20-17. USART module block diagram CPU/DMA Transmit Read Write Shift Buffer Buffer Register SW_RX IrDA Block Receive Shift Read FiFO Register USART Guard Time and Prescaler Register nRTS Hardware CK Controler Flow nCTS Controler USART Control Registers USART Address...
Page 717
GD32E50x User Manual STB[1:0] stop bit length (bit) usage description Normal USART and single-w ire modes Smartcard mode for transmitting and receiving In an idle frame, all the frame bits are logic 1. The frame length is equal to the normal USART frame.
GD32E50x User Manual After the TEN bit is set, an idle frame will be sent. The TEN bit should not be cleared while the transmission is ongoing. After power on, the TBE bit is high by default. Data can be written to the USART_TDATA when the TBE bit in the USART_STAT register is asserted.
GD32E50x User Manual USART receiver After power on, the USART receiver can be enabled by the following procedure: Write the WL bit in USART_CTL0 to set the data bits length. Set the STB[1:0] bits in USART_CTL1. Enable DMA (DENR bit) in USART_CTL2 if multibuffer communication is selected. Set the baud rate in USART_BAUD.
Page 720
GD32E50x User Manual the receiver calculates the expected parity value while receiving a frame. The received parity bit will be compared with this expected value. If they are not the same, the parity error (PERR) bit in USART_STAT register will be set. An interrupt is generated, if the PERRIE bit in USART_CTL0 register is set.
GD32E50x User Manual Figure 20-21. Configuration step when using DMA for USART transmission Clear the TC bit in USART_STAT Set the address of USART_TDATA as the DMA destination address Set the address of data in internal sram as the DMA source address Set the number of data as the DMA transfer number Set other configurations of DMA,...
GD32E50x User Manual Figure 20-22. Configuration step when using DMA for USART reception Set the address of USART_RDATA as the DMA source address Set the address of the buffer in internal sram as the DMA destination address Set the number of data as the DMA transfer number Set other configurations of DMA, interrupt enable, priority, etc...
GD32E50x User Manual If the PCEN bit in USART_CTL0 is set, the MSB bit will be checked as the parity bit, and the bit preceding the MSB bit is detected as the address bit. If the ADDM bit is set and the receive frame is a 7bit data, the LSB 6 bits will be compared with ADDR[5:0].
GD32E50x User Manual the clock output of the synchronous USART transmitter, and can be only activated when the TEN bit is enabled. No clock pulse will be sent through the CK pin during the transmission of the start bit and stop bit. The CLEN bit in USART_CTL1 can be used to determine whether the clock is output or not during the last (address flag) bit transmission.
GD32E50x User Manual Figure 20-27. IrDA SIR ENDEC module Inside chip Outside chip RX pin Receive Decoder Infrared Normal IREN USART TX pin Transmit Encoder SIR MODULE In IrDA mode, the polarity of the TX and RX pins is different. The TX pin is usually at low state, while the RX pin is usually at high state.
GD32E50x User Manual Half-duplex communication mode The half-duplex communication mode is enabled by setting the HDEN bit in USART_CTL2. The LMEN, CKEN bits in USART_CTL1 and SCEN, IREN bits in USART_CTL2 should be cleared in half-duplex communication mode. Only one wire is used in half-duplex mode. The TX and RX pins are connected together internally.
Page 727
GD32E50x User Manual gap of 2.5 bits time will be inserted before the start of a resented frame. At the end of the last repeated character the TC bit is set immediately without guard time. The USART will stop transmitting and assert the frame error status if it still receives the NACK signal after the programmed number of retries.
Page 728
GD32E50x User Manual The total block length (including prologue, epilogue and information fields) equals BL+4. The end of the block is signaled to the software through the EBF flag and interrupt (when EBIE bit is set). The RT interrupt may occur in case of an error in the block length. Direct and inverse convention The smartcard protocol defines two conventions: direct and inverse.
GD32E50x User Manual Figure 20-30. USART receive FIFO structure If the software read receive data buffer in the routing of the RBNE interrupt, the RBNEIE bit should be reset at the beginning of the routing and set after all of the receive data is read out. The PERR/NERR/FERR/EBF flags should be cleared before reading a receive data out.
Page 730
GD32E50x User Manual Interrupt event Event flag Enable Control bit read Overrun error detected ORERR Receive FIFO full RFFINT RFFIE Idle line detected IDLEF IDLEIE Parity error flag PERR PERRIE Break detected flag in LIN LBDF LBDIE mode Reception errors (noise flag, overrun error, framing error) in NERR or ORERR or FERR ERRIE...
Page 732
GD32E50x User Manual Register defintion 20.2.4. USART5 base address: 0x4001 7000 Control register 0 (USART_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved EBIE RTIE Reserved OVSMOD AMIE PCEN PERRIE TBEIE TCIE RBNEIE IDLEIE...
Page 733
GD32E50x User Manual This bit field cannot be w ritten w hen the USART is enabled (UEN=1). Wakeup method in mute mode 0: Idle Line 1: Address Mark This bit field cannot be w ritten w hen the USART is enabled (UEN=1). PCEN Parity control enable.
Page 734
GD32E50x User Manual 1: USART able to w ake up the MCU from Deep-sleep mode. Providing that the clock source for the USART must be IRC8M or LXTAL. USART enable 0: USART prescaler and outputs disabled. 1: USART prescaler and outputs enabled. Control register 1 (USART_CTL1) Address offset: 0x04 Reset value: 0x0000 0000...
Page 735
GD32E50x User Manual 1: Data bit signal values are inverted. This bit field cannot be w ritten w hen the USART is enabled (UEN=1). TINV TX pin level inversion. 0: TX pin signal values are not inverted. 1: TX pin signal values are inverted. This bit field cannot be w ritten w hen the USART is enabled (UEN=1).
Page 736
GD32E50x User Manual 1: The clock pulse of the last data bit (MSB) is output to the CK pin in synchronous mode. This bit field cannot be w ritten w hen the USART is enabled (UEN=1). Reserved Must be kept at reset value. LBDIE LIN break detection interrupt enable.
Page 737
GD32E50x User Manual These bits are used to specify the event w hich activates the WUF (Wakeup from Deep-sleep mode flag) in the USART_STAT register. 00: WUF active on address match, w hich is defined by ADDR and ADDM. 01: Reserved. 10: WUF active on Start bit.
Page 738
GD32E50x User Manual 10:8 Reserved Must be kept at reset value. DENT DMA enable for transmission. 0: DMA mode is disabled for transmission. 1: DMA mode is enabled for transmission. DENR DMA enable for reception. 0: DMA mode is disabled for reception. 1: DMA mode is enabled for reception.
Page 739
GD32E50x User Manual Reserved BRR [15:4] BRR[3:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:4 BRR[15:4] Integer of baud-rate divider INTDIV = BRR[15:4] BRR [3:0] Fraction of baud-rate divider If OVSMOD = 0, FRADIV = BRR [3:0]; If OVSMOD = 1, FRADIV = BRR [2:0], BRR [3] must be reset.
Page 740
GD32E50x User Manual factor is tw ice as the prescaler value. 00000: Reserved - do not program this value. 00001: divides the source clock by 2. 00010: divides the source clock by 4. 00011: divides the source clock by 6. This bit field cannot be w ritten w hen the USART is enabled (UEN=1).
Page 741
GD32E50x User Manual Command register (USART_CMD) Address offset: 0x18 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved TXFCMD RXFCMD MMCMD SBKCMD Reserved Bits Fields Descriptions 31:5 Reserved Must be kept at reset value. TXFCMD Transmit data flush request.
Page 742
GD32E50x User Manual Receive enable acknow ledge flag. This bit, w hich is set/reset by hardw are, reflects the receive enable state of the USART core logic. 0: The USART core receiving logic has not been enabled. 1: The USART core receiving logic has been enabled. Transmit enable acknow ledge flag.
Page 743
GD32E50x User Manual 1: USART reception path is w orking. 15:13 Reserved Must be kept at reset value. End of block flag. 0: End of Block not reached. 1: End of Block (number of characters) reached. An interrupt is generated if the EBIE=1 in the USART_CTL1 register.
Page 744
GD32E50x User Manual 0: Data is not received. 1: Data is received and ready to be read. An interrupt w ill occur if the RBNEIE bit is set in USART_CTL0. Set by hardw are w hen the content of the receive shift register has been transferred to the USART_RDATA.
Page 745
GD32E50x User Manual Set by hardw are w hen a parity error occurs in receiver mode. Cleared by w riting 1 to PEC bit in USART_INTC register. Interrupt status clear register (USART_INTC) Address offset: 0x20 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved Reserved...
Page 746
GD32E50x User Manual OREC Overrun error clear. Writing 1 to this bit clears the ORERR bit in the USART_STAT register. Noise detected clear. Writing 1 to this bit clears the NERR bit in the USART_STAT register. Frame error flag clear. Writing 1 to this bit clears the FERR bit in the USART_STAT register.
Page 747
GD32E50x User Manual Bits Fields Descriptions 31:9 Reserved Must be kept at reset value. TDATA[8:0] Transmit Data value. The transmit data character is contained in these bits. The value w ritten in the MSB (bit 7 or bit 8 depending on the data length) w ill be replaced by the parity, w hen transmitting w ith the parity is enabled (PCEN bit set to 1 in the USART_CTL0 register).
Page 748
GD32E50x User Manual Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. RFFINT Receive FIFO full interrupt flag. 14:12 RFCNT[2:0] Receive FIFO counter number. Receive FIFO full flag. 0: Receive FIFO not full. 1: Receive FIFO full. Receive FIFO empty flag 0: Receive FIFO not empty.
GD32E50x User Manual Inter-integrated circuit interface (I2C) Inter-integrated circuit interface (I2Cx, x=0, 1) 21.1. Overview 21.1.1. The I2C (inter-integrated circuit) module provides an I2C interface which is an industry standard two-line serial interface for MCU to communicate with external I2C interface. I2C bus uses two serial lines: a serial data line, SDA, and a serial clock line, SCL.
GD32E50x User Manual Figure 21-1. I2C module block diagram PEC register CRC Calculation / Check SDA Controller Shift Register SCL Controller Data Register SMBA/Rxframe Control Registers Timing and Control Logic Txframe Status Flags DMA/ Interrupts Table 21-1. Definition of I2C-bus terminology (refer to the I2C specification of Philips semiconductors) Term Description...
GD32E50x User Manual connected to the I2C-bus, the voltage levels of the logical ‘0’ (LOW) and ‘1’ (HIGH) are not fixed and depend on the associated level of V Data validation The data on the SDA line must be stable during the HIGH period of the clock. The HIGH or LOW state of the SDA line can only change when the clock signal on the SCL line is LOW (see Figure 21-2.
GD32E50x User Manual a HIGH wait-state during this time. Figure 21-4. Clock synchronization Arbitration Arbitration, like synchronization, is part of the protocol where more than one master is used in the system. Slaves are not involved in the arbitration procedure. A master may start a transfer only if the bus is free.
GD32E50x User Manual An I2C master always initiates or ends a transfer using START or STOP signal and it’s also responsible for SCL clock generation. Figure 21-6. I2C communication flow with 7-bit address Figure 21-7. I2C communication flow with 10-bit address (Master Transmit) Figure 21-8.
Page 754
GD32E50x User Manual I2C_CTL1 to make sure correct I2C timing. After enabled and configured, I2C operates in its default slave state and waits for START signal followed by address on I2C bus. After receiving a START signal followed by a matched address, either in 7-bit format or in 10-bit format, the I2C hardware sets the ADDSEND bit in I2C_STAT0 register, which should be monitored by software either by polling or interrupt.
GD32E50x User Manual Figure 21-9. Programming model for slave transmitting (10-bit address mode) I2C Line State Hardware Action Software Flow IDLE 1) Software initialization Master generates START condition Master sends Header Slave sends Acknowledge Master sends Address Slave sends Acknowledge Set ADDSEND Master generates repeated 2) Clear ADDSEND...
Page 756
GD32E50x User Manual After the last byte is received, RBNE is set. Software reads the last byte. STPDET bit is set when I2C detects a STOP signal on I2C bus and software reads I2C_STAT0 and then writes I2C_CTL0 to clear the STPDET bit. Figure 21-10.
GD32E50x User Manual Now I2C enters data transmission stage and hardware sets TBE bit because both the shift register and data register I2C_DATA are empty. Software now writes the first byte data to I2C_DATA register, but the TBE will not be cleared because the byte written in I2C_DATA is moved to internal shift register immediately.
Page 758
GD32E50x User Manual reception and then sending a STOP signal on I2C bus. So, special attention should be paid to ensure the correct ending of data reception. Two solutions for master receiving are provided here for applications: Solution A and B. Solution A requires the software’s quick response to I2C events, while Solution B doesn’t.
GD32E50x User Manual Figure 21-12. Programming model for master receiving using Solution A (10-bit address mode) I2C Line State Hardware Action Software Flow 1) Software initialization IDLE 2) Set START START Condition Set SBSEND SCL Strechd 3) Clear SBSEND Master sends Header Slave sends Acknowledge Set ADD10SEND SCL stretched by master...
GD32E50x User Manual If the address is in 10-bit format, software should then set START bit again to generate a repeated START signal on I2C bus and SBSEND is set after the repeated START is sent out. Software should clear the SBSEND bit by reading I2C_STAT0 and writing header to I2C_DATA.
Page 761
GD32E50x User Manual address mode) I2C Line State Hardware Action Software Flow 1) Software initialization IDLE 2) Set START Master generates START condition Set SBSEND SCL stretched by master 3) Clear SBSEND Master sends Header Slave sends Acknowledge Set ADD10SEND SCL stretched by master 4) Clear ADD10SEND Master sends Address...
Page 762
GD32E50x User Manual SS bit in the I2C_CTL0 register. If this bit is set, the software is required to be quick enough to serve the TBE, RBNE and BTC status, otherwise, overflow or underflow situation might occur. Use DMA for data transfer As is shown in Programming Model, each time TBE or RBNE is asserted, software should write or read a byte, this may cause CPU to be high overloaded.
Page 763
GD32E50x User Manual SMBus protocol Each message transmission on SMBus follows the format of one of the defined SMBus protocols. The SMBus protocols are a subset of the data transfer formats defined in the I2C specifications. I2C devices that can be accessed through one of the SMBus protocols are compatible with the SMBus specifications.
GD32E50x User Manual The programming flow for SMBus is similar to normal I2C. In order to use SMBus mode, the application should configure several SMBus specific registers, respond to some SMBus specific flags and implement the upper protocols described in SMBus specification. Before communication, SMBEN bit in I2C_CTL0 should be set and SMBSEL and ARPEN bits should be configured to desired values.
GD32E50x User Manual Table 21-3. Error flags Error Nam e Description BERR Bus error LOSTARB Arbitration lost OUERR Over-run or under-run w hen SCL stretch is disabled. AERR No acknow ledge received CRC value doesn’t match PECERR SMBTO Bus timeout in SMBus mode SMBALT SMBus Alert...
Page 766
GD32E50x User Manual Register definition 21.1.4. I2C0 base address: 0x4000 5400 I2C1 base address: 0x4000 5800 Control register 0 (I2C_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register can be accessed by half-word (16-bit) or word (32-bit). Reserved PECTRA SRESET Reserved SALT POAP...
Page 767
GD32E50x User Manual 1: ACKEN bit specifies w hether to send ACK or NACK for the next byte that is to be received, PECTRA NS bit indicates the next byte that is to be received is a PEC byte ACKEN Whether or not to send an ACK This bit is set and cleared by softw are and cleared by hardw are w hen I2CEN=0 0: ACK w ill not be sent...
Page 768
GD32E50x User Manual 1: I2C is enabled Control register 1 (I2C_CTL1) Address offset: 0x04 Reset value: 0x0000 0000 This register can be accessed by half-word (16-bit) or word (32-bit). Reserved Reserved DMALST DMAON BUFIE EVIE ERRIE Reserved I2CCLK[6:0] Bits Fields Descriptions 31:13 Reserved...
Page 769
GD32E50x User Manual 0000000 - 0000001: Not allow ed 0000010 - 1011010: 2MHz~90MHz 1011011 - 1111111: Not allow ed due to the limitation of APB1 clock Note: In I2C standard mode, the frequencies of APB1 must be equal or greater than 2MHz.
Page 770
GD32E50x User Manual Reserved ADDRESS2[7:1] DUADEN Bits Fields Descriptions 31:8 Reserved Must be kept at reset value. ADDRESS2[7:1] The second I2C address for the slave in Dual-Address mode DUADEN Dual-Address mode enable 0: Dual-Address mode is disabled 1: Dual-Address mode is enabled Transfer buffer register (I2C_DATA) Address offset: 0x10 Reset value: 0x0000 0000...
Page 771
GD32E50x User Manual 31:16 Reserved Must be kept at reset value. SMBALT SMBus Alert status This bit is set by hardw are and cleared by w riting 0. 0: SMBA pin not pulled dow n (device mode) or no Alert detected (host mode) 1: SMBA pin pulled dow n and Alert address received (device mode) or Alert detected (host mode) SMBTO...
Page 772
GD32E50x User Manual cleared by w riting a byte to I2C_DATA. If both the shift register and I2C_DATA are empty, w riting I2C_DATA w on’t clear TBE (refer to Programming Model for detail). 0: I2C_DATA is not empty 1: I2C_DATA is empty, softw are can w rite RBNE I2C_DATA is not empty during receiving This bit is set by hardw are after it moves a byte from shift register to I2C_DATA and...
Page 773
GD32E50x User Manual mode, address has been sent and receives the ACK from slave. SBSEND START signal is sent out in master mode This bit is set by hardw are and cleared by reading I2C_STAT0 and w riting I2C_DATA. 0: No START signal sent 1: START signal sent Transfer status register 1 (I2C_STAT1) Address offset: 0x18...
Page 774
GD32E50x User Manual Reserved Must be kept at reset value. Transmitter or receiver This bit indicates w hether the I2C is a transmitter or a receiver. It is cleared by hardw are after a STOP or a START signal or I2CEN=0 or LOSTARB=1. 0: Receiver 1: Transmitter I2CBSY...
Page 775
GD32E50x User Manual =CLKC* T =2*CLKC* T high PCLK1 PCLK1 In fast speed mode or fast mode plus, if DTCY=1: =9*CLKC*T =16*CLKC* T high PCLK1 PCLK1 Note: If DTCY is 0, w hen PCLK1 is an integral multiple of 3, the baud rate w ill be more accurate.
Page 776
GD32E50x User Manual Txframe rise flag, cleared by softw are by w riting 0 Txframe fall flag, cleared by softw are by w riting 0 11:10 Reserved Must be kept at reset value. Level of rxframe signal Level of txframe signal RFRIE Rxframe rise interrupt enable 0: Rxframe rise interrupt disabled...
Page 777
GD32E50x User Manual 31:16 Reserved Must be kept at reset value. 15:9 ADDM[6:0] Defines w hich bits of register ADDRESS[7:1] are compared w ith an incoming address byte, and w hich bits are ignored. Any bit set to 1 in ADDM[6:0] enables comparisons w ith the corresponding bit in ADDRESS[7:1].
Page 778
GD32E50x User Manual STLOIE Interrupt enable for start lost 0: interrupt disable 1: interrupt enable Reserved Must be kept at reset value. STPSEND Stop condition sent out in master mode This bit is set by hardw are and cleared by softw are write 0 0: No STOP condition sent 1: STOP condition sent STLO...
Page 779
GD32E50x User Manual ADD10SEND C ADD10SEND status clear When SRCEN bit is set to 1, softw are can clear the ADD10SEND bit of I2C_STAT0 by w riting 1 to this bit BTCC BTC status clear When SRCEN bit is set to 1, softw are can clear the BTC bit of I2C_STAT0 by w riting 1 to this bit ADDSENDC ADDSEND status clear...
GD32E50x User Manual Inter-integrated circuit interface (I2Cx, x=2) 21.2. Overview 21.2.1. The I2C (inter-integrated circuit) module provides an I2C interface which is an industry standard two-line serial interface for MCU to communicate with external I2C interface. I2C bus uses two serial lines: a serial data line, SDA, and a serial clock line, SCL. The I2C interface implements standard I2C protocol with standard mode, fast mode and fast mode plus as well as CRC calculation and checking, SMBus (system management bus), and PMBus (power management bus).
GD32E50x User Manual with: : SCL low time : SCL high time HIGH : When the filters are enabled, represent the delays by the analog filter and digital filter. filters Analog filter delay is maximum 260ns. Digital filter delay is DNF[3:0]×t I2CCLK The period of PCLK clock t match the conditions as follows:...
GD32E50x User Manual Figure 21-16. START and STOP signal Each I2C device is recognized by a unique address (whether it is a microcontroller, LCD driver, memory or keyboard interface) and can operate as either a transmitter or receiver, depending on the function of the device. It operates in slave mode by default. When it generates a START signal, the interface automatically switches from slave to master.
GD32E50x User Manual Figure 21-18. I2C communication flow with 7-bit address (Master Transmit) Figure 21-19. I2C communication flow with 7-bit address (Master Receive) In 10-bit addressing mode, the HEAD10R bit can configured to decide whether the complete address sequence must be executed, or only the header to be sent. When HEAD10R=0, the complete 10 bit address read sequence must be excuted with START + header of 10-bit address in write direction + slave address byte 2 + RESTART + header of 10-bit address in read direction, as is shown in...
GD32E50x User Manual be configured before the I2C peripheral is enabled according to the actual requirements. The analog noise filter is disabled by setting the ANOFF bit in I2C_CTL0 register and enabled when ANOFF is 0. It can suppress spikes with a pulse width up to 50ns in fast mode and fast mode plus.
GD32E50x User Manual When the SCL falling edge is internally detected, a delay is inserted before sending SDA output. This delay is t =SDADELY*t where t = ( PSC+1 ) *t SDADELY I2CCLK I2CCLK effects t . The total delay of SDA output is t +{ [ SDADELY* ( PSC+1 ) SDADELY HD;DAT...
GD32E50x User Manual I2C reset A software reset can be performed by clearing the I2CEN bit in the I2C_CTL0 register. When a software reset is generated, the SCL and SDA are released. The communication control bits and status bits come back to the reset value. Software reset have no effect on configuration registers.
GD32E50x User Manual Figure 21-25. Data reception SCL Stretch data1 data2 Shift register RBNE read data0 read data1 data0 data1 data2 I2C_RDATA Reload and automatic end mode In order to manage byte transfer and to shut down the communication in modes as is shown Table 21-6.
Page 789
GD32E50x User Manual When works in slave mode, at least one slave address should be enabled. Slave address 1 can be programmed in I2C_SADDR0 register and slave address 2 can be programmed in I2C_SADDR1 register. ADDRESSEN in I2C_SADDR0 register and ADDRESS2EN in I2C_SADDR1 register should be set when the corresponding address is used.
Page 790
GD32E50x User Manual Slave byte control mode In slave receiving mode, the slave byte control mode can be enabled by setting the SBCTL bit in the I2C_CTL0 register to allow byte ACK control. When SS=1, the slave byte control mode is not allowed.
GD32E50x User Manual Figure 21-26. I2C initialization in slave mode START I2CEN=0 Configure DNF[3:0] in I2C_CTL0 Configure PSC[3:0], SDADELY[3:0], SCLDELY[3:0] in I2C_TIMING Configure SS in I2C_CTL0 I2CEN=1 Clear ADDRESSEN in I2C_SADDR0 Clear ADDRESS2EN in I2C_SADDR1 Configure ADDRESS[9:0], ADDFORMAT and ADDRESSEN in I2C_SADDR0, ADDRESS2[7:1], ADDMSK2[2:0] and ADDRESS2EN in I2C_SADDR1, ADDM[6:0] in I2C_CTL2...
GD32E50x User Manual When SS=1, the SCL will not be stretched when ADDSEND bit in I2C_STAT register is set. In this case, the data in I2C_TDATA register can not be flushed in ADDSEND interrupt service routine. So the first byte to be sent must be programmed in the I2C_TDATA register previously. This data can be the one which is written in the last TI event of the last transfer.
GD32E50x User Manual Figure 21-28. Programming model for slave transmitting when SS=1 I2C Line State Hardware Action Software Flow I2C initialization IDLE Set TBE Write DATA(1) to I2C_TDATA Master generates START condition Master sends Address read READDR and TR in Set ADDSEND Slave sends Acknowledge I2C_STAT, clear ADDSEND...
GD32E50x User Manual Figure 21-29. Programming model for slave receiving I2C Line State Hardware Action Software Flow IDLE Master generates START Software initialization condition Master sends Address Slave sends Acknowledge read READDR and TR in Set ADDSEND I2C_STAT, clear ADDSEND SCL stretched by slave (only when SS=0) Master sends DATA(1)
GD32E50x User Manual mode, the HEAD10R bit must be configured to decide whether the complete address sequence must be executed, or only the header to be sent. The number of bytes to be transferred should be configured in BYTENUM[7:0] in I2C_CTL1 register. If the number of bytes to be transferred is equal to or greater than 255, BYTENUM[7:0] should be configured as 0xFF.
GD32E50x User Manual bit in I2C_CTL1 can be set to generate a STOP signal automatically. When AUTOEND is 0, the TC bit in I2C_STAT register will be set and the SCL is stretched. In this case, the master can generate a STOP signal by setting the STOP bit in the I2C_CTL1 register. Or generate a RESTART signal to start a new transfer.
GD32E50x User Manual Figure 21-32. Programming model for master transmitting (N>255) I2C Line State Hardware Action Software Flow Software initialization RELOAD =1 IDLE BYTENUM[7:0]=0xFF Master generates START N=N-255 condition Set START Master sends Address Slave sends Acknowledge Write DATA(1) to Set TI I2C_TDATA Wait for ACK from slave...
GD32E50x User Manual Figure 21-34. Programming model for master receiving (N>255) I2C Line State Hardware Action Software Flow Software initialization RELOAD =1 BYTENUM[7:0]=0xFF N=N-255 IDLE Set START START Condition Master sends Address Slave sends Acknowledge Slave sends DATA(1) Master sends Acknowledge Set RBNE Read DATA(1) (Data transmission)...
Page 800
GD32E50x User Manual Address resolution protocol The SMBus uses I2C hardware and I2C hardware addressing, but adds second-level software for building special systems. Additionally, its specifications include an Address Resolution Protocol that can make dynamic address allocations. Dynamic reconfiguration of the hardware and software allow bus devices to be ‘hot-plugged’...
Page 801
GD32E50x User Manual of the SMBus peripheral is greater than (BUSTOB+1)*2048*t and within the timeout I2CCLK interval described in the bus idle detection section, the TIMEOUT bit in the I2C_STAT register will be set. Packet error checking There is a CRC-8 calculator in I2C block to perform Packet Error Checking for I2C data. A PEC (packet error code) byte is appended at the end of each transfer.
GD32E50x User Manual SMBus slave mode The SMBus receiver must be able to NACK each command or data it receives. For ACK control in slave mode, slave byte control mode can be enabled by setting SBCTL bit in I2C_CTL0 register. SMBus-specific addresses should be enabled when needed.
GD32E50x User Manual If the SMBus master is required to receive PEC at the end of bytes transfer, automatic end mode can be enabled. Before sending a START signal on the bus, PECTRANS bit must be set and slave addresses must be programmed. After receiving BYTENUM-1 data, the next received byte will be compared with the data in the I2C_PEC register automatically.
GD32E50x User Manual Use DMA for data transfer As is shown in I2C slave mode and I2C master mode, each time TI or RBNE is asserted, software should write or read a byte, this may cause CPU’s high overload. The DMA controller can be used to process TI and RBNE flag: each time TI or RBNE is asserted, DMA controller does a read or write operation automatically.
Page 805
GD32E50x User Manual I2C debug mode When the microcontroller enters the debug mode (Cortex®-M33 core halted), the SMBus timeout either continues to work normally or stops, depending on the I2Cx_HOLD configuration bits in the DBG module.
Page 806
GD32E50x User Manual Register definition 21.2.4. I2C2 base address: 0x4000 C000 Control register 0 (I2C_CTL0) Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). SMBALT SMBDAE SMBHAE Reserved PECEN GCEN WUEN SBCTL STPDETI DENR DENT Reserved ANOFF...
Page 807
GD32E50x User Manual 1 mode and Deep-sleep 2 mode. 0: Wakeup from pow er saving mode disable. 1: Wakeup from pow er saving mode enable. Note: WUEN can be set only w hen DNF[3:0] = 0000 Whether to stretch SCL low w hen data is not ready in slave mode. This bit is set and cleared by softw are.
Page 808
GD32E50x User Manual 0: Stop detection (STPDET) interrupt is disabled 1: Stop detection (STPDET) interrupt is enabled NACKIE NACK received interrupt enable 0: NACK received interrupt is disabled 1: NACK received interrupt is enabled ADDMIE Address match interrupt enable in slave mode 0: Address matchinterrupt is disabled 1: Address matchnterrupt is enabled RBNEIE...
Page 809
GD32E50x User Manual 1: Transfer PEC Note: This bit has no effect w hen RELOAD=1, or SBCTL=0 in slave mode. AUTOEND Automatic end mode in master mode 0: TC bit is set w hen the transfer of BYTENUM[7:0] bytes is completed. 1: a STOP signal is sent automatically w hen the transfer of BYTENUM[7:0] bytes is completed.
Page 810
GD32E50x User Manual 1: The 10 bit master receive address sequence is RESTART + header of 10-bit address (read). Note: When the START bit is set, this bit can not be changed. ADD10EN 10-bit addressing mode enable in master mode 0: 7-bit addressing in master mode 1: 10-bit addressing in master mode Note: When the START bit is set, this bit can not be modified.
Page 811
GD32E50x User Manual 0: I2C address disable. 1: I2C address enable. 14:11 Reserved Must be kept at reset value. ADDFORMAT Address mode for the I2C slave 0: 7-bit address 1: 10-bit address Note: When ADDRESSEN is set, this bit should not be w ritten. ADDRESS[9:8] Highest tw o bits of a 10-bit address Note: When ADDRESSEN is set, this bit should not be w ritten.
Page 812
GD32E50x User Manual 111: ADDRESS2[7:1] are masked. All 7-bit received addresses are acknow ledged except the reserved address (0b0000xxx and 0b1111xxx). Note: When ADDRESS2EN is set, these bits should not be w ritten. If ADDMSK2 is not equal to 0, the reserved I2C addresses (0b0000xxx and 0b1111xxx) are not acknow ledged even if all the bits are matched.
Page 813
GD32E50x User Manual =(SCLH+1)* t SCLH Note: These bits can only be used in master mode. SCLL[7:0] SCL low period SCL low period can be generated by configuring these bits. =(SCLL+1)*t SCLL Note: These bits can only be used in master mode. Timeout register (I2C_TIMEOUT) Address offset: 0x14 Reset value: 0x0000 0000...
Page 814
GD32E50x User Manual 0: BUSTOA is used to detect SCL low timeout 1: BUSTOA is used to detect both SCL and SDA high timeout w hen the bus is idle Note: This bit can be w ritten only w hen TOEN =0. 11:0 BUSTOA[11:0] Bus timeout A...
Page 815
GD32E50x User Manual setting the SMBALTC bit. This bit is cleared by hardw are w hen I2CEN=0. 0: SMBALERT event is not detected on SMBA pin 1: SMBALERT event is detected on SMBA pin TIMEOUT TIMEOUT flag. When a timeout or extended clock timeout occurred, this bit w ill be set. It is cleared by softw are by setting the TIMEOUTC bit and cleared by hardw are w hen I2CEN=0.
Page 816
GD32E50x User Manual BYTENUM[7:0] bytes have been transferred. It is cleared by softw are w hen START bit or STOP bit is set. 0: Transfer of BYTENUM[7:0] bytes is not completed 1: Transfer of BYTENUM[7:0] bytes is completed STPDET STOP signal detected in slave mode This flag is set by hardw are w hen a STOP signal is detected on the bus.
Page 817
GD32E50x User Manual Status clear register (I2C_STATC) Address offset: 0x1C Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved SMBALT TIMEOUT PECERR LOSTAR STPDET ADDSEN Reserved OUERRC BERRC Reserved NACKC Reserved Bits Fields Descriptions 31:14 Reserved Must be kept at reset value.
Page 818
GD32E50x User Manual PEC register (I2C_PEC) Address offset: 0x20 Reset value: 0x0000 0000 This register has to be accessed by word (32-bit). Reserved Reserved PECV[7:0] Bits Fields Descriptions 31:8 Reserved Must be kept at reset value. PECV[7:0] Packet Error Checking Value that calculated by hardw are w hen PEC is enabled. PECV is cleared by hardw are w hen I2CEN = 0.
Page 819
GD32E50x User Manual Reserved TDATA [7:0] Bits Fields Descriptions 31:8 Reserved Must be kept at reset value. TDATA[7:0] Transmit data value...
Page 820
GD32E50x User Manual Serial peripheral interface/Inter-IC sound (SPI/I2S) 22.1. Overview The SPI/I2S module can communicate with external devices using the SPI protocol or the I2S audio protocol. The Serial Peripheral Interface (SPI) provides a SPI protocol of data transmission and reception function in master or slave mode.
GD32E50x User Manual Pin nam e Direction Description Master in hardw are NSS mode: w hen NSSDRV=1, it is NSS output, suitable for single master application; w hen NSSDRV=0, it is NSS input, suitable for multi-master application. Slave in hardw are NSS mode: NSS input, as a chip select signal for slave.
GD32E50x User Manual NSS function 22.3.4. Slave mode When slave mode is configured (MSTMOD=0), SPI gets NSS level from NSS pin in hardware NSS mode (SWNSSEN = 0) or from SWNSS bit in software NSS mode (SWNSSEN = 1) and transmits/receives data only when NSS level is low.
GD32E50x User Manual Mode Register configuration Description configuration error w ill occur and the CONFERR bit w ill be set to 1. Applicable to multi-master mode. Once MSTMOD = 1 SWNSS = 0, SPI w ill automatically SWNSSEN = 1 enter slave mode, and a master SWNSS = 0 configuration error w ill occur and the...
GD32E50x User Manual Figure 22-6. A typical simplex connection (Master: transmit only, Slave: receive) Figure 22-7. A typical bidirectional connection Initialization sequence Before transmitting or receiving data, application should follow the SPI initialization sequence described below: If master mode or slave TI mode is used, program the PSC [2:0] bits in SPI_CTL0 register to generate SCK with desired baud rate or configure the Td time in TI mode, otherwise, ignore this step.
Page 828
GD32E50x User Manual Basic transmission and reception sequence Transmission sequence After the initialization sequence, the SPI is enabled and stays at idle state. In master mode, the transmission starts when the application writes a data into the transmission buffer. In slave mode the transmission starts when SCK clock signal begins to toggle at SCK pin and NSS level is low, so application should ensure that data is already written into transmission buffer before the transmission starts in slave mode.
GD32E50x User Manual similar to normal mode described above. The modes described above (MFD, MTU, MRU, MTB, MRB, SFD, STU, SRU, STB and SRB) are still supported in TI mode. While, in TI mode the CKPL and CKPH bits in SPI_CTL0 registers take no effect and the SCK sample edge is falling edge.
GD32E50x User Manual LSB bit of the last data byte, and after a half-bit time, the master begins to sample the line. To make sure that the master samples the right value, the slave should continue to drive this bit after the falling sample edge of SCK for a period of time before releasing the pin. This time is calledT is decided by PSC [2:0] bits in SPI_CTL0 register.
GD32E50x User Manual QRD bit in SPI_QCTL register. Quad write operation SPI works in quad write mode when QMOD is set and QRD is cleared in SPI_QCTL register. In this mode, MOSI, MISO, IO2 and IO3 are all used as output pins. SPI begins to generate clock on SCK line and transmit data on MOSI, MISO, IO2 and IO3 as soon as data is written into SPI_DATA (TBE is cleared) and SPIEN is set.
GD32E50x User Manual Write an arbitrary byte (for example, 0xFF) to SPI_DATA register. Wait until the RBNE flag is set and read SPI_DATA to get the received byte. Write an arbitrary byte (for example, 0xFF) to SPI_DATA to receive the next byte. Figure 22-13.
Page 833
GD32E50x User Manual NSS pulse mode The disabling sequence of NSSP mode is the same as the sequences described above. Quad-SPI mode Before leaving quad wire mode or disabling SPI, software should first check that TBE bit is set and TRANS bit is cleared, then the QMOD bit in SPI_QCTL register and SPIEN bit in SPI_CTL0 register are cleared.
Page 834
GD32E50x User Manual SPI interrupts 22.3.8. Status flags Transmission buffer empty flag (TBE) This bit is set when the transmission buffer is empty, the software can write the next data to the transmission buffer by writing the SPI_DATA register. ...
GD32E50x User Manual when they are different. Table 22-6. SPI interrupt requests Interrupt Flag Description Clear m ethod enable bit Transmission buffer empty Write SPI_DATA register. TBEIE RBNE Reception buffer not empty Read SPI_DATA register. RBNEIE Read or w rite SPI_STAT register, CONFERR Configuration fault error then w rite SPI_CTL0 register.
GD32E50x User Manual I2S signal description 22.4.2. There are four pins on the I2S interface, including I2S_CK, I2S_WS, I2S_SD and I2S_MCK. I2S_CK is the serial clock signal, which shares the same pin with SPI_SCK. I2S_WS is the frame control signal, which shares the same pin with SPI_NSS. I2S_SD is the serial data signal, which shares the same pin with SPI_MOSI.
GD32E50x User Manual Figure 22-16. I2S Phillips standard timing diagram (DTLEN=00, CHLEN=0, CKPL=1) When the packet type is 16-bit data packed in 16-bit frame, only one write or read operation to or from the SPI_DATA register is needed to complete the transmission of a frame. Figure 22-17.
GD32E50x User Manual bit data D[23:0] is going to be sent, the first data written to the SPI_DATA register should be the higher 16 bits: D[23:8], and the second one should be a 16-bit data. The higher 8 bits of this 16-bit data should be D[7:0] and the lower 8 bits can be any value.
GD32E50x User Manual than the data length, the valid data is aligned to LSB for LSB justified standard while the valid data is aligned to MSB for MSB justified standard. The timing diagrams for the cases that the channel length is greater than the data length are shown below. Figure 22-31.
GD32E50x User Manual PCM standard For PCM standard, I2S_WS and I2S_SD are updated on the rising edge of I2S_CK, and the I2S_WS signal indicates frame synchronization information. Both the short frame synchronization mode and the long frame synchronization mode are available and configurable using the PCMSMOD bit in the SPI_I2SCTL register.
GD32E50x User Manual Figure 22-50. PCM standard long frame synchronization mode timing diagram (DTLEN=00, CHLEN=1, CKPL=1) I2S clock 22.4.4. Figure 22-51. Block diagram of I2S clock generator The block diagram of I2S clock generator is shown as Figure 22-51. Block diagram of I2S clock generator.The I2S interface clocks are configured by the DIV bits, the OF bit, the MCKOEN bit in the SPI_I2SPSC register and the CHLEN bit in the SPI_I2SCTL register.
GD32E50x User Manual Figure 22-52. I2S initialization sequence Start Configure the DIV [7:0] bits, the OF Is the bit is 1 bit, and the MCKOEN bit to define MSTMOD the I2S bitrate and master clock Configure the CKPL bit to define the clock polarity of idle state Configure the I2SSEL bit to select I2S mode Configure the I2SSTD [1:0] bits and the PCMSMOD...
Page 847
GD32E50x User Manual (TBE is high) and no transmission sequence is processing in the shift register. When a half word is written to the SPI_DATA register (TBE goes low), the data is transferred from the transmission buffer to the shift register (TBE goes high) immediately. At the moment, the transmission sequence begins.
GD32E50x User Manual Figure 22-53. I2S master reception disabling sequence Start If DTLEN == 2b'00&&CHLEN == 2b'1 && I2SSTD ==2b'10 ? If DTLEN == 2b'00&&CHLEN == Wait for the second last RBNE 2b'1 && I2SSTD !=2b'10 ? Wait for the last RBNE Wait for the second last RBNE Wait 17 I2S CK clock (clock on Wait one I2S clock cycle...
Page 849
GD32E50x User Manual I2S slave reception sequence The reception sequence in slave mode is similar to that in master mode. The differences between them are described below. In slave mode, the slave has to be enabled before the external master starts the communication.
GD32E50x User Manual Transmission buffer empty flag (TBE) This bit is set when the transmission buffer is empty, the software can write the next data to the transmission buffer by writing the SPI_DATA register. Reception buffer not empty flag (RBNE) This bit is set when reception buffer is not empty, which means that one data is received and stored in the reception buffer, and software can read the data by reading the SPI_DATA register.
Page 851
GD32E50x User Manual Interrupt Interrupt flag Description Clear m ethod enable bit TXURERR Transmission underrun error Read SPI_STAT register Read SPI_DATA register and then RXORERR Reception overrun error ERRIE read SPI_STAT register. FERR I2S format error Read SPI_STAT register...
Page 852
GD32E50x User Manual 22.5. Register definition SPI0 base address: 0x4001 3000 SPI1/I2S1 base address: 0x4000 3800 SPI2/I2S2 base address: 0x4000 3C00 I2S1_ADD base address: 0x4000 3400 I2S2_ADD base address: 0x4000 4000 Control register 0 (SPI_CTL0) 22.5.1. Address offset: 0x00 Reset value: 0x0000 0000 This register can be accessed by byte (8-bit) or half-word (16-bit) or word (32-bit).
Page 853
GD32E50x User Manual When the transfer is managed by DMA, CRC value is transferred by hardw are. This bit should be cleared. In full-duplex or transmit-only mode, set this bit after the last data is w ritten to SPI_DATA register. In receive only mode, set this bit after the second last data is received.
Page 854
GD32E50x User Manual MSTMOD Master mode enable 0: Slave mode 1: Master mode CKPL Clock polarity selection 0: CLK pin is pulled low w hen SPI is idle. 1: CLK pin is pulled high w hen SPI is idle. CKPH Clock phase selection 0: Capture the first data at the first clock transition.
Page 855
GD32E50x User Manual 1: Enable SPI NSS pulse mode NSSDRV Drive NSS output 0: Disable master NSS output 1: Enable master NSS output DMATEN Transmit buffer DMA enable 0: Disable transmit buffer DMA 1: Enable transmit buffer DMA, w hen the TBE bit in SPI_STAT is set, it w ill be a DMA request on corresponding DMA channel.
Page 856
GD32E50x User Manual RXORERR Reception overrun error bit 0: No reception overrun error occurs. 1: Reception overrun error occurs. This bit is set by hardw are and cleared by a read operation on the SPI_DATA register follow ed by a read access to the SPI_STA T register. CONFERR SPI configuration error 0: No configuration fault occurs.
Page 857
GD32E50x User Manual Reserved SPI_DATA[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 SPI_DATA[15:0] Data transfer register. the hardw are has tw o buffers, including transmission buffer and reception buffer. Write data to SPI_DATA w ill save the data to transmission buffer and read data from SPI_DATA w ill get the data from reception buffer.
Page 858
GD32E50x User Manual This register can be accessed by byte (8-bit) or half-word (16-bit) or word (32-bit). Reserved RCRC[15:0] Bits Fields Descriptions 31:16 Reserved Must be kept at reset value. 15:0 RCRC[15:0] RX CRC value When the CRCEN bit of SPI_CTL0 is set, the hardw are computes the CRC value of the received bytes and saves them in RCRC register.
Page 859
GD32E50x User Manual is set, a read to this register could return an intermediate value. The different frame formats (LF bit of the SPI_CTL0) w ill get different CRC values. This register is reset w hen the CRCEN bit in SPI_CTL0 register or the SPIxRST bit in RCU reset register is set.
Page 860
GD32E50x User Manual This bit is not used in SPI mode. Reserved Must be kept at reset value. I2SSTD[1:0] I2S standard selection 00: I2S Phillips standard 01: MSB justified standard 10: LSB justified standard 11: PCM standard These bits should be configured w hen I2S mode is disabled. These bits are not used in SPI mode.
Page 861
GD32E50x User Manual Bits Fields Descriptions 31:10 Reserved Must be kept at reset value. MCKOEN I2S_MCK output enable 0: Disable I2S_MCK output 1: Enable I2S_MCK output This bit should be configured w hen I2S mode is disabled. This bit is not used in SPI mode. Odd factor for the prescaler 0: Real divider value is DIV * 2 1: Real divider value is DIV * 2 + 1...
Page 862
GD32E50x User Manual This bit is only available in SPI0. Quad-SPI mode enable. QMOD 0: SPI is in single w ire mode. 1: SPI is in Quad-SPI mode. This bit can only be configured w hen the SPI is not busy (the TRANS bit is cleared). This bit is only available in SPI0.
GD32E50x User Manual Serial/Quad Parallel Interface (SQPI) 23.1. Overview Serial/Quad Parallel Interface (SQPI) is a controller for external serial/dual/quad parallel interface memory peripheral. For example: SQPI-PSRAM and SQPI-FLASH. With this controller, users can use external SQPI interface memory as SRAM simply. 23.2.
GD32E50x User Manual SQPI controller special command 23.3.2. SQPI controller special command (SQPI_SC) function can send only command phase with no address, waitcycle, and data phase. Special command function will be mandatory to SSS mode by hardware. If you set SQPI_SC bit to 1, you must read this bit and wait it cleared before doing other memory access because this can ensure the operation has performed in the interface.
GD32E50x User Manual SQPI controller output clock configuration 23.3.4. SQPI clock period is configured by SQPI_CLKDIV bits. The frequency formula of SQPI_CLK ℎ _ _ + 1 Note: SQPI_CLKDIV cannot be 0. When SPI_CLKDIV field is even number, the output clock high level time has 1 HCLK period more than low level time.
Page 869
GD32E50x User Manual SQPI Initial Register (SQPI_INIT) 23.4.1. Address offset: 0x00 Reset Value: 0x1805 0000 This register has to be accessed by word (32-bit). SQPI_PL SQPI_IDLEN[1:0] SQPI_ADDRBIT[4:0] SQPI_CLKDIV[5:0] SQPI_CMDBIT[1:0] Reserved Bits Fields Descriptions SQPI_PL Read data sample polarity. 0: Sample data at rising edge(default) 1: Sample data at falling edge.
Page 870
GD32E50x User Manual This register has to be accessed by word (32-bit). SQPI_RI SQPI_RMODE[2:0] SQPI_RWAITCYCLE[3:0] Reserved SQPI_RCMD[15:0] Bits Fields Descriptions SQPI_RID Send read ID command, command code comes from SQPI_RCMD. 30:23 Reserved Must be kept at reset value. 22:20 SQPI_RMODE[2:0] SQPI controller read command mode: 000: SSQ mode 001: SSS mode...
Page 871
GD32E50x User Manual Bits Fields Descriptions SQPI_SC Send special command w hich does not have address and data phase, command code comes from SQPI_WCMD. 30:23 Reserved Must be kept at reset value. 22:20 SQPI_WMODE[2:0] SQPI controller w rite command mode: 000: SSQ mode 001: SSS mode 010: SQQ mode...
Page 872
GD32E50x User Manual This register has to be accessed by word (32-bit). SQPI_IDH[31:16] SQPI_IDH[15:0] Bits Fields Descriptions 31:0 SQPI_IDH[31:0] ID High Data saved for SQPI read ID command This register only valid w hen SQPI_IDL EN = 00.
Page 873
GD32E50x User Manual Secure digital input/output interface (SDIO) Introduction 24.1. The secure digital input/output interface (SDIO) defines the SD, SD I/O, MMC and CE -ATA card host interface, which provides command/data transfer between the AHB system bus and SD memory cards, SD I/O cards, Multimedia Card (MMC) and CE-ATA devices. The supported SD memory card and SD I/O card system specifications are defined in the SD card Association website at www.sdcard.org.
GD32E50x User Manual Response: a response is a token which is sent from the card to the host as an answer to a previously received command. A response is transferred serially on the CMD line. Data: data can be transferred from the card to the host or vice versa. Data is transferred via the data lines.
GD32E50x User Manual has an optional busy before it is ready to receive the data. Figure 24-2. SDIO multiple blocks read operation Figure 24-3. SDIO multiple blocks write operation Command Response Command Response Host to Device Device to Host Host to Device Device to Host DATA BLOCK CRC DATA BLOCK CRC...
GD32E50x User Manual Figure 24-5. SDIO sequential write operation SDIO functional description 24.4. The following figure shows the SDIO structure. There have two main parts: The SDIO adapter block consists of control unit which manage clock, command unit which manage command transfer, data unit which manage data transfer. ...
GD32E50x User Manual a one bit transfer on the command line (SDIO_CMD) and on all the data lines (SDIO_DAT). The SDIO_CLK frequency can vary between 0 MHz and 20 MHz for a Multimedia Card V3.31, between 0 and 48 MHz for a Multimedia Card V4.2, or between 0 and 25 MHz for an SD/SD I/O card.
Page 878
GD32E50x User Manual avoid the corresponded error. Only state machines are frozen, the AHB interface is still alive. So, the FIFO can access by AHB bus. Command unit The command unit implements command transfer to the card. The data transfer flow is controlled by Command State Machine (CSM).
Page 879
GD32E50x User Manual CS_Receive Receive the response and check the CRC. → 1.Response Received in CE-ATA mode CS_Waitcompl interrupt disabled and w ait for CE-ATA Command Completion signal enabled → 2.Response Received in CE-ATA mode CS_Pend interrupt disabled and w ait for CE-ATA Command Completion signal disabled →...
Page 880
GD32E50x User Manual DS_Send Transmit data to the card. → 1.Data block transmitted DS_Busy → 2.DSM disabled DS_Idle → 3.Data FIFO underrun error occurs DS_Idle → 4. Internal CRC error DS_Idle DS_Busy Waits for the CRC status flag. → 1.Receive a positive CRC status DS_WaitS →...
Page 881
GD32E50x User Manual and memory. The following example describes how to implement this method: 1. Complete the card identification process 2. Increase the SDIO_CLK frequency 3. Send CMD7 to select the card and configure the bus width 4. Configure the DMA1 as follows: Enable DMA1 controller and clear any pending interrupts.
Page 882
GD32E50x User Manual Card functional description 24.5. Card registers 24.5.1. Within the card interface registers are defined: OCR, CID, CSD, EXT_CSD, RCA, DSR and SCR. These can be accessed only by corresponding commands. The OCR, CID, CSD and SCR registers carry the card/content specific information, while the RCA and DSR registers are configuration registers storing actual configuration parameters.
GD32E50x User Manual length, transfer rate or number of cards). The CSD register carries the information about the DSR register usage. The default value of the DSR register is 0x404. The host can use CMD4 to get the content of this register. SCR register: Just SD/SD I/O (if has memory port) have this register.
GD32E50x User Manual Command classes The command set of the Card system is divided into several classes (See Table 24-3. Card command classes (CCCs)). Each class supports a set of card functionalities. Table 24-3. Card command classes (CCCs) determines the setting of CCC from the card supported commands.
GD32E50x User Manual ACMD22 ACMD23 ACMD41 ACMD42 ACMD51 Note: 1.CMD1, CMD11, CMD14, CMD19, CMD20, CMD23, CMD26, CMD39 and CMD40 are only available for MMC.CMD5, CMD32-34, CMD50, CMD52, CMD53, CMD57 and ACMDx are only available for SD card. CMD60, CMD61 are only available for CE-ATA device. 2.
Page 887
GD32E50x User Manual [31:26] Set to 0 [25:24] Access Only for MMC. Sw itches the [23:16] Index mode of operation of the selected CMD6 SWITCH [15:8] Value card or modifies the EXT_CS D [7:3] Set to 0 registers. [2:0] Cmd Set Command toggles card...
GD32E50x User Manual Table 24-5. Block-Oriented read commands (class 2) Cm d Response type argum ent Abbreviation Description index form at the case of a Standar d Capacity SD and MMC, this command sets the block length (in bytes) for all follow ing bloc k commands (read, w rite, lock).
GD32E50x User Manual Table 24-6. Stream read commands (class 1) and stream write commands (class 3) Cm d Response type argum ent Abbreviation Description index form at Reads data stream from the card, [31:0] data READ_DAT_UNTI starting at the given address, CMD11 adtc address...
GD32E50x User Manual Cm d Response type argum ent Abbreviation Description index form at Programming card identification register. This command shall be issued only once. card contains CMD26 adtc [31:0] stuff bits PROGRA M_CID hardw are prevent this operation after first programming.
GD32E50x User Manual Table 24-9. Block oriented write protection commands (class 6) Cm d Response type argum ent Abbreviation Description index form at If the card has w rite protection features, this command sets the w rite protection addressed group. The properties [31:0] data SET_WRITE_PRO of w rite protection are coded in...
GD32E50x User Manual Table 24-11. Application-specific commands (class 8) Cm d Response type argum ent Abbreviation Description index form at Sends host capacity support information (HCS) and asks [31]reserved bit the accessed card to send its [30]HCS operating condition [29:24]reserved SD_SEND_OP_ register(OCR) content in the ACMD41...
GD32E50x User Manual Table 24-12. I/O mode commands (class 9) Cm d Response type argum ent Abbreviation Description index form at Used to w rite and read 8 bit (register) data fields. command addresses a card and a register and provides the [31:16] RCA data for w riting if the w rite flag [15] register w rite...
GD32E50x User Manual Cm d Response type argum ent Abbreviation Description index form at Count Note: 1.CMD39, CMD40 are only for MMC. 2. CMD52, CMD53 are only for SD I/O card. Table 24-13. Switch function commands (class 10) Cm d Response type argum ent...
GD32E50x User Manual R7 : Card interface condition. The SD Memory Card support five types of them, R1 / R1b, R2, R3, R6, R7. And the SD I/O Card and MMC supports additional response types named R4 and R5, but they are not exactly the same for SD I/O Card and MMC.
GD32E50x User Manual R2 (CID, CSD register) Code length is 136 bits. The contents of the CID register are sent as a response to the commands CMD2 and CMD10. The contents of the CSD register are sent as a response to CMD9.
GD32E50x User Manual ‘0’ ‘0’ ‘000011’ ‘1’ Value start transmission New published RCA card status description CMD3 CRC7 of the card bits:23,22,19,12:0 R7 (Card interface condition) For SD memory only. Code length is 48 bits. The card support voltage information is sent by the response of CMD8.
GD32E50x User Manual 4-bit data packet format Figure 24-10. 4-bit data bus width Start Byte Byte Byte Byte … … DAT3 … … DAT2 … … DAT1 … … DAT0 8-bit data packet format Figure 24-11. 8-bit data bus width Start Byte Byte...
GD32E50x User Manual Type •E: Error bit. Send an error condition to the host. These bits are cleared as soon as the response (reporting the error) is sent out. •S: Status bit. These bits serve as information fields only, and do not alter the execution of the command being responded to.
Page 901
GD32E50x User Manual ’1’= error passw ord error been detected in lock/unlock card command. ’0’= no error COM_CRC_ERROR The CRC check of the previous ’1’= error command failed. ’0’= no error ILLEGAL_COMMAND Command not legal for the card ’1’= error state.
Page 902
GD32E50x User Manual 1 = ready receiving the command. If the 2 = identification command execution causes a 3 = stand by state change, it w ill be visible to 4 = transfer the host in the response to the 5 = send data next command.
GD32E50x User Manual Table 24-24. SD status Bits Identifier Type Value Description Clear Condition ’00’= 1 (default) [511: DAT_BUS_WIDTH Show s the currently defined ‘01’= reserved 510] data bus w idth that w as defined ‘10’= 4 bit w idth SET_BUS_W IDT H ‘11’= reserved command...
GD32E50x User Manual Bits Identifier Type Value Description Clear Condition time. [399: reserved 312] [311: reserved for manufacturer SIZE_OF_PROTECTED_AREA Setting this field differs between SDSC and SDHC/SDXC. In case of SDSC Card, the capacity of protected area is calculated as follows: Protected Area = SIZE_OF_PROTECTED_AREA_* MULT * BLOCK_LEN.
GD32E50x User Manual PERFORMANCE_M OV E Value Definition Infinity AU_SIZE This 4-bit field indicates AU Size and the value can be selected from 16 KB. Table 24-26. AU_SIZE field AU_SIZE Value Definition Not Defined 16 KB 32 KB 64 KB 128 KB 256 KB 512 KB...
GD32E50x User Manual ERASE_SIZ E Value Definition 0003h 3 AU ....FFFFh 65535 AU ERASE_TIMEOUT This 6-bit field indicates the T and the value indicates erase timeout from offset when ERASE multiple AUs are erased as specified by ERASE_SIZE. The range of ERASE_TIMEOUT can be defined as up to 63 seconds and the card manufacturer can choose any combination of ERASE_SIZE and ERASE_TIMEOUT depending...
Page 907
GD32E50x User Manual voltage range, identifies cards and asks them to publish Relative Card Address (RCA). This operation is done to each card separately on its own CMD line. All data communication in the Card Identification Mode uses the command line (CMD) only. During the card identification process, the card shall operate in the clock frequency of the identification clock rate F (400 kHz).
Page 908
GD32E50x User Manual the following steps: 1. Check if the card is connected. 2. Identify the card type; SD, MMC(CE-ATA), or SD I/O. – Send CMD5 first. If a response is received, then the card is SD I/O – If not, send ACMD41; if a response is received, then the card is SD. –...
Page 909
GD32E50x User Manual Single block or multiple block write 24.6.3. During block write (CMD24 - 27) one or more blocks of data are transferred from the host to the card. The block consists of start bits (1 or 4 bits LOW), data block, CRC and end bits(1 or 4 bits HIGH).
Page 910
GD32E50x User Manual task file, then use CMD61 to write the data. After writing to the CMD register, host starts executing a command, when the command is sent to the bus, the CMDRECV flag is set. 5. Write data to SDIO_FIFO. 6.
Page 911
GD32E50x User Manual read and CMD18 for a multiple-block read. For SD I/O cards, using CMD53 for both single- block and multiple-block transfers. For CE-ATA, first using CMD60 to write the ATA task file, then using CMD 61 to read the data. After writing to the CMD register, the host starts executing the command, when the command is sent to the bus, the CMDRECV flag is set.
Page 912
GD32E50x User Manual the card may not be able to process the data and will stop programming, and while ignoring all further data transfer, wait (in the Receive-data-State) for a stop command. As the host sends CMD12, the card will respond with the TXURE bit set and return to Transfer state Stream read There is a stream oriented data transfer controlled by READ_DAT_UNTIL_STOP (CMD11).
Page 913
GD32E50x User Manual write blocks which are the basic writable units of the card. The size of the Erase Group is a card specific parameter and defined in the CSD. The host can erase a contiguous range of Erase Groups. Starting the erase process is a three steps sequence.
Page 914
GD32E50x User Manual Protection management 24.6.8. In order to allow the host to protect data against erase or write, three methods for the cards are supported in the card: CSD register for card protection (optional) The entire card may be write protected by setting the permanent or temporary write protect bits in the CSD.
GD32E50x User Manual card data structure describes the structure of the command data block. Table 24-31. Lock card data structure Byte Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Reserved(all set to 0) ERASE LOCK_UNLOCK CLR_PWD...
Page 916
GD32E50x User Manual Reset the password Select a card (CMD7), if not previously selected. Define the block length (CMD16), given by the 8-bit card lock/unlock mode, the 8-bit password size (in bytes), and the number of bytes of the currently used password. Send the card lock/unlock command with the appropriate data block size on the data line ...
GD32E50x User Manual Read Wait operation Suspend/resume operation Interrupts The SD I/O supports these operations only if the SDIO_DATACTL[11] bit is set, except for read suspend that does not need specific hardware implementation. SD I/O read wait operation The optional Read Wait (RW) operation is defined only for the SD 1-bit and 4-bit modes. The Read Wait operation allows a host to signal a card that is executing a read multiple (CMD53) operation to temporarily stall the data transfer while allowing the host to send commands to any function within the SD I/O card.
GD32E50x User Manual SDIO_DATACTL[8] = 1) and data direction is from card to SD I/O (SDIO_DATACTL[1] = 1), the DSM directly moves from Idle to Read Wait. In Read Wait the DSM drives SDIO_DAT[2] to 0 after 2 SDIO_CLK clock cycles. In this state, when you set the RWSTOP bit (SDIO_DATACTL[9]), the DSM remains in Wait for two more SDIO_CLK clock cycles to drive SDIO_DAT[2] to 1 for one clock cycle.
GD32E50x User Manual on the SD interface. Pin number 8, which is used as SDIO_DAT[1] when operating in the 4- bit SD mode, is used to signal the card’s interrupt to the host. The us e of interrupt is optional for each card or function within a card.
GD32E50x User Manual during a 4-bit multi-block write. Figure 24-17. Multiple block 4-Bit read interrupt cycle timing Figure 24-18. Multiple block 4-Bit write interrupt cycle timing CE-ATA specific operations 24.7.2. The CE-ATA device supports these specific operations: Receive command completion signal Send command completion disable signal The SDIO supports these operations only when SDIO_CMDCTL[14] is set.
GD32E50x User Manual Command completion disable signal The host may cancel the ability for the device to return a command completion signal by issuing the command completion signal disable. The host shall only issue the command completion signal disable when it has received an R1b response for an outstanding RW_MULTIPLE_BLOCK (CMD61) command.
Page 922
GD32E50x User Manual SDIO registers 24.8. SDIO base address: 0x4001 8000 Power control register (SDIO_PWRCTL) 24.8.1. Address offset: 0x00 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved Reserved PWRCTL[1:0] Bits Fields Descriptions 31:2 Reserved Must be kept at reset value PWRCTL[1:0] SDIO pow er control bits.
Page 923
GD32E50x User Manual Bits Fields Descriptions DIV[8] MSB of Clock division This field defines the MSB division betw een the input clock (SDIOCLK) and the output clock, refer to bit 7:0 of SDIO_CLKCTL. 30:15 Reserved Must be kept at reset value. HWCLKEN Hardw are Clock Control enable bit If this bit is set, hardw are controls the SDIO_CLK on/off depending on the system...
Page 924
GD32E50x User Manual Command argument register (SDIO_CMDAGMT) 24.8.3. Address offset: 0x08 Reset value: 0x0000 0000 This register defines 32 bit command argument, which will be used as part of the command (bit 39 to bit 8). This register has to be accessed by word(32-bit) CMDAGMT[31:16] CMDAGMT[15:0] Bits...
Page 925
GD32E50x User Manual 1: CE-ATA enable NINTEN No CE-ATA Interrupt (CE-ATA only) This bit defines if there is CE-ATA interrupt or not. This bit is only used w hen CE- ATA card. 0: CE-ATA interrupt enable 1: CE_ATA interrupt disable ENCMDC CMD completion signal enabled (CE-ATA only) This bit defines if there is command completion signal or not in CE-ATA card.
GD32E50x User Manual Command index response register (SDIO_RSPCMDIDX) 24.8.5. Address offset: 0x10 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) Reserved Reserved RSPCMDIDX[5:0] Bits Fields Descriptions 31:6 Reserved Must be kept at reset value RSPCMDIDX[5:0] Last response command index Read-only bits field.
Page 927
GD32E50x User Manual Register Short response Long response SDIO_RESP2 reserved Card response [63:32] SDIO_RESP3 reserved Card response [31:1],plus bit 0 Data timeout register (SDIO_DATATO) 24.8.7. Address offset: 0x24 Reset value: 0x0000 0000 This register has to be accessed by word(32-bit) DATATO[31:16] DATATO[15:0] Bits...
Page 928
GD32E50x User Manual starts, the data counter loads this register and starts decrement. Note: If block data transfer selected, the content of this register must be a multiple of the block size (refer to SDIO_DATACTL). The data timer register and the data length register must be updated before being written to the data control register when need a data transfer.
Page 930
GD32E50x User Manual Bits Fields Descriptions 31:25 Reserved Must be kept at reset value 24:0 DATACNT[24:0] Data count value Read-only bits field. When these bits are read, the number of remaining data bytes to be transferred is returned. Status register (SDIO_STAT) 24.8.11.
Page 931
GD32E50x User Manual Transmit FIFO is full Receive FIFO is half full: at least 8 w ords can be read in the FIFO Transmit FIFO is half empty: at least 8 w ords can be w ritten into the FIFO RXRUN Data reception in progress TXRUN...
Page 932
GD32E50x User Manual Bits Fields Descriptions 31:24 Reserved Must be kept at reset value ATAENDC ATAEND flag clear bit Write 1 to this bit to clear the flag. SDIOINTC SDIOINT flag clear bit Write 1 to this bit to clear the flag. 21:11 Reserved Must be kept at reset value...
Page 933
GD32E50x User Manual ATAENDI SDIOINTI RXDTVA TXDTVAL Reserved RFEIE TFEIE RFFIE TFFIE CMDRUN DTBLKE CMDSEN CMDREC DTTMOU CMDTMO DTCRCE CCRCER RFHIE TFHIE RXRUNIE TXRUNIE STBITEIE DTENDIE RXOREIE TXUREIE NDIE UTIE RRIE Bits Fields Descriptions 31:24 Reserved Must be kept at reset value ATAENDIE CE-ATA command completion signal received interrupt enable Write 1 to this bit to enable the interrupt.
Page 934
GD32E50x User Manual Write 1 to this bit to enable the interrupt. STBITEIE Start bit error interrupt enable Write 1 to this bit to enable the interrupt. DTENDIE Data end interrupt enable Write 1 to this bit to enable the interrupt. CMDSENDIE Command sent interrupt enable Write 1 to this bit to enable the interrupt.
Page 935
GD32E50x User Manual These bits define the remaining number w ords to be w ritten or read from the FIFO. It loads the data length register (SDIO_DATALEN[24:2] if SDIO_DATALEN is w ord- aligned or SDIO_DA TALEN[24:2]+1 if SDIO_DATALEN is not w ord-aligned) w hen DATAEN is set, and start count decrement w hen a w ord w rite to or read from the FIFO.
Page 936
GD32E50x User Manual External memory controller (EXMC) Overview 25.1. The external memory controller EXMC, is used as a translator for MCU to access a variety of external memory. By configuring the related registers, it can automatically convert AMBA memory access protocol into a specific memory access protocol, such as SRAM, ROM, NOR Flash, NAND Flash and PC Card.
GD32E50x User Manual External device address mapping 25.3.3. Figure 25-2. EXMC memory banks EXMC access space is divided into multiple banks. Each bank is 256 Mbytes. The first bank (Bank0) is further divided into four regions, and each region is 64 Mbytes. Bankx(x=1, 2) is divided into two spaces, the attribute memory space and the common memory space.
Page 939
GD32E50x User Manual Figure 25-3. Four regions of bank0 address mapping HADDR[25:0] is the byte address whereas the external memory may not be byte accessed, this will lead to address inconsistency. EXMC can adjust HADDR to accommodate the data width of the external memory according to the following rules. –...
GD32E50x User Manual Figure 25-4. NAND/PC Card address mapping EXMC Memory Address Memory Space Bank 0x7000 0000 Common Memory Space 0x73FF FFFF Bank1 0x7800 0000 Attribute Memory Space 0x7BFF FFFF 0x8000 0000 Common Memory Space 0x83FF FFFF Bank2 0x8800 0000 Attribute Memory Space 0x8BFF FFFF...
GD32E50x User Manual – When HADDR [17:16] = 00, the data area is selected. – When HADDR [17:16] = 01, the command area is selected. – When HADDR [17:16] = 1X, the address area is selected. Application software uses these three areas to access NAND Flash, their definitions are as follows.
GD32E50x User Manual Mem ory Mem ory Access Mode Transaction Transaction Com m ents Size Size EXMC_NBL[1:0] Async Async Split into 2 EXMC Async accesses Split into 2 EXMC Async accesses Sync Sync Use of byte lanes Sync EXMC_NBL[1:0] Sync Split into 2 EXMC Sync accesses...
GD32E50x User Manual Param eter Function Access m ode Unit DSET Data setup time Async HCLK AHLD Address hold time Async(muxed) HCLK ASET Address setup time Async HCLK Table 25-5. EXMC_timing models Tim ing Extend Write tim ing Read tim ing Mode description m odel m ode...
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value NREN No effect Depends on memory NRTP Depends on memory, except 2(Nor Flash) NRMUX NRBKEN EXMC_SNTCFGx 31-30 Reserved 0x0000 29-28 ASYNCMOD No effect 27-24 DLAT No effect 23-20 CKDIV No effect Time betw een EXMC_NE[x] rising edge to 19-16...
GD32E50x User Manual Figure 25-9. Mode A write access Address (EXMC_A[25:0]) Chip Enable (EXMC_NEx) Byte Lane Select (EXMC_NBL[1:0]) Output Enable (EXMC_NOE) Write Enable (EXMC_NWE) Data EXMC Output (EXMC_D[15:0]) Address Setup Time Data Setup Time 1 HCLK (WASET+1 HCLK) (WDSET HCLK) The difference between mode A and mode 1 write timing is that read/write timing is specified by the same set of timing configuration, while mode A write timing configuration is independent of its read configuration.
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value Time betw een EXMC_NE[x] rising edge to 19-16 BUSLAT EXMC_NE[x] falling edge Depends on memory and user (DSET+3 HCLK for 15-8 DSET read) AHLD No effect ASET Depends on memory and user EXMC_SNWTCFGx(Write) 31-30 Reserved...
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value NREN Depends on memory NRTP 0x2, NOR Flash NRMUX NRBKEN EXMC_SNTCFGx( Read and w rite in m ode 2,read in m ode B) 31-30 Reserved 0x0000 29-28 ASYNCMOD Mode B:0x1 27-24 DLAT No effect...
GD32E50x User Manual Figure 25-14. Mode C write access Address (EXMC_A[25:0]) Chip Enable (EXMC_NEx) Address Valid (EXMC_NADV) Output Enable (EXMC_NOE) Write Enable (EXMC_NWE) Data EXMC Output (EXMC_D[15:0]) Address Setup Time Data Setup Time 1 HCLK (WASET+1 HCLK) (WDSET HCLK) The differences between mode C and mode 1 write timing are that read/write timing is specified by the same set of timing configuration, while mode C write timing configuration is independent of its read configuration, and the toggle of NOE and NADV are different.
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value Time betw een EXMC_NE[x] rising edge to 19-16 BUSLAT EXMC_NE[x] falling edge Depends on memory and user (DSET+3 HCLK for 15-8 DSET read) AHLD ASET Depends on memory and user EXMC_SNWTCFGx 31-30 Reserved...
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value AHLD Depends on memory and user ASET Depends on memory and user EXMC_SNWTCFGx 31-30 Reserved 29-28 WASYNCMOD Mode D:0x3 27-20 Reserved 0x00 Time betw een EXMC_NE[x] rising edge to 19-16 WBUSLAT EXMC_NE[x] falling edge...
GD32E50x User Manual Table 25-11. Multiplex mode related registers configuration Bit Position Bit Nam e Reference Setting Value EXMC_SNCTLx 31-20 Reserved 0x000 SYNCWR 18-16 ASYNCWAIT Depends on memory EXMODEN NRWTEN WREN Depends on memory NRWTCFG No effect WRAPEN NRWTPOL Meaningful only w hen the bit 15 is set to 1 SBRSTEN Reserved NREN...
Page 957
GD32E50x User Manual CKDIV is the synchronous clock divider ratio, it is configured through the CKDIV control field in the EXMC_SNTCFGx register. 1. Data latency and NOR Flash latency Data latency is the number of EXMC_CLK cycles to wait before sampling the data. The relationship between data latency and NOR Flash specification’s latency parameter is as follows: For NOR Flash’s specification excluding the EXMC_NADV cycle, their relationship should be:...
GD32E50x User Manual For synchronous burst transmission, if the needed data of AHB is 16-bit, EXMC will perform a burst transmission whose length is 1. If the needed data of AHB is 32-bit, EXMC will make the transmission divided into two 16-bit transmissions, that is, EXMC performs a burst transmission whose length is 2.
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value EXMC_SNCTLx Depends on memory,0x1/0x2 NRTP NRMUX 0x1, Depends on memory and users NRBKEN EXMC_SNTCFGx( Read) 31-30 Reserved 29-28 ASYNCMOD 27-24 DLAT Data latency 23-20 CKDIV The figure above: 0x1, EXMC_CLK=2HCLK Time betw een EXMC_NE[x] rising edge to 19-16 BUSLAT...
GD32E50x User Manual Bit Position Bit Nam e Reference Setting Value EXMC_SNCTLx AYSNCWAIT EXMODEN NRWTEN Depends on memory WREN NRWTCFG 0x0(Here must be zero) WRAPEN NTWTPOL Depends on memory SBRSTEN No effect Reserved NREN Depends on memory NRTP NRMUX 0x1, Depends on users NRBKEN EXMC_SNTCFGx( Write) 31-30...
GD32E50x User Manual such as EXMC_NPCTLx, EXMC_NPINTENx, EXMC_NPCTCFGx, EXMC_NPATCFGx, EXMC_PIOTCFG3 and EXMC_NECCx. Among these registers, EXMC_NPCTCFGx, EXMC_NPATCFGx, EXMC_PIOTCFG3 registers contain four timing parameters individually which are configured according to user specification and features of the external memory. Table 25-17. NAND Flash or PC Card programmable parameters NAND Flash/ Program m able param eter Unit...
GD32E50x User Manual signal (EXMC_A[16]) or address latch signal (EXMC_A[17]), namely, the CPU needs to perform write operation in particular address. Example: NAND Flash read operation steps: Configure EXMC_NPCTLx and EXMC_NPCTCFGx register. When pre-waiting is needed, EXMC_NPATCFGx has to be configured. Send the command of NAND Flash read operation to the common space.
Page 964
GD32E50x User Manual Write ADD1 into NAND Flash bank common space address area. Write ADD2 into NAND Flash bank common space address area. Write ADD3 into NAND Flash bank common space address area. Write CMD1 into NAND Flash bank attribute space command area. In step 6, EXMC uses the operation timing defined in EXMC_NPATCFGx register.
Page 965
GD32E50x User Manual 8- or 16-bit access operation is being performed. EXMC_NWE and EXMC_NOE dictates whether the on-going operation is a write or read operation, and EXMC_NREG is low during attribute space access. IO space: EXMC_NCE3_x (x = 0, 1) is the chip enable signal, it indicates whether 8- or 16-bit access operation is being performed.
Page 966
GD32E50x User Manual Registers definition 25.4. EXMC base address: 0xA000 0000 NOR/PSRAM controller registers 25.4.1. SRAM/NOR Flash control registers (EXMC_SNCTLx) (x=0, 1, 2, 3) Address offset: 0x00 + 8 * x, (x = 0, 1, 2, and 3) Reset value: 0x0000 30DX This register has to be accessed by word (32-bit) SYNCWR CPS[2:0]...
Page 967
GD32E50x User Manual insertion via the NWAIT signal: 0: Disable NWAIT signal 1: Enable NWAIT signal WREN Write enable 0: Disabled w rite in the bank by the EXMC, otherw ise an AHB error is reported 1: Enabled w rite in the bank by the EXMC (default after reset) NRWTCFG NWAIT signal configuration, only w ork in synchronous mode 0: NWAIT signal is active one data cycle before w ait state...
Page 968
GD32E50x User Manual SRAM/NOR Flash timing configuration registers (EXMC_SNTCFGx) (x=0, 1, 2, Address offset: 0x04 + 8 * x, (x = 0, 1, 2, and 3) Reset value: 0x0FFF FFFF This register has to be accessed by word(32-bit) Reserved ASYNCMOD[1:0] DLAT[3:0] CKDIV[3:0] BUSLAT[3:0]...
Page 969
GD32E50x User Manual This field is meaningful only in asynchronous access. 0x00: Reserved 0x01: Data setup time = 2 * HCLK period …… 0xFF: Data setup time = 256 * HCLK period AHLD[3:0] Address hold time This field is used to set the time of address hold phase, w hich only used in mode D and multiplexed mode.
Page 970
GD32E50x User Manual 11: Mode D access 27:20 Reserved Must be kept at reset value. 19:16 WBUSLAT[3:0] Bus latency Bus latency added at the end of each w rite transaction to match w ith the minimu m time betw een consecutive transactions. 0x0: Bus latency = 1 * HCLK period 0x1: Bus latency = 2 * HCLK period ……...
Page 972
GD32E50x User Manual 0: Disable w ait function 1: Enable w ait function Reserved Must be kept at reset value. NAND Flash/PC Card interrupt enable registers (EXMC_NPINTENx) (x=1, 2, 3) Address offset: 0x44 + 0x20 * x, (x = 1, 2, and 3) Reset value: 0x0000 0046 (for bank1 and bank2), 0x0000 0040 (for bank3) This register has to be accessed by word (32-bit) In addition to interrupt controlling bits, this register also contains a FIFO empty status bit,...
Page 973
GD32E50x User Manual INTHS Interrupt high-level status 0: Not detect interrupt high-level 1: Detect interrupt high-level INTRS Interrupt rising edge status 0: Not detect interrupt rising edge 1: Detect interrupt rising edge NAND Flash/PC Card common space timing configuration registers (EXMC_NPCTCFGx) (x=1, 2, 3) Address offset: 0x48 + 0x20 * x, (x = 1, 2, and 3) Reset value: 0xFCFC FCFC...
Page 974
GD32E50x User Manual 0x01: COMWAIT = 2 * HCLK (+NWAIT active cycles) …… 0xFE: COMWAIT = 255 * HCLK (+NWAIT active cycles) 0xFF: Reserved COMSET[7:0] Common memory setup time Define the time to build address before sending command 0x00: COMSET = 1 * HCLK ……...
Page 975
GD32E50x User Manual 0xFF: Reserved 15:8 ATTWAIT[7:0] Attribute memory w ait time Define the minimum time to maintain command 0x00: Reserved 0x01: ATTWAIT = 2 * HCLK (+NWAIT active cycles) …… 0xFE: ATTWAIT = 255 * HCLK (+NWAIT active cycles) 0xFF: Reserved ATTSET[7:0] Attribute memory setup time...
Page 976
GD32E50x User Manual 15:8 IOWAIT[7:0] IO space w ait time Define the minimum time to maintain command 0x00: Reserved 0x01: IOWAIT = 2 * HCLK (+NWAIT active cycles) …… 0xFF: IOWAIT = 256 * HCLK (+NWAIT active cycles) IOSET[7:0] IO space setup time Define the time to build address before sending command 0x00: IOSET = 1 * HCLK ……...
Page 977
GD32E50x User Manual Controller area network (CAN) Overview 26.1. CAN bus (Controller Area Network) is a bus standard designed to allow microcontrollers and devices to communicate with each other without a host computer. The CAN network interfaces of the GD32E503xx, GD32E505xx and GD32E507xx series supports the CAN protocol 2.0A and B, and the GD32E508xx series also supports the ISO11898-1:2015 and BOSCH CAN-FD specifications.The CAN interface automatically handles the transmission and the reception of CAN frames.
GD32E50x User Manual Disable retransmission automatically in time-triggered communication mode. 16-bit free timer Time stamp on SOF reception Time stamp sent in last two data bytes Function overview 26.3. Figure 26-1. CAN module block diagram shows the CAN block diagram. Figure 26-1.
Page 979
GD32E50x User Manual register. Initial working mode When the configuration of CAN bus communication is needed to be changed, the CAN must enter initial working mode. When IWMOD bit in CAN_CTL register is set, the CAN enters the initial working mode. Then the IWS bit in CAN_STAT register is set.
GD32E50x User Manual Loopback communication mode Loopback communication mode means the transmitted messages are transferred into the Rx FIFOs, the RX pin is disconnected from the CAN network and the TX pin can still send messages to the CAN network. Setting LCMOD bit in CAN_BT register to enter loopback communication mode, while clearing it to leave.
GD32E50x User Manual If FD frame would be transmitted, always write TMDATA00 registers when mailbox 0 is used, TMDATA01 register when mailbox 1 is used and TMDATA02 register when mailbox 2 is used until the end. For example, if application wants to transmit 64 bytes data using mailbox0, it needs to write the 64 bytes data through TMDATA00 register for 16 times.
Page 982
GD32E50x User Manual successful. Transmission options Abort MST bit in CAN_TSTAT register can abort the transmission. If the transmit mailbox’s status is pending or scheduled, the abort of transmission can be done immediately. In the transmit state, the abort of transmission does not take effect immediately until the transmission is finished.
GD32E50x User Manual Figure 26-4. Reception register RFIFO0 RFIFOMI0 RFIFOMP0 Receive FIFO0 RFIFOMDATA00 RFIFOMDATA10 Application RFIFOMI1 RFIFOMP1 Receive FIFO1 RFIFOMDATA01 RFIFOMDATA11 RFIFO1 Rx FIFO Rx FIFO has three mailboxes. The reception frames are stored in the mailbox according to the arriving sequence. First arrived frame can be accessed by application firstly. The number of frames in the Rx FIFO and the status can be accessed by the register CAN_RFIFO0 and CAN_RFIFO1.
GD32E50x User Manual Steps of receiving a message Step 1: Check the number of frames in the Rx FIFO. Step Read CAN_RFIFOMIx, CAN_RFIFOMPx, CAN_RFIFOMDATA0x CAN_RFIFOMDATA1x. Step 3: Set the RFD bit in CAN_RFIFOx register. Filtering function 26.3.5. The CAN receives frames from the CAN bus. If the frame passes the filter, it is stored in the Rx FIFOs.
GD32E50x User Manual Figure 26-8. 16-bit mask mode filter List mode The filter consists of frame identifiers. The filter can determine whether a frame will be discarded or not. When one frame arrived, the filter will check which member can match the identifier of the frame.
GD32E50x User Manual Filtering index Each filter number corresponds to a filtering rule. When the frame which is associated with a filter number N passes the filters, the filter index is N. It stores in the FI bits in CAN_RFIFOMPx. Filter bank has filter index once it is associated with the FIFO no matter whether the bank is active or not.
Page 987
GD32E50x User Manual Filter Filter Filter Filter FIFO0 Active FIFO1 Active bank nunber bank nunber F9DATA0[31:16]-16bits- F11DATA0[31:16]-16bits- Mask F9DATA1[15:0]-16bits- F11DATA1[15:0]-16bits- ID F9DATA1[31:16]-16bits- F11DATA1[31:16]-16bits- Mask F12DATA0-32bits-ID F13DATA0-32bits-ID F12DATA1-32bits-Mask F13DATA1-32bits- ID Priority The filters have the priority rules: 32-bits mode is higher than 16-bits mode. List mode is higher than mask mode.
GD32E50x User Manual Bit time On the bit-level, the CAN protocol uses synchronous bit transmission. This not only enhances the transmitting capacity but also requires a sophisticated method of bit synchronization. While bit synchronization in a character-oriented transmission (asynchronous) is performed upon the reception which the start bit is available with each character, the synchronous transmission protocol just need one start bit available at the beginning of a frame.
Page 989
GD32E50x User Manual If a valid edge is detected in BS1, not in SYNC_SEG, BS1 is added up to SJW maximumly, so that the sample point is delayed. Conversely, if a valid edge is detected in BS2, not in SYNC_SEG, BS2 is cut down to SJW at most, so that the transmit point is moved earlier.
Page 990
GD32E50x User Manual CAN_FDSTAT register to 1. The transmission of ESI bit (the bit before DLC bits, refer to ISO11898-1 or Bosch CAN FD Specification V1.0) is defined by ESIMOD bit in CAN_FDCTL register and ESI bit in CAN_TMPx register. If ESIMOD bit is 0, it will transmit the dominant bit by error active nodes and transmit the recessive bit by error passive nodes.
GD32E50x User Manual Figure 26-12. Transmitter Delay Measurement CANTX CANRX TDCV TDCO TDCMOD=0,TDCV>=TD TDCO TDCMOD=1 SSP position TDCF TDCO TDCMOD=0,TDCV<TDCF SSP position Error flags 26.3.10. The state of CAN bus can be reflected by Transmit Error Counter (TECNT) and Receive Error Counter (RECNT) of CAN_ERR register.
Page 992
GD32E50x User Manual The interrupt sources can be classified as: Transmit interrupt FIFO0 interrupt FIFO1 interrupt Error and status change interrupt Transmit interrupt The transmit interrupt can be generated by any of the following conditions and TMEIE bit in CAN_INTEN register will be set: ...
GD32E50x User Manual Table 26-3. CAN Event / Interrupt The CAN bus controller interrupt conditions can refer to flags. Table 26-3. CAN Event / Interrupt flags nterrupt event nterrupt / Event flag Enable control bit Mailbox 0 transmit finished flag (MTF0) Transmit interrupt Mailbox 1 transmit finished flag (MTF1) TMEIE...
Page 994
GD32E50x User Manual CAN registers 26.4. CAN0 base address: 0x4000 6400 CAN1 base address: 0x4000 6800 CAN2 base address: 0x4000 CC00 Control register (CAN_CTL) 26.4.1. Address offset: 0x00 Reset value: 0x0001 0002 This register has to be accessed by word(32-bit). Reserved SLPWMO SWRST...
Page 995
GD32E50x User Manual If this bit is set, the CAN leaves sleep w orking mode w hen CAN bus activity is detected, and SLPWMOD bit in CAN_CTL register w ill be cleared automatically. 0: The sleeping w orking mode is left manually by softw are 1: The sleeping w orking mode is left automatically by hardw are Automatic retransmission disable 0: Enable automatic retransmission...
Page 996
GD32E50x User Manual RX level LASTRX Last sample value of RX pin Receiving state 0: CAN is not w orking in the receiving state 1: CAN is w orking in the receiving state Transmitting state 0: CAN is not w orking in the transmitting state 1: CAN is w orking in the transmitting state Reserved Must be kept at reset value.
Page 997
GD32E50x User Manual 1: CAN is in the state of sleep w orking mode Initial w orking state This bit is set by hardw are w hen the CAN enters initial w orking mode after setting IWMOD bit in CAN_CTL register. If the CAN leaves normal w orking mode to initial w orking mode, it must w ait the current frame transmission or reception to be completed.
Page 998
GD32E50x User Manual 0: Transmit mailbox 1 not empty 1: Transmit mailbox 1 empty TME0 Transmit mailbox 0 empty 0: Transmit mailbox 0 not empty 1: Transmit mailbox 0 empty 25:24 NUM[1:0] These bits are the number of the Tx FIFO mailbox in w hich the frame w ill be transmitted if at least one mailbox is empty.
Page 999
GD32E50x User Manual 1 to this bit or MTF1 bit in CAN_TSTAT register. This bit is reset by hardw are w hen next transmit starts. MAL1 Mailbox 1 arbitration lost This bit is set w hen the arbitration lost occurs. This bit is reset by w ritting 1 to this bit or MTF1 bit in CAN_TSTAT register.
Page 1000
GD32E50x User Manual 1: Mailbox 0 transmit finished Receive message FIFO0 register (CAN_RFIFO0) 26.4.4. Address offset: 0x0C Reset value: 0x0000 0000 This register has to be accessed by word(32-bit). Reserved Reserved RFD0 RFO0 RFF0 Reserved RFL0[1:0] rc_w1 rc_w1 Bits Fields Descriptions 31:6 Reserved...
Need help?
Do you have a question about the GD32E50 Series and is the answer not in the manual?
Questions and answers