2 px825182307 px825182307 于 2016.01.28 15:38 提问

stm32 PVD掉电检测,进不了中断

芯片是stm32f103C8T6,PVD掉电检测,中断服务函数是通过串口发送数据。可是并没有发送,不知道是没有进入中断,还是进入了中断,但电压值过低,串口发送数据失败。求大神看看,写了好久没解决问题。代码如下:

void PVD_Init(void)
{
SystemInit();

EXTI_InitTypeDef EXTI_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);//PWRʹÄÜ

/* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and
 falling edges */

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_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}

void PVD_NVIC(void)
{
NVIC_InitTypeDef NVIC_InitStructure;

/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

/* Enable the PVD Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}

void PVD_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line16) != RESET)
{
GPIO_SetBits(GPIOA,GPIO_Pin_1);
start();//串口发送数据
EXTI_ClearITPendingBit(EXTI_Line16);
}
}

int main()
{
.....

PWR_PVDLevelConfig(PWR_PVDLevel_2V9);
PWR_PVDCmd(ENABLE);

PVD_Init();
PVD_NVIC();

....
while(1)
{
;
}

}

1个回答

devmiao
devmiao   Ds   Rxr 2016.01.29 06:58
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!