Home > other >  Stm32 PVD off electricity detection, couldn't get into the interrupt, strives for the great god
Stm32 PVD off electricity detection, couldn't get into the interrupt, strives for the great god

Time:10-01

Chip is stm32f103C8T6, PVD off electricity detection, interrupt service function is through a serial port to send data, but not to send, don't know is not to enter the interrupt, or enter the interrupt, but the voltage is too low, a serial port to send data failure, a great god see, write for a long time didn't solve the problem, the code is as follows:

 void PVD_Init (void) 
{
SystemInit ();
EXTI_InitTypeDef EXTI_InitStructure;
RCC_APB1PeriphClockCmd (RCC_APB1Periph_PWR, ENABLE);//PWRe1? U

/* 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 (& amp; EXTI_InitStructure);
}

Void PVD_NVIC (void)
{
NVIC_InitTypeDef NVIC_InitStructure;

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

/* the 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 (& amp; NVIC_InitStructure);
}

Void PVD_IRQHandler (void)
{
If (EXTI_GetITStatus (EXTI_Line16)!=RESET)
{
GPIO_SetBits (GPIOA, GPIO_Pin_1);
Start ().//a serial port to send data
EXTI_ClearITPendingBit (EXTI_Line16);
}
}

Int main ()
{
.

PWR_PVDLevelConfig (PWR_PVDLevel_2V9);
PWR_PVDCmd (ENABLE);

PVD_Init ();
PVD_NVIC ();

.
While (1)
{
;
}
}

CodePudding user response:

The use of leds in instructions

CodePudding user response:

Not ah, tried

CodePudding user response:

The corresponding clock open
  • Related