我在用keil一步步仿真的时候进入不了中断函数
- void RTC_NVIC_Config()
- {
- NVIC_InitTypeDef NVIC_InitStructure;
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
- NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
- }
- /*******************************************************************************
- *******************************************************************************/
- void rtc_init()
- {
-
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP,ENABLE);
- RTC_NVIC_Config();
-
- PWR_BackupAccessCmd(ENABLE);
- BKP_DeInit();
- RCC_LSEConfig(RCC_LSE_ON);
- while(RCC_GetFlagStatus(RCC_FLAG_LSERDY)==RESET);
- RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
- RCC_RTCCLKCmd(ENABLE);
- RTC_WaitForSynchro();
- RTC_WaitForLastTask();
- RTC_ITConfig(RTC_IT_SEC,ENABLE);
- RTC_WaitForLastTask();
- RTC_SetPrescaler(32767);
- RTC_WaitForLastTask();
-
- }
- void clockinit_RTC()
- {
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP|RCC_APB1Periph_PWR,ENABLE);
- PWR_BackupAccessCmd(ENABLE);
- if(BKP_ReadBackupRegister(BKP_DR1)!=0XA0A0)
- {
-
-
- rtc_init();
- RTC_WaitForLastTask();
- RTC_SetCounter(0x9f92);
- RTC_WaitForLastTask();
- BKP_WriteBackupRegister(BKP_DR1,0xA0A0);
- }
- else
- {
-
- RTC_WaitForSynchro();
- RTC_WaitForLastTask();
- RTC_ITConfig(RTC_IT_SEC,ENABLE);
- RTC_WaitForLastTask();
- }
-
- RCC_ClearFlag();
- }
- void RTC_IRQHandler()
- {
- if(RTC_GetITStatus((RTC_IT_SEC))!=RESET)
- {
- RTC_ClearITPendingBit(RTC_IT_SEC);
- timebz=1;
- }
- }
- int main()
- {
- u16 hour=0,min=0,sec=0;
- u32 timedata=0;
-
-
- printf_init();
- clockinit_RTC();
- while(1)
- {
-
- if(timebz==1)
- {
- timebz=0;
- timedata=RTC_GetCounter();
- hour=timedata/3600;
- min=(timedata%3600)/60;
- sec=timedata%60;
- printf("RTC time is: %0.2d:%0.2d:%0.2d\r\n",hour,min,sec);
- }
- }
- }
复制代码
|