STM32F030 的RTC 定时3秒,进入中断后,清除所有标志位,再重设定时时间3秒,后开闹钟,竟然不能再进中断?这个是为什么 if(RTC_GetITStatus(RTC_IT_ALRA)!=0)//RTC_IT_ALRA { } RCC_LSICmd(DISABLE);//OPEN LSI RTC_AlarmCmd(RTC_Alarm_A,DISABLE);//ÄÖÖÓʹÄÜ RTC_ITConfig(RTC_IT_ALRA, DISABLE);//ÖжÏÅäÖà RTC_ClearFlag(RTC_FLAG_ALRAF);//alarm flag RTC_ClearFlag(RTC_FLAG_WUTF);//WakeUp Timer flag RTC_ClearFlag(RTC_FLAG_TAMP2F); RTC_ClearFlag(RTC_FLAG_TAMP1F); RTC_ClearFlag(RTC_FLAG_TSOVF); RTC_ClearFlag(RTC_FLAG_TSF); RTC_ClearFlag(RTC_FLAG_RSF); RTC_ClearITPendingBit(RTC_IT_TS); RTC_ClearITPendingBit(RTC_IT_WUT); RTC_ClearITPendingBit(RTC_IT_ALRA); RTC_ClearITPendingBit(RTC_IT_TAMP1); RTC_ClearITPendingBit(RTC_IT_TAMP2); sleeptemp1=11; IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);//DOGдʹÄÜ 0X5555 IWDG_SetPrescaler(0X7);//Ô¤·ÖƵ IWDG_SetReload(0XAAAA);//×°ÔØÖµ IWDG_ReloadCounter();//0XAAAA IWDG_Enable();//¿ªÆôDOG EXTI_ClearITPendingBit(EXTI_Line0 | EXTI_Line2 | EXTI_Line4 | EXTI_Line1 | EXTI_Line17); // ?? EXIT ???? RTC_AlarmCmd(RTC_Alarm_A,DISABLE);//RTC-CR-ALARM ¹ØµôÄÖÖÓ RTC_TIMESET.RTC_H12 = RTC_H12_AM; RTC_TIMESET.RTC_Hours = 0x02; RTC_TIMESET.RTC_Minutes = 0x00; RTC_TIMESET.RTC_Seconds = 0x02; RTC_SetTime(RTC_Format_BIN, &RTC_TIMESET); RTC_SLEEP(); sleeptemp1=1; RTC_ITConfig(RTC_IT_ALRA, ENABLE);//ÖжÏÅäÖà } void RTC_CONFIG(void) { RTC_InitTypeDef RTC_InitStruct; RTC_TimeTypeDef RTC_TIMESET; int LSIFreq=40000; RTC_INT(); RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);//open the clock PWR_BackupAccessCmd(ENABLE);//POWER OPEN PWR_ClearFlag(PWR_FLAG_WU); RCC_LSICmd(ENABLE);//OPEN LSI /* Wait till LSI is ready */ while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {} /* Check if the StandBy flag is set */ if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET) { /* Clear StandBy flag */ PWR_ClearFlag(PWR_FLAG_SB); /* Check if the StandBy flag is cleared */ if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET) { while(1); } IWDG_ReloadCounter();//FEED WACHDOG RTC_WaitForSynchro(); /* No need to configure the RTC as the RTC config(clock source, enable, prescaler,...) are kept after wake-up from STANDBY */ } else { /* RTC Configuration ******************************************************/ /* Reset Backup Domain */ RCC_BackupResetCmd(ENABLE); RCC_BackupResetCmd(DISABLE); /* Select the RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);//4000 /* Enable the RTC Clock */ RCC_RTCCLKCmd(ENABLE); /* Wait for RTC APB registers synchronisation */ RTC_WaitForSynchro(); IWDG_ReloadCounter();//FEED WACHDOG /* Get the LSI frequency: TIM14 is used to measure the LSI frequency */ //LSIFreq = GetLSIFrequency(); RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24; RTC_InitStruct.RTC_AsynchPrediv = 127; // RTC_InitStruct.RTC_SynchPrediv = (LSIFreq/100) - 1; RTC_InitStruct.RTC_SynchPrediv = 255; RTC_Init(&RTC_InitStruct); /* Set the time to 01h 00mn 00s AM */ RTC_TIMESET.RTC_H12 = RTC_H12_AM; RTC_TIMESET.RTC_Hours = 0x02; RTC_TIMESET.RTC_Minutes = 0x00; RTC_TIMESET.RTC_Seconds = 0x00; IWDG_ReloadCounter();//FEED WACHDOG RTC_SetTime(RTC_Format_BIN, &RTC_TIMESET); } // RTC_DeInit();//³õʼ»¯RTC¸÷¼Ä´æÆ÷Ϊ³õÖµ // // RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);//4000 RCC_RTCCLKSource_LSI LSI_VALUE RCC_RTCCLKSource_LSI // RCC_RTCCLKCmd(ENABLE);//ENABLE rtc CLOCK } void RTC_INT(void) { EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure;IWDG_ReloadCounter();//FEED WACHDOG /* Configure EXTI Line17(RTC Alarm) to generate an interrupt on rising edge */ EXTI_ClearITPendingBit(EXTI_Line17);//¡¢¡¢RTC_IRQn EXTI_InitStructure.EXTI_Line = EXTI_Line17; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//EXTI_Mode_Event EXTI_Mode_Interrupt EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); IWDG_ReloadCounter();//FEED WACHDOG /* Enable the RTC Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;//TIM17_IRQn NVIC_InitStructure.NVIC_IRQChannelPriority = 1;//NVIC_IRQChannelPriority NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); //EXTI_ClearITPendingBit(EXTI_Line0 | EXTI_Line2 | EXTI_Line4 | EXTI_Line1 | EXTI_Line17); // ?? EXIT ???? IWDG_ReloadCounter();//FEED WACHDOG } void RTC_SLEEP(void) { RTC_AlarmTypeDef RTC_AlarmStructure; RTC_TimeTypeDef RTC_TIMESET; RTC_AlarmCmd(RTC_Alarm_A,DISABLE);//RTC-CR-ALARM ¹ØµôÄÖÖÓ IWDG_ReloadCounter();//FEED WACHDOG RTC_GetTime(RTC_Format_BIN, &RTC_TIMESET); RTC_AlarmStructure.RTC_AlarmTime.RTC_H12=RTC_H12_AM;//0 RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours=0x02; RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes=0x00; // RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=( RTC_TIMESET.RTC_Seconds + 0x3b )%60; RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=0x02; //¶¨Ê±Ê±¼äÃë IWDG_ReloadCounter();//FEED WACHDOG RTC_AlarmStructure.RTC_AlarmDateWeekDay = 31; RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date; RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Hours | RTC_AlarmMask_Minutes; RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure); /* Clear RTC Alarm Flag */ RTC_ClearFlag(RTC_FLAG_ALRAF); RTC_ClearFlag(RTC_FLAG_ALRAF);//alarm flag RTC_ClearFlag(RTC_FLAG_WUTF);//WakeUp Timer flag RTC_ClearITPendingBit(RTC_IT_TS); RTC_ClearITPendingBit(RTC_IT_ALRA); RTC_ClearITPendingBit(RTC_IT_TAMP1); RTC_ClearITPendingBit(RTC_IT_TAMP2); /* Enable RTC Alarm A Interrupt: this Interrupt will wake-up the system from STANDBY mode (RTC Alarm IT not enabled in NVIC) */ RTC_ITConfig(RTC_IT_ALRA, ENABLE); /* Enable the Alarm A */ RTC_AlarmCmd(RTC_Alarm_A, ENABLE); IWDG_ReloadCounter();//FEED WACHDOG /* Clear RTC Alarm Flag */ // RTC_ClearFlag(RTC_FLAG_ALRAF); // EXTI_ClearITPendingBit(EXTI_Line0 | EXTI_Line2 | EXTI_Line4 | EXTI_Line1 | EXTI_Line17); // ?? EXIT ???? // PWR_EnterSTANDBYMode(); // PWR_EnterSTOPMode(PWR_Regulator_ON,PWR_STOPEntry_WFI);//WFI=every interrput PWR_Regulator_LowPower PWR_Regulator_ON } |
【STM32F0开发日志/评测/笔记】+互补PWM波的产生
STM32F030 PB14和PB15无法输出PWM求助
【STM32F030探索套件】序列之五 外部中断
【STM32F0开发日志---二】+ucosii.2.92移植在STM32F030
上传个STM32F0+5110+内部温度传感器的菜鸟实例
【STM32F030探索套件使用问题】STM32F030 SPI方式驱动ST7565LCD失败
求一份STM32F051 I2C驱动LCD 12864的例程
STM32F0 M0 向结构体赋值进入HardFault异常
STM32F0 ADC-DMA方式采集2路数据时出现问题
STM32F030C8T6,TIM16定时慢很多问题?
别人说是标志位没清,所以我把所有的标志位都清了。也没有用
1,设置RTC闹钟定时2秒
2,进入STOP状态。
3,到达闹钟时间,进入中断函数,我再次在中断函数里面设置RTC闹钟定时2秒后
4进入STOP状态,…
……………一直循环
1、alarm后,是否重新初始化了RTC,如果没有,下一个唤醒时间应该是用当前的RTC秒进行加。
2、可以设置为秒闹钟,其他的不要,如果不能唤醒,看一下下一分钟是否能发生中断,如果能说明RTC闹钟设置不对。
ALARM后,我把启动时的代码又重跑了一次,应当是初始化了吧,第一次是能进入中断的,但是进入一次后,再也不进了