Hi 各路大神, STM8L101 内部38K LSI校准不起作用吗? 实测加不加LSIMeasurment(),定时1S ,抓出来的时间都一样。下面是官方代码稍加修改的。 INTERRUPT_HANDLER(AWU_IRQHandler,4) { /* Clear AWU peripheral pending bit */ AWU_GetFlagStatus(); GPIO_ToggleBits(GPIOD, GPIO_Pin_0);//翻转 } void main(void) { /* Clock configuration -----------------------------------------*/ CLK_Config(); GPIO_Init(GPIOD,GPIO_Pin_0,GPIO_Mode_Out_PP_Low_Slow); /*AWU configuration --------------------------------------------*/ AWU_Config(); /* Enable general interrupts */ enableInterrupts(); while (1) { halt(); /* Program halted */ } } static void AWU_Config(void) { /* Initialization of AWU */ /* LSI calibration for accurate auto wake up time base*/ AWU_LSICalibrationConfig(LSIMeasurment()); // AWU_LSICalibrationConfig(10000); /* The delay corresponds to the time we will stay in Halt mode */ AWU_Init(AWU_Timebase_1s); } uint32_t LSIMeasurment(void) { uint32_t lsi_freq_hz = 0x0; uint32_t fmaster = 0x0; uint16_t ICValue1 = 0x0; uint16_t ICValue2 = 0x0; /* Get master frequency */ fmaster = CLK_GetClockFreq(); /* Enable the LSI measurement: LSI clock connected to timer Input Capture 1 */ AWU->CSR |= AWU_CSR_MSR; /* Capture only every 8 events!!! */ TIM2_ICInit( TIM2_Channel_1, TIM2_ICPolarity_Rising, TIM2_ICSelection_DirectTI, TIM2_ICPSC_Div8, 0x0); /* Enable TIM2 */ TIM2_Cmd(ENABLE); /* wait a capture on cc1 */ while ((TIM2->SR1 & (uint8_t)TIM2_FLAG_CC1) != TIM2_FLAG_CC1); /* Get CCR1 value*/ ICValue1 = TIM2_GetCapture1(); TIM2_ClearFlag(TIM2_FLAG_CC1); /* wait a capture on cc1 */ while ((TIM2->SR1 & (uint8_t)TIM2_FLAG_CC1) != TIM2_FLAG_CC1); /* Get CCR1 value*/ ICValue2 = TIM2_GetCapture1(); TIM2_ClearFlag(TIM2_FLAG_CC1); /* Disable IC1 input capture */ TIM2->CCER1 &= (uint8_t)(~TIM_CCER1_CC1E); /* Disable TIM2 */ TIM2_Cmd(DISABLE); /* Compute LSI clock frequency */ lsi_freq_hz = (8 * fmaster) / (ICValue2 - ICValue1); /* Disable the LSI measurement: LSI clock disconnected from timer Input Capture 1 */ AWU->CSR &= (uint8_t)(~AWU_CSR_MSR); return (lsi_freq_hz); } |
STM8S003F3U6 请求各位大佬支援,但是遇到如下问题。。。这样就一定是这颗芯片的问题吗?
STVD如何生成库文件
STM8 flash 库函数 startaddress = startaddress + ((uint32_t)BlockNum * FLASH_BLOCK_S
stm 8 flash 在RAM运行代码的问题,是不是库函数有问题 Library call (?sll32_l0_l0_a) from within a
STM 有能替代MCHC912B32CFUE8 / NXP的型号吗?
STM8S的CAN总线使用
STM8L151在使用DAC功能后严重发热
STM8 IIC SLAVE 400K
STM8S 定时器1互补输出pwm
STM8S003F3 NRST电压低,无法开机
点评