RCC CSR寄存器会存储复位标示,可通过它来知道复位原因,来源:
- 1 if(RCC_GetFlagStatus(RCC_FLAG_PINRST))
- 2 printf("PINRST\r\n");
- 3 if(RCC_GetFlagStatus(RCC_FLAG_PORRST))
- 4 printf("PORRST\r\n");
- 5 if(RCC_GetFlagStatus(RCC_FLAG_SFTRST))
- 6 printf("SFTRST\r\n");
- 7 if(RCC_GetFlagStatus(RCC_FLAG_IWDGRST))
- 8 printf("IWDGRST\r\n");
- 9 if(RCC_GetFlagStatus(RCC_FLAG_WWDGRST))
- 10 printf("WWDGRST\r\n");
- 11 if(RCC_GetFlagStatus(RCC_FLAG_LPWRRST))
- 12 printf("LPWRRST\r\n");
- 13 printf("RCC->CSR:%x \r\n",RCC->CSR);
- 14 RCC->CSR|=0X1000000 ; //清楚中断标示
- 15 printf("RCC->CSR:%x \r\n",RCC->CSR);
简单示例
软件复位:转载
|