fix: 修复RTC闹钟中断风暴导致设备假死
1. 关闭未使用的闹钟中断(Rtc_AlmIeCmd改为FALSE) 2. Rtc_IRQHandler增加闹钟标志清除,防止残留标志引发中断死循环
This commit is contained in:
+4
-2
@@ -1,4 +1,4 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "sysctrl.h"
|
#include "sysctrl.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
@@ -303,7 +303,7 @@ void RTCInit(uint8_t sec)
|
|||||||
RtcInitStruct.rtcCompen = RtcCompenEnable;
|
RtcInitStruct.rtcCompen = RtcCompenEnable;
|
||||||
RtcInitStruct.rtcCompValue = 0; //补偿值 根据实际情况进行补偿
|
RtcInitStruct.rtcCompValue = 0; //补偿值 根据实际情况进行补偿
|
||||||
Rtc_Init(&RtcInitStruct);
|
Rtc_Init(&RtcInitStruct);
|
||||||
Rtc_AlmIeCmd(TRUE); //使能闹钟中断
|
Rtc_AlmIeCmd(FALSE); //关闭闹钟中断(未使用)
|
||||||
EnableNvic(RTC_IRQn, IrqLevel3, TRUE); //使能RTC中断向量
|
EnableNvic(RTC_IRQn, IrqLevel3, TRUE); //使能RTC中断向量
|
||||||
Rtc_Cmd(TRUE); //使能RTC开始计数
|
Rtc_Cmd(TRUE); //使能RTC开始计数
|
||||||
Rtc_StartWait(); //启动RTC计数,如果要立即切换到低功耗,需要执行此函数
|
Rtc_StartWait(); //启动RTC计数,如果要立即切换到低功耗,需要执行此函数
|
||||||
@@ -813,6 +813,8 @@ void Uart0_IRQHandler(void)
|
|||||||
|
|
||||||
void Rtc_IRQHandler(void)
|
void Rtc_IRQHandler(void)
|
||||||
{
|
{
|
||||||
|
if(Rtc_GetAlmItStatus() == TRUE)
|
||||||
|
Rtc_ClearAlmItStatus();
|
||||||
if(Rtc_GetPridItStatus() == TRUE) {
|
if(Rtc_GetPridItStatus() == TRUE) {
|
||||||
Rtc_ClearPrdfItStatus(); //清除中断标志位
|
Rtc_ClearPrdfItStatus(); //清除中断标志位
|
||||||
RtcIRQHander();
|
RtcIRQHander();
|
||||||
|
|||||||
Reference in New Issue
Block a user