打印
[STM32L1]

STM32L151 RTC读取问题

[复制链接]
2424|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zhxi|  楼主 | 2014-10-8 10:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
问题描述:
1、设置RTC后,时间与日期都设置,读取时间和日期,发现时间已经对了,而日期却需要读取好几次以后才会正确;
2、时间从23:59:xx跳到 00:00:xx,日期应该也增加一天了,可是发现日期却没有增加。

修改代码:先读时间,再读日期,好像就正常了。
        RTC_GetTime(RTC_Format_BIN,&time);
        RTC_GetDate(RTC_Format_BIN,&date);

读RTC的时候,有读顺序的要求?同样,写RTC是不是也有写顺序要求?
不知道大家有没有遇到同样的情况?
沙发
yinhaix| | 2015-5-14 14:44 | 只看该作者
刚要研究这个,顶一下

使用特权

评论回复
板凳
yinhaix| | 2015-5-18 11:23 | 只看该作者
楼主,上传一下代码

使用特权

评论回复
地板
zhengxiaobin| | 2015-12-16 14:01 | 只看该作者
/**
  * @brief  Gets RTC current time.
  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains
  *                the configuration information for RTC.
  * @param  sTime: Pointer to Time structure
  * @param  Format: Specifies the format of the entered parameters.
  *          This parameter can be one of the following values:
  *            @arg FORMAT_BIN: Binary data format
  *            @arg FORMAT_BCD: BCD data format
  * @NOTE Call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values
  *         in the higher-order calendar shadow registe
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
{
..............
}

使用特权

评论回复
5
广东大掌柜| | 2019-12-23 14:48 | 只看该作者
我也遇到这个问题,换过来好像行了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

34

主题

146

帖子

1

粉丝