本帖最后由 qihang3307 于 2019-5-30 14:18 编辑 下面是程序,问题是根本就没有进入中断,更不用说唤醒了,这么看主函数里面不是开启中断了嘛,大神们怎么解决,求助, void MX_LPTIM1_Init(void) { /* USER CODE BEGIN LPTIM1_Init 0 */ /* USER CODE END LPTIM1_Init 0 */ /* USER CODE BEGIN LPTIM1_Init 1 */ /* USER CODE END LPTIM1_Init 1 */ hlptim1.Instance = LPTIM1; hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH; hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL; hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; if (HAL_LPTIM_Init(&hlptim1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN LPTIM1_Init 2 */ /* USER CODE END LPTIM1_Init 2 */ } /** * @brief LPTIM MSP Initialization * This function configures the hardware resources used in this example * @param hlptim: LPTIM handle pointer * @retval None */ void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim) { if(hlptim->Instance==LPTIM1) { /* USER CODE BEGIN LPTIM1_MspInit 0 */ /* USER CODE END LPTIM1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_LPTIM1_CLK_ENABLE(); /* LPTIM1 interrupt Init */ HAL_NVIC_SetPriority(LPTIM1_IRQn, 0, 2); HAL_NVIC_EnableIRQ(LPTIM1_IRQn); /* USER CODE BEGIN LPTIM1_MspInit 1 */ /* USER CODE END LPTIM1_MspInit 1 */ } } int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART1_UART_Init(); MX_LPTIM1_Init(); /* USER CODE BEGIN 2 */ if (HAL_LPTIM_Counter_Start_IT(&hlptim1, 1000) != HAL_OK) { Error_Handler(); } HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { } } /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInit; /**Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = 16; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 1; RCC_OscInitStruct.PLL.PLLN = 10; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7; RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; HAL_RCC_OscConfig(&RCC_OscInitStruct); if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } /**Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 // |RCC_PERIPHCLK_USART2 |RCC_PERIPHCLK_LPTIM1 |RCC_PERIPHCLK_LPUART1; PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSI; PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } /**Configure the main internal regulator output voltage */ if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } /**Configure the Systick interrupt time */ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); /**Configure the Systick */ HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); } /** * @brief This function handles LPTIM2 global interrupt. */ void LPTIM1_IRQHandler(void) { /* USER CODE BEGIN LPTIM2_IRQn 0 */ /* USER CODE END LPTIM2_IRQn 0 */ HAL_LPTIM_IRQHandler(&hlptim1); /* USER CODE BEGIN LPTIM2_IRQn 1 */ /* USER CODE END LPTIM2_IRQn 1 */ } void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim) { /* Turn on LED2 */ BSP_LED_Toggle(LED2); printf("计数完成\n"); } |
问个关于STM32L4 SPI读数据,前3个字节永远是0
STM32L432 2个SPI同时使用的问题
STM32L476 ADC采集内部温度传感器电压值
STM32L431通过串口下载程序问题
ST的hal库有问题手头有STM32L4或STM32F7的帮忙测试DMA SD卡
STM32L476-Discovery开发板如何进行串口固件烧写
大家有用到STM32L433的CAN通信的吗?
STM32L4 FFT 自带arm_math.h编译不成功
想问一个关于STM32L475 flash的问题
谁有STM32L476的编程手册,传一个,感谢
评分
查看全部评分
我现在调试LPTIM唤醒时碰到一个问题,LPTIM中断能进去但是一直唤醒不了单片机,不知道是不是哪里没理解对。楼主能指点一下吗