你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

stm8低速时钟校准问题

[复制链接]
axushilong 提问时间:2016-8-22 15:28 /
stm8低速时钟校准问题
stm8L10x标准库例程里的这个时钟校准函数一直不理解,求详解啊,一直不理解例程里的低速时钟校准
函数如下:


/**
  * @brief  Update APR register with the measured LSI frequency.
  * @note   AWU must be disabled to avoid unwanted interrupts.
  * @note   Prescaler calculation:
  *         A is the integer part of LSIFreqkHz/4 and x the decimal part.
  *         x <= A/(1+2A) is equivalent to A >= x(1+2A)
  *         and also to 4A >= 4x(1+2A) [F1]
  *         but we know that A + x = LSIFreqkHz/4 ==> 4x = LSIFreqkHz-4A
  *         so [F1] can be written :
  *         4A >= (LSIFreqkHz-4A)(1+2A)
  * @param  LSIFreqHz Low Speed RC frequency measured by timer (in Hz).
  * @retval None
  */
void AWU_LSICalibrationConfig(uint32_t LSIFreqHz)
{

  uint16_t lsifreqkhz = 0x0;
  uint16_t A = 0x0;

  /* Check parameter */
  assert_param(IS_LSI_FREQUENCY(LSIFreqHz));

  lsifreqkhz = (uint16_t)(LSIFreqHz / 1000); /* Converts value in kHz */

  /* Calculation of AWU calibration value */

  A = (uint16_t)(lsifreqkhz >> 2U); /* Division by 4, keep integer part only */

  if ((4U * A) >= ((lsifreqkhz - (4U * A)) *(1U + (2U * A))))
  {
    AWU->APR = (uint8_t)(A - 2U);
  }
  else
  {
    AWU->APR = (uint8_t)(A - 1U);
  }

}


收藏 1 评论3 发布时间:2016-8-22 15:28

举报

3个回答
zcl201207 回答时间:2016-8-22 23:03:03
不用理解,直接调用就可以了。。。
axushilong 回答时间:2016-9-7 09:13:37
zcl201207 发表于 2016-8-22 23:03
不用理解,直接调用就可以了。。。

好吧~我想搞清楚
帅鹰杨 回答时间:2017-3-13 15:18:39

现在理解了?能说一下吗

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版