cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement the TIM_IRQHandler when using other classes

Jvan .10
Associate III

I'm trying to make a scheduler and everything seems to be ready, now the final step is add the proper function to the IRQ_Handler. This is where my problem starts. At default this uses a extern tim object from the main.c. I removed it there and put it in a class, as required for my project.

from the _it.c file:

void TIM3_IRQHandler(void)
{
  /* USER CODE BEGIN TIM3_IRQn 0 */
 
  /* USER CODE END TIM3_IRQn 0 */
  HAL_TIM_IRQHandler(&htim3);
  /* USER CODE BEGIN TIM3_IRQn 1 */
 
  /* USER CODE END TIM3_IRQn 1 */
}

Now is my question. How can I use the tim located in my scheduler class in the IRQHandler?

Thanks in advance!

3 REPLIES 3
KnarfB
Principal III

IRQ handlers are identified by their names which are defined in g_pfnVectors table of startup code. Hence, TIM3_IRQHandler will only be called on TIM3 events. There is nothing wrong with using htim3 wihin the handler.

hth

KnarfB

Pavel A.
Evangelist III

Instead of TIM handle struct, keep in the class a pointer to it.

The struct itself will stay global.

(No, one can't really hide a timer in a class instance. If this is not obvious, think on it as a homework).

-- pa

Jvan .10
Associate III

Fixed the problem, thank you both!