2021-10-28 01:59 AM
Hello,
I'm trying to do basic led blink with STM32F4 Dicovery Board with timer6 using Cube IDE.
As you see in picture 84 Mhz clock divided by 8400 and counts to 10000 so i aimed 1 second toggle.
Also interrupt option of timer 6 is enabled which dosen't seem in picture.
Also Led is in GPIO_Output mode.
Here is my interrupt fuciton:
/**
* @brief This function handles TIM6 global interrupt, DAC1 and DAC2 underrun error interrupts.
*/
void TIM6_DAC_IRQHandler(void)
{
/* USER CODE BEGIN TIM6_DAC_IRQn 0 */
/* USER CODE END TIM6_DAC_IRQn 0 */
HAL_TIM_IRQHandler(&htim6);
/* USER CODE BEGIN TIM6_DAC_IRQn 1 */
HAL_GPIO_TogglePin(LD6_GPIO_Port, LD6_Pin);
/* USER CODE END TIM6_DAC_IRQn 1 */
}
And i did nothin at main.c
Any suggestion ?
2021-10-28 02:08 AM
you forgot to tell us what is your actual problem..... the led is not blinking?
Debugging: did you put a break point inside the TIM6 IRQ, does your program reach the IRQ function at all?
2021-10-28 05:42 AM
Hi Mr. Javier,
Thank you for your answer.
The problem is LED not blinking.
I did changes 8400-1 - 10000-1 and also add the HAL_TIM_Base_Start(&htim6) after /* USER CODE BEGIN 2 */
Still dosen't work.
I put a break point inside TIM6 IRQ and it looks like program DOSEN'T reach the IRQ function.
What do you think i should do now?
2021-10-28 06:40 AM
> And i did nothin at main.c
If you want the timer to generate interrupts, you need to call HAL_TIM_Base_Start_IT to start it.
2021-10-28 07:41 AM
I changed HAL_TIM_Base_Start(&htim6) to HAL_TIM_Base_Start_IT(&htim6)
I added HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); before Base_Start_IT...
And added __HAL_TIM_CLEAR_FLAG(&htim6, TIM_FLAG_UPDATE); after toggling LED in interrupt callback.
Finally works. I don't know which one is real solution.
2021-10-29 12:14 AM
it probably was HAL_TIM_Base_Start_IT , i forgot to add the _IT, my bad