cancel
Showing results for 
Search instead for 
Did you mean: 

Help- on Using TIM16 with Shared NVIC for 10 ms Interrupts

kumarairia
Associate II

Hello Expert,

 

I am working on an STM32F303VET6 project using the MCSDK. I want to configure TIM16 to generate a 10 ms periodic interrupt . However, I noticed that on this MCU, TIM16 shares its NVIC vector with TIM1 (TIM1_UP_TIM16_IRQHandler), which is already used by MCSDK for motor control.

Could you please advise:

  1. Can I safely use TIM16 for my 10 ms task while TIM1 is used by MCSDK?

  2. If yes, what is the recommended way to handle the shared interrupt? 

  3. Are there any potential conflicts or timing issues I should be aware of?

  4. If the solution could be illustrated with an example, it would make me so happy.

 

In MCSDK- 6.41 , #define TIMx_UP_M1_IRQHandler TIM1_UP_TIM16_IRQHandler

void TIMx_UP_M1_IRQHandler(void)
{
/* USER CODE BEGIN TIMx_UP_M1_IRQn 0 */

/* USER CODE END TIMx_UP_M1_IRQn 0 */

LL_TIM_ClearFlag_UPDATE(TIM1);
R3_2_TIMx_UP_IRQHandler(&PWM_Handle_M1);
TSK_DualDriveFIFOUpdate(M1);

/* USER CODE BEGIN TIMx_UP_M1_IRQn 1 */

/* USER CODE END TIMx_UP_M1_IRQn 1 */
}

1 ACCEPTED SOLUTION

Accepted Solutions
gbm
Principal

No need for 10ms interrupt - add some code to SysTick ISR to execute every 10 interrupts.

If you want to use the shared interrupt, in the ISR first check the flag to determine which peripheral caused the interrupt, then invoke the proper handler only if the flag is set.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

View solution in original post

2 REPLIES 2
STuser2
Senior III

My suggestion would be to not write additional code in the interrupt routine but just update a flag and in the while loop check for the flag and perform the action. This is the safest method i assume you have to verify the 10ms period by toggling a port and confirming the behavior.

 

gbm
Principal

No need for 10ms interrupt - add some code to SysTick ISR to execute every 10 interrupts.

If you want to use the shared interrupt, in the ISR first check the flag to determine which peripheral caused the interrupt, then invoke the proper handler only if the flag is set.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice