# 工程创建参考:https://shequ.stmicroelectronics ... p;extra=#pid26570715 x( q3 P" }4 _) J8 v4 V8 ~. A 7 C" f# R9 u9 d9 r # CubeMX配置工程8 c f' Y7 C$ o2 [ ; j0 v$ o: X! {" Y$ K! V+ o9 A # 修改代码/ X t$ F* w" Y' U+ O static void MX_LPTIM3_Init(void) { /* USER CODE BEGIN LPTIM3_Init 0 */ /* USER CODE END LPTIM3_Init 0 */ 7 p! B2 `6 U) l. R9 C& }; ~ /* USER CODE BEGIN LPTIM3_Init 1 */ /* USER CODE END LPTIM3_Init 1 */& H4 S8 E6 k+ [0 X4 A; }+ f$ N hlptim3.Instance = LPTIM3; hlptim3.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; hlptim3.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV128;2 R8 X# A" S1 O- N" T3 U- z# L hlptim3.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; hlptim3.Init.Period = 65535; hlptim3.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; hlptim3.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;; d' z9 P [/ w; C hlptim3.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; hlptim3.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; hlptim3.Init.RepetitionCounter = 0; if (HAL_LPTIM_Init(&hlptim3) != HAL_OK) {; ~) D' h4 Z @ H2 ]: S9 h2 z& o Error_Handler(); }4 |; M" ?7 g. L/ w( S+ ~ /* USER CODE BEGIN LPTIM3_Init 2 */ HAL_LPTIM_Counter_Start_IT(&hlptim3);//添加启动低功耗定时器 /* USER CODE END LPTIM3_Init 2 */& ~' }8 x1 P/ x2 E; ?" D } , b2 N% V+ W1 w( K# |: o( i while (1)% J7 f) f. M/ B9 A {: Q2 p/ m$ V4 U0 X2 V& G3 J /* -- Sample board code for User push-button in interrupt mode ---- */ if (BspButtonState == BUTTON_PRESSED)2 R4 s; X' `. f$ `+ ] {" i; ?9 B( w+ u, f' k /* Update button state */ BspButtonState = BUTTON_RELEASED;" ^9 b' Z0 J1 U! c1 e /* -- Sample board code to toggle leds ---- */( i! \. G. B3 ~3 P* l7 L BSP_LED_Toggle(LED_GREEN); /* ..... Perform your action ..... */ } HAL_SuspendTick();//添加进入休眠,以及串口打印命令 printf("\r\n Enter sleep mode! \r\n");! r( r6 h' E5 _" V+ U# Z BSP_LED_Off(LED_GREEN);5 w! s2 {# f2 n& @: _. a HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* USER CODE END WHILE */) U- ~ w8 ~7 }/ P- {$ Z /* USER CODE BEGIN 3 */ }' ^% {; \$ @0 d, M# R( q0 Z 1 J0 U2 L, a: ~* A6 E /* USER CODE BEGIN 0 */9 v/ s& @. l+ w/ W void HAL_LPTIM_UpdateEventCallback(LPTIM_HandleTypeDef *hlptim) {//添加回调函数、唤西醒并打印提示: o/ F# H3 g3 j: H HAL_ResumeTick();( m+ N: L) k% g1 \5 i ]1 n BSP_LED_On(LED_GREEN); printf("\r\n Exit sleep mode ! \r\n");! d0 T! |* ?7 A }3 f" h" P/ p* \7 i/ Q /* USER CODE END 0 *// t8 l5 V ]3 L 3 H0 U: C7 ]5 Z- \8 Z2 L E # 下载运行,看效果 & h% ~/ ]1 q9 C9 P |
【狂欢三】PWNUCLEO-U083RC M 互补输出配置
IDE删除编译中间文件
NUCLEO-U083RC学习历程-空闲中断+DMA接收不定长数据
今天下午直播 | 解析STM32U0 新一代超低功耗入门级MCU
STM32CubeIDE 快速入门指南
有奖直播 | 解析STM32U0 新一代超低功耗入门级MCU
行业应用篇 | STM32U0为水气表提供降本增效新思路
【NUCLEO-WB09KE评测】BLE创建服务和写特征控制LED
基于STM32CubeIDE+MPU6050做的动量轮平衡自行车(一)
【NUCLEO-WB09KE评测】使用I2C点亮一个OLED