/** * @brief Configure PVD event to be connected to BRKIN * @param None * @retval None */ static void SYSCFG_Config(void) { /* Enable SYSCFG clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Connect PVD event with BKIN: when a PVD event (VDD lower than the threshold) is detected a break event is generated */ SYSCFG_BreakConfig(SYSCFG_Break_PVD); }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* PWR clock enable */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); /* PVD configuration: Level 5 */ PWR_PVDLevelConfig(PWR_PVDLevel_5); /* Enable the Power Voltage Detector(PVD) */ PWR_PVDCmd(ENABLE); /* Enable SYSCFG clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Connect PVD event with BKIN: when a PVD event (VDD lower than the threshold) is detected a break event is generated */ SYSCFG_BreakConfig(SYSCFG_Break_PVD); /* TIM1 channels Configuration in PWM mode */ TIM_Config(); /* Wait till a PVD event is detected */ while(PWR_GetFlagStatus(PWR_FLAG_PVDO) == RESET); /* Infinite loop */ while (1) { } }