ZET6的低电压中断,现在进不了中断,网上也看了很多资料,但是始终就不进不了中断,上升和下降都不进入中断,我把程序贴上,恳请前辈指点一下。
这是PVD中断配置函数:
void PVD_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
//PWR_PVDLevelConfig(PWR_PVDLevel_2V8);
//PWR_PVDCmd(ENABLE);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//EXTI_StructInit(&EXTI_InitStructure);
//EXTI_ClearITPendingBit(EXTI_Line16);
EXTI_InitStructure.EXTI_Line = EXTI_Line16; //ía2¿ÖD¶ÏÏß16רÎaPVDÖD¶Ïê1óÃ
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //μçÑ1μíóú·§Öμê±2úéúÖD¶Ï
EXTI_InitStructure.EXTI_LineCmd = ENABLE; //ê1Äü
EXTI_Init(&EXTI_InitStructure);
}
这是主函数:
int main(void)
{
uint8_t i;
PWR_PVDLevelConfig(PWR_PVDLevel_2V8);
PWR_PVDCmd(ENABLE);
LED_GPIO_Config();
PVD_Config();
USART2_Config();
for(i=0;i<9;i++)
{
USART_SendData(USART2, temp[i]);
while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
}
while(1);
}
这是PVD中断函数:
void PVD_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line16) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line16);
GPIO_SetBits(GPIOB, GPIO_Pin_0);
}
}
始终看不到LED灯闪一下。另外请教一下,要使用PVD中断,连接备用电池的引脚是否一定要连接一个100nf的陶瓷电容到电源啊?我现在就没有加电容,是直接连接到3.3V电源的,还没来得及加陶瓷电容,先发个帖请教一下。
此帖出自
小平头技术问答
一周热门 更多>