标题用“扯淡”,只为吸引大家注意,呵呵
看了它的例程就,好像校准起不到作用
下面是例程的主程序片段,只要看最后三行
CLK_MasterPrescalerConfig(CLK_MasterPrescaler_HSIDiv1);
00072
00073 /* Enable SPI clock */
00074 CLK_PeripheralClockConfig(CLK_Peripheral_SPI, ENABLE);
00075 CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
00076 CLK_PeripheralClockConfig(CLK_Peripheral_AWU, ENABLE);
00077
00078 /* Initialization of I/Os in Output Mode */
00079 GPIO_Init(LEDS_PORT, (LED2_PIN | LED3_PIN | LED4_PIN), GPIO_Mode_Out_PP_Low_Fast);
00080
00081 /* Initialization of I/O in Input Mode with Interrupt */
00082 GPIO_Init(BUTTON_PORT, BUTTON_PIN, GPIO_Mode_In_FL_IT);
00083
00084 /* Initialization of the Interrupt sensitivity */
00085 EXTI_SetPinSensitivity(EXTI_Pin_5, EXTI_Trigger_Falling);
00086
00087 /* Initialization of AWU */
00088 /* LSI calibration for accurate auto wake up time base*/
00089 AWU_LSICalibrationConfig(LSIMeasurment());
00090
00091 /* The delay corresponds to the time we will stay in Halt mode */
00092 AWU_Init(AWU_Timebase_12s);
00093
看一下 AWU_LSICalibrationConfig 函数的内容
00129 void AWU_LSICalibrationConfig(uint32_t LSIFreqHz)
00130 {
00131
00132 uint16_t lsifreqkhz = 0x0;
00133 uint16_t A = 0x0;
00134
00135 /* Check parameter */
00136 assert_param(IS_LSI_FREQUENCY(LSIFreqHz));
00137
00138 lsifreqkhz = (uint16_t)(LSIFreqHz / 1000); /* Converts value in kHz */
00139
00140 /* Calculation of AWU calibration value */
00141
00142 A = (uint16_t)(lsifreqkhz >> 2U); /* Division by 4, keep integer part only */
00143
00144 if ((4U * A) >= ((lsifreqkhz - (4U * A)) * (1U + (2U * A))))
00145 {
00146 AWU->APR = (uint8_t)(A - 2U);
00147 }
00148 else
00149 {
00150 AWU->APR = (uint8_t)(A - 1U);
00151 }
00152
00153 /* Set the MR bit to load the new value to the prescalers */
00154 AWU->CSR |= AWU_CSR_MR;
00155
00156 }
校准的结果最终反应在 AWU->APR 的值
然后再看一下 AWU_Init();函数
00073 */
00074 void AWU_Init(AWU_Timebase_TypeDef AWU_TimeBase)
00075 {
00076
00077 /* Check parameter */
00078 assert_param(IS_AWU_TIMEBASE(AWU_TimeBase));
00079
00080 /* Enable the AWU peripheral */
00081 AWU->CSR |= AWU_CSR_AWUEN;
00082
00083 /* Set the TimeBase */
00084 AWU->TBR &= (uint8_t)(~AWU_TBR_AWUTB);
00085 AWU->TBR |= TBR_Array[(uint8_t)AWU_TimeBase];
00086
00087 /* Set the APR divider */
00088 AWU->APR &= (uint8_t)(~AWU_APR_APR);
00089 AWU->APR |= APR_Array[(uint8_t)AWU_TimeBase];
00090
00091 }
它又把 AWU->APR 给刷新了
这样校准后有什么用?实测也是没用的。
上面的程序全部来自stm8l101的固件库
照例程没用,请高手指点应该怎么用。
|