tastynoob
Articles58
Tags18
Categories7
GD32V运行速度慢的解决方法

GD32V运行速度慢的解决方法

使用longan mcu时,出现了延时1s却实际上感觉延时了5s左右

这个问题实际上是由于官方提供的时钟初始化函数没有执行

导致核心频率达不到全频108MHz,出现定时器延时错误

我们只需要把该功能开启即可

找到该函数_init()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

void _init()
{
SystemInit();

//ECLIC init
eclic_init(ECLIC_NUM_INTERRUPTS);
eclic_mode_enable();

//printf("After ECLIC mode enabled, the mtvec value is %x \n\n\r", read_csr(mtvec));

// // It must be NOTED:
// // * In the RISC-V arch, if user mode and PMP supported, then by default if PMP is not configured
// // with valid entries, then user mode cannot access any memory, and cannot execute any instructions.
// // * So if switch to user-mode and still want to continue, then you must configure PMP first
//pmp_open_all_space();
//switch_m2u_mode();

/* Before enter into main, add the cycle/instret disable by default to save power,
only use them when needed to measure the cycle/instret */
disable_mcycle_minstret();
}

在主函数开头里调用该函数即可

Author:tastynoob
Link:https://tastynoob.github.io/1970/01/01/GD32V%E8%BF%90%E8%A1%8C%E9%80%9F%E5%BA%A6%E6%85%A2%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可
×