cancel
Showing results for 
Search instead for 
Did you mean: 

Not all timer interrupts working on STM32F407 (shared timer IRQ settings)

jlaufer
Associate II

I am trying to control 8 independent pulse channels using 8 independent pins of the STM32F407. Each pin will supply the pulse pin to a different motor, so I will be controlling 8 independent motors with the microcontroller. For each pin I am assigning an independent timer's Output Compare Channel. I have assigned the timers as follows:

PA1 - TIM5_CH2

PA5 - TIM2_CH1

PA6 - TIM3_CH1

PA7 - TIM14_CH1

PA8 - TIM1_CH1

PB8 - TIM4_CH3

PB9 - TIM11_CH1

PE5 - TIM9_CH1

TIM5, TIM2, TIM3, and TIM4 work as expected. But as soon as I try to toggle TIM14, TIM1, TIM11 or TIM9 it stops working. I noticed that the timers that don't work require NVIC settings are shared between multiple timers. I don't understand why they are shared like this but it appears the issue is related. Here are the NVIC settings:

 

 

HAL_NVIC_SetPriority(TIM5_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM5_IRQn); 
HAL_NVIC_SetPriority(TIM2_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM2_IRQn);
HAL_NVIC_SetPriority(TIM3_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM3_IRQn); 
HAL_NVIC_SetPriority(TIM8_TRG_COM_TIM14_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn); 
HAL_NVIC_SetPriority(TIM1_CC_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn); 
HAL_NVIC_SetPriority(TIM4_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM4_IRQn); 
HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM11_IRQn); 
HAL_NVIC_SetPriority(TIM1_BRK_TIM9_IRQn,15,0); 
HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jlaufer
Associate II

It was the IRQ handler names which are different as well as the NVIC settings

 

void SysTick_Handler(void)
{
	HAL_IncTick();
	HAL_SYSTICK_IRQHandler();
}

void USART2_IRQHandler(void)
{
	HAL_UART_IRQHandler(&huart2);
}

void TIM5_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer5);
}

void TIM2_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer2);
}

void TIM3_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer3);
}

void TIM8_TRG_COM_TIM14_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer14);
}

void TIM1_CC_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer1);
}

void TIM4_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer4);
}

void TIM1_TRG_COM_TIM11_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer11);
}

void TIM1_BRK_TIM9_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer9);
}

View solution in original post

1 REPLY 1
jlaufer
Associate II

It was the IRQ handler names which are different as well as the NVIC settings

 

void SysTick_Handler(void)
{
	HAL_IncTick();
	HAL_SYSTICK_IRQHandler();
}

void USART2_IRQHandler(void)
{
	HAL_UART_IRQHandler(&huart2);
}

void TIM5_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer5);
}

void TIM2_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer2);
}

void TIM3_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer3);
}

void TIM8_TRG_COM_TIM14_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer14);
}

void TIM1_CC_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer1);
}

void TIM4_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer4);
}

void TIM1_TRG_COM_TIM11_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer11);
}

void TIM1_BRK_TIM9_IRQHandler(void)
{
	HAL_TIM_IRQHandler(&htimer9);
}