|
本帖最后由 liuqq 于 2015-5-19 01:35 编辑
void PVD_IRQHandler(void)
{
if (EXTI_GetITStatus(EXTI_Line16) != RESET)
{
//清理16号中断线
EXTI_ClearITPendingBit(EXTI_Line16);
//警报灯LE0翻转
LED0 = !LED0;
AT24CXX_Write(0, (u8*)PVD, sizeof(PVD));
}
}
void PVD_Init(void)
{
NVIC_InitTypeDef NVIC_InitStruct;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitStruct.NVIC_IRQChannel = PVD_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);//允许中断
EXTI_ClearITPendingBit(EXTI_Line16);
EXTI_InitStructure.EXTI_Line = EXTI_Line16;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;//EXTI_Trigger_Falling ;//EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
// 以下PVD_Init 一份. main函数在 PVD_Init();前一份
PWR_PVDLevelConfig(PWR_PVDLevel_2V5);
PWR_PVDCmd(ENABLE);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_PWR, ENABLE); //_PWR, ENABLE);
}
|
|