stm8低速时钟校准问题
stm8低速时钟校准问题stm8L10x标准库例程里的这个时钟校准函数一直不理解,求详解啊,一直不理解例程里的低速时钟校准
函数如下:
/**
* @briefUpdate 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)
* but we know that A + x = LSIFreqkHz/4 ==> 4x = LSIFreqkHz-4A
* so can be written :
* 4A >= (LSIFreqkHz-4A)(1+2A)
* @paramLSIFreqHz 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);
}
}
不用理解,直接调用就可以了。。。 zcl201207 发表于 2016-8-22 23:03
不用理解,直接调用就可以了。。。
好吧~我想搞清楚 axushilong 发表于 2016-9-7 09:13
好吧~我想搞清楚
现在理解了?能说一下吗
页:
[1]