/*********************************************************************************************************//** * @brief Period_Reload program,the example main funtion. * @retval None ***********************************************************************************************************/ void Period_Reload(void) { NVIC_Configuration(); /* NVIC configuration */ CKCU_Configuration(); /* System Related configuration */ USART_Configuration(); /* USART Related configuration */ SYSTICK_Configuration(); /* SYSTICK Related configuration */ LED_Configuration(); /* WatchDog configuration */ WDT_IntConfig(ENABLE); /* Enable WDT Interrupt */ WDT_SetPrescaler(WDT_PRESCALER_8); /* Set Prescaler Value as 2 */ WDT_SetReloadValue(0xEFF); /* Set Reload Value as 0xEFF */ WDT_Restart(); /* Reload Counter as WDTV Value */ WDT_SetDeltaValue(0xA00); /* Set Delta Value as 0xA00 */ WDT_ProtectCmd(ENABLE); /* Enable Protection */ //printf("\n\rWDT Period Reload Starts...\n\r"); //printf("The Program Is Still Working If LED3 Keep Flashing\n\r"); /* Enable the SYSTICK Counter */ SYSTICK_CounterCmd(SYSTICK_COUNTER_ENABLE); while(1); }
/******************************************************************************* * Function Name : Set_System * Description : Configures Main system clocks & power. * Input : None. * Return : None. *******************************************************************************/ void Set_System(void) { /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if(HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); /* On STICE the PLL output clock is fixed to 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } } /* Enable USART1, GPIOA, GPIOD and AFIO clocks RCC_APB2Periph_USART1 |*/ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO | RCC_APB2Periph_USART1, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); /* Configure the used GPIOs*/ GPIO_Configuration(); /* Configure the EXTI lines for Key and Tamper push buttons*/ EXTI_Configuration(); UART_Configuration(); SYSTICK_Configuration(); }