2023-06-30 12:35 AM
How to use timer interrupt in GPIO interrupt
2023-06-30 12:43 AM
Priority?
2023-06-30 01:45 AM
Timer
2023-06-30 03:15 AM
Why ?
2023-06-30 04:23 AM
primary your personal sended code nobody see then nobody help.
volatile uint8_t count = 0;
HAL_GPIO_TogglePin(GPIOB, Red_Led_Pin);
HAL_Delay(100);
For ISR variables need volatile. Your count++ and if else is litle complicated.
And your code isnt timer interrupt in GPIO. You only start timer with IT method aplied...
HAL_TIM_Base_Start_IT(&htim3);
And use Delay in callback is mistake if systick isnt higher priority code hang here
2023-06-30 05:21 AM
/** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, Green_Led_Pin|Red_Led_Pin, GPIO_PIN_RESET); /*Configure GPIO pin : Push_Button_Pin */ GPIO_InitStruct.Pin = Push_Button_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(Push_Button_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : Green_Led_Pin Red_Led_Pin */ GPIO_InitStruct.Pin = Green_Led_Pin|Red_Led_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
2023-06-30 05:27 AM
If I press the user button for 2 sec. Then red led will tern on .... Again I press button then red led will tern off.....If I continue press the button led will be tern off........
I did some changes but my problem is not solved ...
2023-06-30 06:07 AM
Dude, tell the people what you want to achieve.
Even your starting post "How to use timer interrupt in GPIO interrupt" is ridiculous, we have no time for guessing.
2023-06-30 06:41 AM
Extremely Sorry ... next time definitely I will try