STM32 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 = 0;
		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;//EXTI_Trigger_Falling   ;//EXTI_Trigger_Rising; 
		EXTI_InitStructure.EXTI_LineCmd = ENABLE; 
		EXTI_Init(&EXTI_InitStructure);


}
void PVD_Init_0(void)
{
	  RCC_APB1PeriphClockCmd( RCC_APB1Periph_PWR, ENABLE); //_PWR, ENABLE); // 这个是必需的	
		PWR_PVDLevelConfig(PWR_PVDLevel_2V9); 
		PWR_PVDCmd(ENABLE);
		
}

//PVD中断函数如下
void PVD_IRQHandler(void)
{
	EXTI_ClearITPendingBit(EXTI_Line16); //必须在if外面。
	if(PWR_GetFlagStatus(PWR_FLAG_PVDO)) //
	{
		PWR_ClearFlag(PWR_FLAG_PVDO);
		Save_BLDC_Hall_Position = Motor_Circle_Count_1;
		__set_PRIMASK(1);        //关闭总中断
		WriteData[0] = 0xA5;
		WriteData[1] = Save_BLDC_Hall_Position;
		WriteData[2] = Save_Data_Count;
		WriteEEPROM(Save_Hall_Position_Address,WriteData,3);
		__set_PRIMASK(0); 
		//STMFLASH_Write(FLASH_SAVE_ADDR,(u16*)TEXT_Buffer,11);本想在这里进行存储操作
	}	
}

int main(void)
{
	NVIC_SetVectorTable(NVIC_VectTab_FLASH + 0X0000, 0x0);
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	PVD_Init_0();//PVD初始化的函数,必须放在Main函数的开头处
	PVD_Init();
	}

1、

  RCC_APB1PeriphClockCmd( RCC_APB1Periph_PWR, ENABLE); //_PWR, ENABLE); // 这个是必需的
PWR_PVDLevelConfig(PWR_PVDLevel_2V9); 

PWR_PVDCmd(ENABLE);

必须放在void PVD_Init(void)之前,否则不能进入中断;

2、初始化的函数,尽量在一进入main函数就初始化;

3、芯片型号为stm32f103c8,STM32 PVD中断问题_第1张图片,红色标注框,为0X0800无法进入中断,改为0X1000就可以进入中断。

你可能感兴趣的:(STM32F1X)