2022-04-04 11:16 PM
I'm working on STM32G030 in STM32CubeIDE without using the HAL( using Low layer). In that i have enable a timer interrupt using .ioc file (hardware file). When i put a break point in the interrupt handler which is in the stm32g0xx_it.h file, it is not entering the handler.I have also tried by giving the priorities to the interrupt but still it won't work Here is the snippet of the code:
GPIO_InitStruct.Pin = IC_mode_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_2;
LL_GPIO_Init(IC_mode_GPIO_Port, &GPIO_InitStruct);
/* TIM1 interrupt Init */
NVIC_SetPriority(TIM1_BRK_UP_TRG_COM_IRQn, 0);
NVIC_EnableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
NVIC_SetPriority(TIM1_CC_IRQn, 0);
NVIC_EnableIRQ(TIM1_CC_IRQn);
here i have taken TIM1 interrupt. And here is the my Interrupt handler.
void TIM1_CC_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_CC_IRQn 1 */
if(TIM1->SR |= TIM_SR_CC3IF) // When a capture occurs, the corresponding CC1IF flag is set
{
TIM1->SR &= ~TIM_SR_CC3IF; //clear the flag by writing it to 0
TIM1->CCMR1 |=TIM_CCMR1_OC1M_2; //Force inactive level
TIM3->CR1 |= TIM_CR1_CEN; // Starts the counter
}
/* USER CODE END TIM1_CC_IRQn 1 */
}
Can someone explain why does it not enter the handler that is assigned to it.
2022-04-05 01:25 AM
For interrupt capture to occur, you have to have the given timer channel set to capture in CCMR, enabled in CCIR, and and interrupt enabled in DIER. You have shown no code to do that - besides I wouldn't read it anyway, as, at the and of the day, you are supposed to read out and check content of relevant GPIO and TIM and NVIC registers.
Here are some general hints to track down interrupts not firing.
JW