求助:STM32F407 RTC读日期 错误的问题。

[复制链接]
3762|12
 楼主| lianxi47 发表于 2012-12-6 10:15 | 显示全部楼层 |阅读模式
  使用STM32F407 标准库的RTC例程,调用函数RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);读取日期,每5S读一次,发现在每天的凌晨时,小时值读出来,可以从23:59:59 正确的读到第2天的00:00:04S,而日期值在过凌晨后,还是前一天的日期,大约再读1分钟得样子,日期读出来才更新,不知道是什么原因,望各位朋友帮忙分析分析,谢谢。
The current time is :  12-12-12 23:59:56
The current time is :  12-12-12 23:59:59
The current time is :  12-12-12 00:00:04
The current time is :  12-12-12 00:00:09
The current time is :  12-12-12 00:00:14
The current time is :  12-12-12 00:00:19
The current time is :  12-12-12 00:00:24
The current time is :  12-12-12 00:00:29
The current time is :  12-12-12 00:00:34
The current time is :  12-12-12 00:00:39
The current time is :  12-12-12 00:00:44
The current time is :  12-12-12 00:00:49
The current time is :  12-12-12 00:00:54
The current time is :  12-12-12 00:00:59
The current time is :  12-12-12 00:01:04
The current time is :  12-12-12 00:01:09
The current time is :  12-12-12 00:01:14
The current time is :  12-12-12 00:01:19
The current time is :  12-12-12 00:01:24
The current time is :  12-12-13 00:01:29
The current time is :  12-12-13 00:01:34
 楼主| lianxi47 发表于 2012-12-6 11:09 | 显示全部楼层
难道就没有人遇到过,求救啊
 楼主| lianxi47 发表于 2012-12-7 12:26 | 显示全部楼层
看样子要石沉大海了,版主何在
ukkara 发表于 2012-12-7 12:36 | 显示全部楼层
没事,有我在就不会沉!
 楼主| lianxi47 发表于 2012-12-8 06:59 | 显示全部楼层
ukkara 发表于 2012-12-7 12:36
没事,有我在就不会沉!

谢谢哦,难道STM32F407的RTC就没人用。昨晚又对了一遍手册,还是没找到问题!
ukkara 发表于 2012-12-8 09:23 | 显示全部楼层
lianxi47 发表于 2012-12-8 06:59
谢谢哦,难道STM32F407的RTC就没人用。昨晚又对了一遍手册,还是没找到问题! ...

我帮你顶。你找到问题之后在这里讲下,我也弄F4但是还没到RTC。
 楼主| lianxi47 发表于 2012-12-8 12:37 | 显示全部楼层
ukkara 发表于 2012-12-8 09:23
我帮你顶。你找到问题之后在这里讲下,我也弄F4但是还没到RTC。

好的,没问题。你可以用官方例程试一下,看看是不是也是同样的现象啊
dami 发表于 2012-12-8 18:07 | 显示全部楼层
交替的的时候要比较一下。
先读日期再读时间的画就要比较,过零了就重新读下日期。因为上次也许没过零读的日期。
dami 发表于 2012-12-8 18:08 | 显示全部楼层
要不你就每秒都读
dami 发表于 2012-12-8 18:09 | 显示全部楼层
用中断读可能是最好的。
 楼主| lianxi47 发表于 2012-12-8 20:44 | 显示全部楼层
dami 发表于 2012-12-8 18:07
交替的的时候要比较一下。
先读日期再读时间的画就要比较,过零了就重新读下日期。因为上次也许没过零读的 ...

问题已经解决,我在定时中断里50ms读一次日期寄存器,在主循环里1S读一次,就不会出现这种情况了。
广东大掌柜 发表于 2019-12-23 14:07 | 显示全部楼层
lianxi47 发表于 2012-12-8 20:44
问题已经解决,我在定时中断里50ms读一次日期寄存器,在主循环里1S读一次,就不会出现这种情况了。 ...

兄弟,还在论坛么,
香水城 发表于 2019-12-23 17:58 | 显示全部楼层
这个问题经常有人碰到,尤其0时刻这个位置,注意读取顺序。

关于读取STM32 RTC 日历值不更新的话题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

21

主题

68

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部