基于arm的时钟闹钟设计内容摘要:

NVIC_Init(amp。 NVIC_InitStructure)。 } /* * 函数名: GPIO_Configuration * 描述 :配置 GPIO * 输入 :无 * 输出 :无 * 调用 :外部调用 */ void GPIO_Configuration(void) { /*定义一个 GPIO_InitTypeDef 类型的结构体 */ GPIO_InitTypeDef GPIO_InitStructure。 /*开启 GPIOC 的外设时钟 */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE)。 /*选择要控制的 GPIOC 引脚 */ = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3。 /*设置引脚模式为通用推挽输出 */ = GPIO_Mode_Out_PP。 /*设置引脚速率为 50MHz */ = GPIO_Speed_50MHz。 /*调用库函数,初始化 GPIOC*/ GPIO_Init(GPIOC, amp。 GPIO_InitStructure)。 GPIO_SetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3)。 } /* * 函数名: RTC_Configuration * 描述 :配置 RTC * 输入 :无 * 输出 :无 * 调用 :外部调用 */ void RTC_Configuration(void) { /* Enable PWR and BKP clocks */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE)。 13 /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE)。 /* Reset Backup Domain */ BKP_DeInit()。 /* Enable LSE */ RCC_LSEConfig(RCC_LSE_ON)。 /* Wait till LSE is ready */ while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {} /* Select LSE as RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE)。 /* Enable RTC Clock */ RCC_RTCCLKCmd(ENABLE)。 /* Wait for RTC registers synchronization */ RTC_WaitForSynchro()。 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask()。 /* Enable the RTC Second */ RTC_ITConfig(RTC_IT_SEC, ENABLE)。 RTC_ITConfig(RTC_IT_ALR, ENABLE)。 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask()。 /* Set RTC prescaler: set RTC period to 1sec */ RTC_SetPrescaler(32767)。 /* RTC period = RTCCLK/RTC_PR = ( KHz)/(32767+1) */ /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask()。 } /* * 函数名: Time_Regulate * 描述 :返回用户在超级终端中输入的时间值,并将值储存在 * RTC 计数寄存器中。 * 输入 :无 * 输出 :用户在超级终端中输入的时间值,单位为 s 14 * 调用 :内部调用 */ uint32_t Time_Regulate(void) { uint32_t Tmp_HH = 0xFF, Tmp_MM = 0xFF, Tmp_SS = 0xFF。 printf(\r\n==============Time Settings=====================================)。 printf(\r\n Please Set Hours)。 while (Tmp_HH == 0xFF) { Tmp_HH = USART_Scanf(23)。 } printf(: %d, Tmp_HH)。 printf(\r\n Please Set Minutes)。 while (Tmp_MM == 0xFF) { Tmp_MM = USART_Scanf(59)。 } printf(: %d, Tmp_MM)。 printf(\r\n Please Set Seconds)。 while (Tmp_SS == 0xFF) { Tmp_SS = USART_Scanf(59)。 } printf(: %d, Tmp_SS)。 /* Return the value to store in RTC counter register */ return((Tmp_HH*3600 + Tmp_MM*60 + Tmp_SS))。 } /* * 函数名: Time_Adjust * 描述 :时间调节 * 输入 :无 * 输出 :无 * 调用 :外部调用 */ void Time_Adjust(void) { //uint32_t AAAA。 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask()。 //AAAA=Time_Regulate()。 15 /* Change the current time */ RTC_SetCounter(Time_Regulate())。 RTC_SetAlarm( Time_Regulate())。 /*。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。