[STM32L1] STM32L151 RTC读取问题

[复制链接]
3020|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)
{
..............
}
广东大掌柜 发表于 2019-12-23 14:48 | 显示全部楼层
我也遇到这个问题,换过来好像行了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

34

主题

146

帖子

1

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