How to replace _GD32 How to replace STM32?

Link: https://blog.csdn.net/qq_23852045/article/details/109802955

GD32F103 is an early product of GD. GD32E103 and GD32F303 are upgrades and optimizations of GD32F103, so the 4 are compatible. Although the kernels are different, the general peripherals rarely involve the kernel part. You can use ST in the case of time is urgent. Library development.

1. Similarities

1) Peripheral pins are PIN TO PIN compatible, and the multiplexing functions on each pin are also identical.
2) The chip's internal registers, external IP register addresses and logical addresses are exactly the same, but some registers have different default values, and the design timing of some peripheral modules is different from STM32. This difference is mainly reflected in software modifications. See below for details.
3) Compilation tool: exactly the same. For example: KEIL, IAR
4) The model naming method is exactly the same, so you only need to find the model with the same suffix, for example: STM32F103C8T6 and GD32E103C8T6.
5) Simulation tool: JLINK GDLINK

Second, the difference between peripheral hardware

Three, hardware replacement needs to pay attention to

From the above introduction, we can see that the GD32F30/E103 series and the STM32F103 series are compatible, but it also needs some attention.

1) BOOT0 must be connected to 10K pull-down or GND, ST can be left floating, this is very important.
2) RC reset circuit must be present, otherwise MCU may not work normally, ST may not be necessary sometimes.
3) Sometimes it is found that the emulator cannot be connected. Because GD's swd interface drive capability is weaker than ST, there are several ways to solve it:
a. The line should be as short as possible;
b. Reduce the SWD communication rate;
c. SWDIO is connected to 10k pull-up and SWCLK is connected to 10k pull-down.
4) Use battery power supply, etc., pay attention to the working voltage of GD. For example, if it drops to the range of 2.0V~2.6V, ST can still work, and GD may not start or work abnormally.

Fourth, the use of ST standard library development needs to be modified

1) GD has strict timing requirements. To configure the peripherals, you need to turn on the clock first, and configure the peripherals, otherwise it may cause the peripherals to fail to configure successfully; ST can be configured to turn on the clock.

2) Modify the external crystal oscillator start-up timeout time, this step can be skipped without the external crystal oscillator.
Reason: There is a difference between the start-up time of GD and ST, in order to make the GD MCU reset more accurately.
modify:

Modify the macro definition: #define HSE_STARTUP_TIMEOUT ((uint16_t)0x0500) to: #define HSE_STARTUP_TIMEOUT ((uint16_t)0xFFFF)
3) GD32F10X flash value zero wait, while ST requires 2 wait cycles, so some precise delay or simulation The code of IIC or SPI may need to be modified.

Reason: GD32 uses patented technology to improve the code execution speed under the same operating frequency.
Modification: If a for or while loop is used for precise timing, the timing will shorten the loop time due to the faster code execution, so the simulation needs to recalculate the design delay. Using Timer has no effect.

4) Set the read protection in the code. If you use external tools such as JFLASH or offline writer to set the read protection, you can skip this step.
After writing the KEY sequence, you need to read this bit to confirm that the key has taken effect. The modification is as follows: A total of four functions need to be modified as follows:

FLASH_Status FLASH_EraseOptionBytes(void);FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);uint32_t FLASH_GetWriteProtectionOptionByte(void);FlagStatus FLASH_GetReadOutvoidProtectionStatus(void);
5) There is a difference between GD and ST in the Flash time: Erase and Program are modified as follows:

6) Note that the flash needs to be larger than 256K, and this item can be ignored if it is smaller than 256K.

Different from ST, GD flash has the concept of partition. In the first 256K, the CPU executes instructions with zero wait, which is called the code area, and the outside of this range is called the dataZ area. There is no difference between the two in erasing and writing operations, but there is a big difference in the read operation time. The code in the code area has zero waiting time, the execution of the code in the data area has a large delay, and the code execution efficiency is an order of magnitude slower than the code area, so the data area It is generally not recommended to run code that requires high real-time performance. To solve this problem, you can use scatter-loading methods, such as putting initialization code and image code in the data area.

Summary: So far, after the above modification, without using the code of USB and network capable complex protocol, you can use ST code to operate.

-END- | Arrange the articles for the dissemination of related technologies, the copyright belongs to the original author | | If there is any infringement, please contact to delete |
Collection of good articles in the past

STM32 serial port send data and receive data method summary STM32 has been learning for a long time, I still don't know how to do projects. STM32: From a rookie to a master is so simple!
————————————————
Copyright statement: This article is the original article of the CSDN blogger "Walking in the Darkness". It follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and This statement.
Original link: https://blog.csdn.net/weixin_34246598/article/details/112651024

Guess you like

Origin blog.csdn.net/tjcwt2011/article/details/115017605