完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
LSE Ready卡
使用st-link下载器对板子供电,供电音乐,导致外部LSE始终不能准备好,但LSI可以。换外部电源之后,LSE可以锁定第二个测试,又卡死了,不是电源供电问题,怀疑是LSE不起振,板子上晶振离离也有点距离远,目前没有安装电池,测试不是没有按照电池的问题.Time_init函数加上如下初始化。 #if 1 /* 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); #else RCC_LSICmd(ENABLE); while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {} RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); #endif RTC_WaitForSynchro卡死 首先将标准库例子中RTC_Configuration中的下面三行代码放上Time_init中,如果使用LSI则LSI初始化也应该放出来,可能是因为没有安装电池的原因。这里和Time_init初始化重复了一些,是因为BKP_DeInit了(原来),还有其他异常。 /** * @brief Configures the RTC. * @param None * @retval None */ void RTC_Configuration(void) { #if 0 /*move to top for RTC_WaitForSynchro dead*/ /* Enable PWR and BKP clocks */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE); #endif /* Reset Backup Domain */ BKP_DeInit(); #if 1 #if EN_RTC_LSE /* 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); #else RCC_LSICmd(ENABLE); while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {} RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); #endif #endif /* 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); /* 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 = (32.768 KHz)/(32767+1) */ /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); } void Time_init(void) { /*Enables the clock to Backup and power interface peripherals */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,ENABLE); /*Allow access to Backup Registers*/ PWR_BackupAccessCmd(ENABLE); #if EN_RTC_LSE /* 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); #else RCC_LSICmd(ENABLE); while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {} RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); #endif /*delay_us(100);*//*delay because uart print error chars*/ /*uart_printf("%s line%drn", __FUNCTION__, __LINE__);*/ if (BKP_ReadBackupRegister(BKP_DR1) != CONFIGURATION_DONE) { /* Backup data register value is not correct or not yet programmed (when the first time the program is executed) */ /* RTC Configuration */ uart_printf("RTC configured....rn"); RTC_Configuration(); uart_printf("Please Set time and date from shellrn"); BKP_WriteBackupRegister(BKP_DR1, CONFIGURATION_DONE); } else { delay_us(2000); /* Check if the Power On Reset flag is set */ if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) { uart_printf("Power On Reset occurred...."); } /* Check if the Pin Reset flag is set */ else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) { uart_printf("External Reset occurred...."); } uart_printf("No need to configure RTC....rn"); /* Wait for RTC registers synchronization */ RTC_WaitForSynchro(); /* Enable the RTC Second */ RTC_ITConfig(RTC_IT_SEC, ENABLE); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); } /* Clear reset flags */ RCC_ClearFlag(); /* Check if how many days are elapsed in power down/Low Power Mode- Updates Date that many Times*/ CheckForDaysElapsed(); s_time_date.Month = BKP_ReadBackupRegister(BKP_DR2); s_time_date.Day = BKP_ReadBackupRegister(BKP_DR3); s_time_date.Year = BKP_ReadBackupRegister(BKP_DR4); } 但并没有解决我的问题,怀疑是输入异常状态,虽然没有放后备电池,但总是检测到RTC已经配置,我更改CONFIGURATION_DONE的值,让RTC重配置后,bug 重启!!! |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1218 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1232 浏览 1 评论
635 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
481 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1161 浏览 2 评论
1690浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
350浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
343浏览 3评论
335浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
314浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-3 16:22 , Processed in 0.802560 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191