LGY
GR533x通过调用以下函数可以获取系统复位的原因:
uint8_t gr533x_get_reset_reason(void)//For GR533x, add it before platform_init().
{
/*获取复位原因*/
uint8_t reset_reason = AON_CTL->DBG_REG_RST_SRC & 0x3F;//reset reason:bit0~bit5
/*如有,则写1清除;由于慢速时钟域,故延时一段时间*/
if (reset_reason)
{
AON_CTL->DBG_REG_RST_SRC = 0x0000003F;
delay_us(100);
}
/*重新使能reset reason record*/
AON_CTL->DBG_REG_RST_SRC = (1 << 24) | (1 << 31);//bit24 to enable reset reason record
while ((AON_CTL->DBG_REG_RST_SRC & (1 << 30)) || !(AON_CTL->DBG_REG_RST_SRC & ( 1 << 16)));
delay_us(100);
return reset_reason;
}
系统中记录和分析复位原因记录的具体方法:
1. 在gr_soc.c 的soc_init函数里面, platform_init() 之前调用上述复位原因记录函数,把复位原因记录到全局变量。
2. 在用户main函数里面,可以对复位原因这个全局变量进行打印输出或存储等,便于后续分析。
3. 对照datasheet 3.4.5 Reset Reason Recorder 章节 Table 3-49,结合记录的复位原因的值,可以得到具体什么原因导致系统的复位。
LGY
有任何问题可在本帖下直接回复~
打开微信,使用“扫一扫”即可关注