记得启动CSS前要: /* Enable Clock Security System(CSS) */ RCC_ClockSecuritySystemCmd(ENABLE);
代码放到RCC_IRQHandler中断中,
/* This interrupt is generated when HSE clock fails */ if (RCC_GetITStatus(RCC_IT_CSS) != RESET) { /* At this stage: HSE, PLL are disabled (but no change on PLL config) and HSI is selected as system clock source */
/* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON);
/* Enable HSE Ready interrupt */ RCC_ITConfig(RCC_IT_HSERDY, ENABLE);
/* Enable PLL Ready interrupt */ RCC_ITConfig(RCC_IT_PLLRDY, ENABLE);
/* Clear Clock Security System interrupt pending bit */ RCC_ClearITPendingBit(RCC_IT_CSS);
/* Once HSE clock recover, the HSERDY interrupt is generated and in the RCC ISR routine the system clock will be reconfigured to its previous state (before HSE clock failure) */ }
hotpower在另外的帖子里问得需要指示,可以通过这个函数RCC_GetITStatus(RCC_IT_CSS)得到。上面的中断服务程序作用在最后的说明有解释。
|