RTC_GetCounter()函数的功能问题

2019-03-23 17:29发布

timecount=RTC_GetCounter();
请问高手,这个函数是不是取出从1970年到现在的秒钟数?谢谢!
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
10条回答
Li_Lei
2019-03-24 15:33
chenbingjy 发表于 2017-10-18 15:38
我问这个函数的功能。RTC_GetCounter()

返回计数值
/**
  * @brief  Gets the RTC counter value.
  * @param  None
  * @retval RTC counter value.
  */
uint32_t RTC_GetCounter(void)
{
  uint16_t high1 = 0, high2 = 0, low = 0;

  high1 = RTC->CNTH;
  low   = RTC->CNTL;
  high2 = RTC->CNTH;

  if (high1 != high2)
  { /* In this case the counter roll over during reading of CNTL and CNTH registers,
       read again CNTL register then return the counter value */
    return (((uint32_t) high2 << 16 ) | RTC->CNTL);
  }
  else
  { /* No counter roll over during reading of CNTL and CNTH registers, counter
       value is equal to first value of CNTL and CNTH */
    return (((uint32_t) high1 << 16 ) | low);
  }
}

一周热门 更多>