我想做一个上电外部时钟的安全检测功能的程序,看了STM32文档及网上关于CSS机制的文章及代码。可以为什么我始终没法进入NMI_Handler中断函数呢?我的问题在哪儿呢?自己弄代码如下:
main:
[mw_shl_code=c,true]RCC_ClocksTypeDef RCC_Clocks;
int main(void)
{
RCC_ClockSecuritySystemCmd(ENABLE);
RCC_GetClocksFreq(&RCC_Clocks);
while(1);
}
[/mw_shl_code]
stm32f2xx_it.c:
[mw_shl_code=c,true]void NMI_Handler(void)
{
if(RESET != RCC_GetITStatus(RCC_IT_CSS))
{ RCC_HSEConfig(RCC_HSE_ON);
RCC_ITConfig(RCC_IT_HSERDY,ENABLE);
RCC_ITConfig(RCC_IT_PLLRDY,ENABLE);
RCC_ClearITPendingBit(RCC_IT_CSS);
}
}[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = RCC_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0 ; //抢占优先级0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //子优先级0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
NVIC_Init(&NVIC_InitStructure);
RCC_ClockSecuritySystemCmd(ENABLE); //启动时钟安全系统CSS
}
void NMI_Handler(void)
{
if (RCC_GetITStatus(RCC_IT_CSS) != RESET)
{
OutPut5_ON; //点亮警示灯
RCC_HSEConfig(RCC_HSE_ON);
RCC_ITConfig(RCC_IT_HSERDY, ENABLE);
RCC_ClearITPendingBit(RCC_IT_CSS);
}
}
int main(void)
{
OutPutConfiguration();
CSS_Init();
while(1)
{}
}
一周热门 更多>