2024-05-16 03:03 PM - edited 2024-05-16 03:19 PM
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);
Solved! Go to Solution.
2024-05-17 07:45 AM
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);
}
2024-05-17 07:45 AM
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);
}