最近在搞低功耗实验,想要通过定时器超时产生一个超时事件来唤醒进入stop模式的机器,我用的是stm32l051这款低功耗芯片,里面有个LPTIM
[mw_shl_code=c,true]/* Configure the System clock to have a frequency of 2 MHz (Up to 32MHZ possible) */
SystemClock_Config();
/* Enable the LSI source */
LSI_ClockEnable();
/* Add your application code here*/
/* ### - 1 - Re-target the LSI to Clock the LPTIM Counter ################# */
/* Select the LSI clock as LPTIM peripheral clock */
RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1;
RCC_PeriphCLKInitStruct.LptimClockSelection = RCC_LPTIM1CLKSOURCE_LSI;
HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
/* ### - 2 - Initialize LPTIM peripheral ################################## */
/*
* Instance = LPTIM1.
* Clock Source = APB or LowPowerOSCillator (in this example LSI is
* already selected from the RCC level).
* Counter source = Internal event.
* Clock prescaler = 1 (No division).
* Counter Trigger = Trigger1: PC3 or PB6 (PB6 in this example).
* Active Edge = Rising edge.
*/