[原创] 读取RTC成功

kangkls   2018-6-26 16:48 楼主
之前没有定义rtc,所以读取失败,重新定义rtc = pyb.RTC()之后,读取成功了,但是,不是设置的时间。 复位,时间还是错误的时间,没法,重新上电之后,读取时间正确,仔细查看,发现,如果连续读取时间的话,还是有问题,就是后一次读取的时间居然比前一次的时间早,很奇怪哦 rtc = pyb.RTC() >>> print(rtc.datetime()) (2015, 1, 1, 4, 0, 0, 0, 255) >>> rtc.datetime((2018,6, 26, 2,16, 25, 0, 0)) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 2, 175) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 32, 252) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 33, 0) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 34, 141) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 40, 239) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 40, 80) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 40, 35) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 41, 245) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 41, 205) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 41, 160) >>> print(rtc.datetime()) (2018, 6, 26, 2, 16, 25, 41, 115) >>> 此内容由EEWORLD论坛网友kangkls原创,如需转载或用于商业用途需征得作者同意并注明出处 本帖最后由 kangkls 于 2018-6-26 17:19 编辑
http://www.jslaser.com高性价比激光测距传感器

回复评论 (4)

print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 16, 96)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 27, 241)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 37, 204)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 37, 56)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 58, 110)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 0, 244)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 1, 100)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 2, 179)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 2, 126)
>>>


仔细查看,发现,如果连续读取时间的话,还是有问题,就是后一次读取的时间居然比前一次的时间早,很奇怪哦
http://www.jslaser.com高性价比激光测距传感器
点赞  2018-6-26 17:00
datetimetuple格式:(year, month, day, weekday, hours, minutes, seconds, subseconds)

weekday is 1-7 for Monday through Sunday.
subseconds counts down from 255 to 0
点赞  2018-6-26 20:25
就是有点不习惯。这样做的初衷是什么呢?
http://www.jslaser.com高性价比激光测距传感器
点赞  2018-6-27 18:49
引用: kangkls 发表于 2018-6-27 18:49
就是有点不习惯。这样做的初衷是什么呢?

说实话,我也不太明白作者的目的,可能要看看底层代码,才能分析原因了。
点赞  2018-6-28 10:32
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复