完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
如题,是否有其他朋友遇到类似问题。
我分析hal库,发现在“HAL_RTC_SetDate”函数中,有怎么一条判断,才导致无法写入日期: /* Reset time to be aligned on the same day */ /* Read the time counter*/ counter_time = RTC_ReadTimeCounter(hrtc); /* Fill the structure fields with the read parameters */ hours = counter_time / 3600; if (hours > 24) { /* Set updated time in decreasing counter by number of days elapsed */ counter_time -= ((hours / 24) * 24 * 3600); /* Write time counter in RTC registers */ if (RTC_WriteTimeCounter(hrtc, counter_time) != HAL_OK) { /* Set RTC state */ hrtc->State = HAL_RTC_STATE_ERROR; /* Process Unlocked */ __HAL_UNLOCK(hrtc); return HAL_ERROR; } /* Read current Alarm counter in RTC registers */ counter_alarm = RTC_ReadAlarmCounter(hrtc); /* Set again alarm to match with new time if enabled */ if (counter_alarm != RTC_ALARM_RESETVALUE) { if(counter_alarm < counter_time) { /* Add 1 day to alarm counter*/ counter_alarm += (uint32_t)(24 * 3600); /* Write new Alarm counter in RTC registers */ if (RTC_WriteAlarmCounter(hrtc, counter_alarm) != HAL_OK) { /* Set RTC state */ hrtc->State = HAL_RTC_STATE_ERROR; /* Process Unlocked */ __HAL_UNLOCK(hrtc); return HAL_ERROR; } } } } |
|
相关推荐
11个回答
|
|
没有研究过。。。
|
|
|
|
RTC日期需要备份 在单片机复位后读出备份日期
|
|
|
|
我现在也遇到了这样的问题,开机后显示2000年01月01日
|
|
|
|
|
|
楼主,请问你的问题有解决吗?可否分享下,谢谢!
|
|
|
|
关注一下,看大神解答
|
|
|
|
你好,请问问题解决了么?可否说说怎么解决的?我现在遇到同样的问题了,正在探索中。
|
|
|
|
大家问题都解决了吗,能否分享一下
|
|
|
|
同问,现在也遇到这样的问题了,复位后时间是对的,日期就不对了
|
|
|
|
同问,很奇怪的问题,为什么时间是对的,就是日期不对
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
693 浏览 1 评论
952 浏览 1 评论
1912 浏览 1 评论
1644 浏览 1 评论
MCU友好过渡MPU,米尔基于STM32MP135开发板裸机开发应用笔记
694 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-5-14 18:49 , Processed in 0.619393 second(s), Total 65, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号