当前位置:网站首页>Use keil5 software to simulate and debug gd32f305 from 0
Use keil5 software to simulate and debug gd32f305 from 0
2022-06-30 10:32:00 【Sky_ Lannister】
Some data collected :
RTT Provided F303 The library of
GD32 BSP Make 1
RTT Make GD32 series BSP
transplant RTT To GD32
Zhaoyi innovation data download
GD32 Standard library migration ( The official website of Zhaoyi innovation only provides the standard library ) The standard library lights up
GD32 Chip package download ( Different from the firmware library package ) If the download is slow, you can also find it on the official website GD32F30x AddOn
GITHUB Upper RTT and GD32 Of BSP Make
GD32F305 Routine for
In fact, after reading the above, there is no need to continue to look down ·······
Here are some tips and process details recorded
One 、 New project and compilation
Will download the keil Chip package in GigaDevice.GD32F30x_DFP.2.2.0.pack, On the installation , Otherwise, there is no way to select the chip model when creating a new project
then GD32F30x_Firmware_Library_V2.1.3\GD32F30x_Firmware_Library_V2.1.3\Template\Keil_project in keil engineering , Not to use it , The main purpose is to copy the path on the new project , Here's the picture 
There are also some configurations 
As for how to select the package in the above figure , In the link mentioned at the beginning, there are
There are also new folders and files , Here's the picture 
In this way, you can see the file naming and classification , Of course, it can also be rebuilt in its own style , Put the mouse over the file , You can also display the location of the file , It is convenient to add files in the following figure ( Right click to select project , choice Manage Project Items come out )
After the file is added , Pay attention to the Utilities Under the folder gd32f307c_lcd_eval.c Screen out , Otherwise, the header file cannot be found , In fact, you can add it manually , But after I finished adding, I looked at the source file , It's just some lcd Related documents , Not usually used , The shielding method is shown in the figure below , Right click to select properties , hold include in target build Just remove the tick at the front 
After the above is done, click compile to pass , however main Many functions in the file cannot be found , It should be based on the standard library functions provided, and it should encapsulate a layer up , So we replaced , It doesn't use his main What's in it
Tips , When replacing his serial port related functions , You can go to GD32F30x_Firmware_Library_V2.1.3\GD32F30x_Firmware_Library_V2.1.3\Examples\USART Check the routine source file under this path , Other peripheral adding methods are similar
The following is the actual measurement that can be compiled led Examples of blinking and serial port printing
#include "gd32f30x.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
#include "gd32f30x_gpio.h"
void led_spark(void)
{
static __IO uint32_t timingdelaylocal = 0U;
if(timingdelaylocal){
if(timingdelaylocal < 500U){
gpio_bit_set(GPIOC, GPIO_PIN_6);
}else{
gpio_bit_reset(GPIOC, GPIO_PIN_6);
}
timingdelaylocal--;
}else{
timingdelaylocal = 1000U;
}
}
void GPIO_Config(void)
{
rcu_periph_clock_enable(RCU_GPIOC);
/*LED*/
gpio_init(GPIOC, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_6);
}
void USART_Config(void)
{
/* enable GPIO clock */
rcu_periph_clock_enable(RCU_GPIOA);
/* enable USART clock */
rcu_periph_clock_enable(RCU_USART0);
/* connect port to USARTx_Tx */
gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_9);
/* connect port to USARTx_Rx */
gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_10);
/* USART configure */
usart_deinit(USART0);
usart_baudrate_set(USART0, 115200U);
usart_receive_config(USART0, USART_RECEIVE_ENABLE);
usart_transmit_config(USART0, USART_TRANSMIT_ENABLE);
usart_enable(USART0);
printf("a usart transmit test example!");
}
int main(void)
{
/* configure systick */
systick_config();
/* initilize the LEDs, USART and key */
GPIO_Config();
USART_Config();
/* print out the clock frequency of system, AHB, APB1 and APB2 */
printf("\r\nCK_SYS is %d", rcu_clock_freq_get(CK_SYS));
printf("\r\nCK_AHB is %d", rcu_clock_freq_get(CK_AHB));
printf("\r\nCK_APB1 is %d", rcu_clock_freq_get(CK_APB1));
printf("\r\nCK_APB2 is %d", rcu_clock_freq_get(CK_APB2));
while (1){
led_spark();
delay_1ms(1);
}
}
/* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f)
{
usart_data_transmit(USART0, (uint8_t)ch);
while(RESET == usart_flag_get(USART0, USART_FLAG_TBE));
return ch;
}
Two 、 Simulation and debugging view
A seemingly normal error is reported in the simulation , Here's the picture ( I don't have permission to read or write that register )
Look up a lot of things on the Internet , Just change the content of the position indicated in the figure below 
I almost enumerate all the numbers on the Internet , No way , Later, I found that they didn't talk about the root , The root is keil5 I won't support it M4 Kernel device , I checked with my colleagues , That's what he said , And then based on this clue, I found a Reliable answer
Official website information reference
We found the reason , The next step is to find a solution , You can't do it if others say no , In the middle, I pulled again gd32 Tools provided on the official website and third-party online simulation tools , To no avail
Look for , Find a seemingly solvable answer
Tried the second method of the big guy , Don't ask why you didn't try the first one ( It has been exhausted )
There is no mistake in the beginning , But it always gets stuck in an uncompiled program , Then I looked at the program , It is grayed out because of the macro definition , So put #define __SYSTEM_CLOCK_IRC8M (uint32_t)(__IRC8M) Let go of , And then put //#define __SYSTEM_CLOCK_120M_PLL_HXTAL (uint32_t)(120000000) Shielded ( Modified the clock source ), Now the error is shown in the following figure ( Stuck here all the time ):
Then think about trying the third method of the boss , Did it for a while , The program runs as soon as it is simulated , But still stuck in the place above , It seems that the situation is even worse , Then try to change .ini Register mapping contents of the file , Go to the data book
The documents modified according to the manual are as follows , Also found that gd32f305 Why not AHB2 ah
map 0x40000000, 0x4000FFFF read write // APB1
map 0x40010000, 0x400157FF read write // APB2
map 0x40018000, 0x5003FFFF read write // AHB1
map 0x60000000, 0xA0000FFF read write // AHB3
Then I found it useless , It seems that this is not the reason , But the mapping is different , On the bright side, this is one of the reasons
Now I have an idea for a moment , Do you want to repeat the first step ( Let's find out why or )
Have a look at the program , It seems that the internal clock is always unstable , I tried it
It doesn't get stuck after it is removed , But it got stuck down there 
The process of finding the cause is arm The community found the following conference presentation , Those who are interested can Click to see 
And then look at , I went to the Internet to check , This problem is caused by the unstable clock of the serial port , This is in line with the penultimate question , So I took the serial port related , Miracles happen , You can simulate 
The next step is to look at the pin changes , Although I can't see the serial port , Looking at the analog pin level can also solve part of the logic
I haven't seen that yet , Another mistake was found , Here's the picture 
I found another interesting thing when I checked the data , To solve the problem, I can even publish papers 
The above problem is article There's a reason , Note that the mapping space should not exceed 0x08000000, Otherwise, an error will be prompted during debugging :“*** error 129: MapMemmap size truncated to 128MB”, unsolvable
Then look at io Port level , Always show undefined identifier, Forget it , Put a global variable directly at the control pin , Then, just look at the changes in the logic analyzer as shown in the following figure 
As can be seen from the above figure, the time is also the same
There is not much about interrupts and other peripherals , If you are interested, you can read the articles written by the big guys


边栏推荐
- Arm新CPU性能提升22%,最高可组合12核,GPU首配硬件光追,网友:跟苹果的差距越来越大了...
- Implementation of monitor program with assembly language
- Automated stock trading ensemble strategy based on Reinforcement Learning
- Deploy lvs-dr cluster
- R语言aov函数进行重复测量方差分析(Repeated measures ANOVA、其中一个组内因素和一个组间因素)、分别使用interaction.plot函数和boxplot对交互作用进行可视化
- MySQL advanced SQL statement of database (1)
- 那个程序员,被打了。
- Chen Haotian won the national championship of the national finals of the 7th children's model star ceremony
- JS get the substring of the specified character position and the specified character position interval of the specified string [simple and detailed]
- OSError: [Errno 28] No space left on device
猜你喜欢
[email protected]基于51系列单片机的智能仪器教具"/>技能梳理[email protected]基于51系列单片机的智能仪器教具

逸仙电商发布一季报:坚持研发及品牌投入,实现可持续高质量发展

MySQL advanced SQL statement of database (2)

“昆明城市咖啡地图”活动再度开启

Apple's 5g chip was revealed to have failed in research and development, and the QQ password bug caused heated discussion. Wei Lai responded to the short selling rumors. Today, more big news is here

《锦绣中华》中老年公益文旅游-走进佛山敬老院

Oracle creates a stored procedure successfully, but the compilation fails

CSDN博客运营团队2022年H1总结

mysql数据库基础:视图、变量

GeoffreyHinton:我的五十年深度学习生涯与研究心法
随机推荐
I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly
打通供应链 深圳礼品展助跨境电商寻破局之道
MIT-6874-Deep Learning in the Life Sciences Week6
Questions about cookies and sessions
Jinbei LT6 is powerful in the year of the tiger, making waves
Splendid China: public welfare tourism for the middle-aged and the elderly - entering Foshan nursing home
Curl --- the request fails when the post request parameter is too long (more than 1024b)
Didn't receive robot state (joint angles) with recent timestamp within 1 seconds
GD32 RT-Thread DAC驱动函数
Automated stock trading ensemble strategy based on Reinforcement Learning
MySQL index, transaction and storage engine of database (2)
【Rust日报】2021-01-22 首份Rust月刊杂志邀请大家一起参与
马斯克推特粉丝过亿了,但他在线失联已一周
Highlight display of Jinbei LB box, adhering to mini special effects
mysql数据库基础:视图、变量
“昆明城市咖啡地图”活动再度开启
ArcGIS Pro脚本工具(5)——排序后删除重复项
机器学习面试准备(一)KNN
keras ‘InputLayer‘ object is not iterable
Launch of Rural Revitalization public welfare fund and release of public welfare bank for intangible cultural heritage protection of ancient tea tree