Compatibility Sumup Between GD32 and STM32 - V2.0
Compatibility Sumup Between GD32 and STM32 - V2.0
1. Preparatory work
If client call for some other scripts and programs, please contract GigaDevice
FAE.
GD32MCU support KEIL MDK and IAR, above 4.74 for KEIL4, above 5.14 for
KEIL5 and above 7.0 for IAR. It is convenient to for us to support client who using
KEIL.
1.3. Emulator
Emulators which suit for GD32MCU are Jlink, ST-link (only for F1 series),Ulink
and GD-link. Except GD-link, other emulators need to install driver.
It is necessary to install addon in KEIL and IAR for support GD device. There are
three purposes in addon: 1, Select GD MCU device type; 2, Select GD flash
download algorithm; 3, View registers in debug. All the addons could be
downloaded from official website. Please install specific addon in given IDE.
If the client is not willing to install addon, please select ST device type for
downloading and debugging
2. Differences and similarities between GD32 and
STM32
2.1. Similarities
1. Peripheral Pin Definitions: for 10x and 4xx, the same device, the same pins;
for 20x and 30x, same device is not exactly same.
4. ESD Parameter:Chip level ESD degree of GD32 is higher than STM32. For
example, 103 series, STM32: The human body mode is 2KV and air mode
is 500V, GD32: The human body mode is 4KV and air mode is 10KV.
3. Flash Erase Time: if erase 1KB per page, GD32 is 60ms, while, STM32 is
30ms
5. SRAM Size: the SRAM size which GD32F2 support maximally is bigger than
STM32F2, so is F4 series.
6. EXMC: if the total number of pins come up to 100, there is EXMC in GD32,
while, for STM32, flash must come up to 256KB at same time, so EXMC
exist.
2. IAP: GD32 program in word or half word, STM32 program only in word
3.1. System
8. Issue:in GD32F450, when system clock switch from high frequency clock
to low frequency clock (HSI), it will leads HIS,HSE,PLL clock disappear,
program will run out of control.
reason When system clock is high frequency, load current is big, switch
to low frequency clock fast, leads internal LDO is unable to follow
fast change, so VCORE falling disable part circuits
solution Before switch clock, divide HCLK to 2 or 4 multiple, then switch
clock
type GD32F450 series
tips Other series without this question
In ST library
FLASH_Status FLASH_EraseOptionBytes(void)
FLASH_Status FLASH_ProgramOptionByteData(uint32_t
Address, uint8_t Data)
FLASH_Status FLASH_EnableWriteProtection(uint32_t
FLASH_Pages)
FLASH_Status FLASH_ReadOutProtection(FunctionalState
NewState)
Should modify
2. Issue:IAP program
reason Erasing and programing time of GD32 is tiny longer than STM32,
it is advised to modify the timeout for erasing and programing
solution change
#define EraseTimeout ((uint32_t)0x000B0000)
#define ProgramTimeout ((uint32_t)0x00002000)
To be
#define EraseTimeout ((uint32_t)0x000FFFFF)
#define ProgramTimeout ((uint32_t)0x0000FFFF)
type GD32 all series
tips
1. Issue: Incompatible with other manufacturer ISP version before 2012 years
reason GD32 chip core version is newer
solution Advise to download newest version MCUISP from
www.mcuisp.com;
Besides, download GigaDevice ISP from website:
http://bbs.21ic.com/gd32.
3.4. FWDGT
3.5. DMA
3.6. CAN
1. Issue: After CAN entered bus-off, it will not recover transmit in probability
with configure ABOM
reason CAN design difference between GD32 and STM32
solution Open bus-off interrupt, initialize CAN in interrupt handler.
type GD32 all series
tips
5. Issue: GPIO continuous flip without delay, appear output level error.
reason GPIO continuous set OCTL, set BC, reset OCTL and set OCTL
again without delay. The second setting OCTL will be covered by
previous setting BC and resetting OCTL.
solution Add one cycle delay between setting BC, resetting OCTL and
setting OCTL again.
type GD32F130\150
tips Other series without this question
3.8. TIMER
3.9. USART
3.10. I2C
3.11. ADC
3. Issue: ADC sample value is 0 always due to delay after ADC enable
reason ADC design difference between GD32 and STM32
solution Insert 20us delay after ADC enable
type GD32F103/101 with below 256KB
tips Other series without this question
4. Issue: ADC2 insert group value is 0 when configure ADC1 and ADC2 in
synchronous mode
reason When configure ADC1 and ADC2 in synchronous mode, ADC2
followed ADC1 synchronically trigger, trigger mode of insert
group should be configured as software trigger. Otherwise,
STM32 is able to work in normal, while, ADC2 of GD32 insert
group sample value is 0 with probability
solution Configure ADC2 trigger mode as software trigger in ADC2
initialization
type GD32 all series
tips
8. Issue: sample through resistor divider, ADC sample value is tiny smaller.
reason There is difference between GD32 and STM32 in ADC input
impedance, at same sample cycle, input impedance of GD is
smaller than ST. If sample through resistor divider, sample value
is smaller than actual value. (Fig 1.3)
solution Increase sample cycle, decrease sample voltage resistor in
hardware.
type GD32 all series
tips
10. Issue: ADC data dislocation if reconfigure ADC and DMA when ADC is
working.
reason After disable ADC and DMA, DMA request of ADC cannot clear.
Thus, when reconfigure ADC and DMA, there is possible remain
DMA request which is not answered, after enable DMA, answer
the remaining DMA request immediately, so as to leads ADC
data dislocation.
solution In DMA TC interrupt handler, disable DMA request bit of ADC or
bit ON of ADC, so as to make sure the remaining DMA request
will not send out.
Reset ADC bit of RCC, clear DMA request.
type GD32F10x series
tips Other series without this question
11. Issue: The first channel convert value of insert group is 0x800 when ADC
use regular group and insert group at the same time.
reason When insert group cycle is set as 1.5 or 7.5, this issue appear
with probability
solution Configure insert group cycle as 13.5.
type GD32F103/101 with above 128KB,GD32F130\150。
tips Other series without this question
13. Issue: continually turning on and off VBAT channel affect ADC data sample
reason Turning off VBAT channel would trigger ADC convert, thereby,
leads data sampling is inconsistent with channel
solution Avoid disable channel without enable channel previously
type GD32F130\150。
tips Other series without this question
14. Issue: 14M crystal oscillation deadlock in reset wait calibration register.
reason For GD MCU, enable 14M clock and then select 14M clock as
ADC clock. For ST MCU, if select 14M clock as ADC clock,
automatically enable internal 14M clock.
solution enable 14M clock and then select 14M clock as ADC clock
type GD32F130\150
tips
3.12. ETH
1. Issue: if MCU is busy, process descriptor speed is low, at the same time,
frequently receive frame, possibly occur Ethernet abnormal. Even if the
network is idle, remain not recover.
reason Process receive FIFO overflow difference between GD and ST
solution Open Flush
ETH_InitStructure.ETH_DMA_FlushReceivedFrame =
ETH_FLUSHRECEIVEDFRAME_ENABLE;
Open ROS(Receive Overflow)interrupt, in its interrupt handler,
reset ETH module and initialize parameters.
in receive interrupt handler, check valid data, if RDES resource
include irregularity data, drop them and release RDES resource
uint32_t ETH_GetRxPktSize(void)
{
uint32_t size = 0;
if((DMACurrentRxDesc->Status &
ETH_DMARXDESC_BUSY) != (uint32_t)RESET)
{
return 0;
}
if(((DMACurrentRxDesc->Status &
ETH_DMARXDESC_ERRS) != (uint32_t)RESET) ||
((DMACurrentRxDesc->Status &
ETH_DMARXDESC_LDES) == (uint32_t)RESET) ||
((DMACurrentRxDesc->Status &
ETH_DMARXDESC_FDES) == (uint32_t)RESET))
{
ETH_DropRxPkt();
return 0;
}
if(((DMACurrentRxDesc->Status &
ETH_DMARXDESC_BUSY) == (uint32_t)RESET) &&
((DMACurrentRxDesc->Status &
ETH_DMARXDESC_ERRS) == (uint32_t)RESET) &&
((DMACurrentRxDesc->Status &
ETH_DMARXDESC_LDES) != (uint32_t)RESET) &&
((DMACurrentRxDesc->Status &
ETH_DMARXDESC_FDES) != (uint32_t)RESET))
{
/* Get the size of the received data including CRC */
size =
ETH_GetDMARxDescFrameLength(DMACurrentRxDesc);
}
3.13. SPI
4. Attention items
Combining PLLMF [3:0] and PLLMF [4] in RCC_CFG0, five bits ensure PLL
clock multiplier factor, PLL output frequency is exceed Highest frequency
(108MHz).
4.2. USB
After power on MCU, all IOs is default in floating, voltage level of IO port is
affected easily, thereby, affect MCU consumption. It is recommended that
configure all IO ports as analog input mode. Even if there is some port without
extract, such as GD32103C8, do not extract GPIOE, all pins of GPIOE is
remain to configure as analog input.
5. Reference pictures
5.1. Core
Fig 1.1
5.2. USART
There is a bit of idle between byte and byte, when USART send data continuously.
As is shown below.
Fig. 1.2
5.3. ADC
Fig. 1.3