cancel
Showing results for 
Search instead for 
Did you mean: 

ExT interrupt not firing.

KumarTP
Associate II

we are using EXTI1 interrupt in our project based on stm32f446. But the Interrupt handler is not firing.

We looked into the interrupt enable registers, Mask registers, etc and all seems fine and a timer interrupt also in the project, which is triggering fine. Please help to rectify this issue.

Clock configuration code generated: is the clock configuration settings correct??

void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);

/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 192;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}

void MX_GPIO_Init(void)
{

GPIO_InitTypeDef GPIO_InitStruct = {0};

/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, CC112x_RST_Pin|CC112x_CS_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);

/*Configure GPIO pins : PCPin PCPin */
GPIO_InitStruct.Pin = B1_Pin|CC112x_INTR_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pins : PCPin PCPin */
GPIO_InitStruct.Pin = CC112x_RST_Pin|CC112x_CS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = LD2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);

/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI2_IRQn);

}

4 REPLIES 4

> We looked into the interrupt enable registers, Mask registers, etc and all seems fine

Show.

Verify be reading respective GPIO_IDR register, that the pin you intend to use indeed is indeed connected to the input signal, i.e. the respective bit in GPIO_IDR should change when you change the input voltage level.

Read out and check/post content of respective SYSCFG_EXTICRx register, and also the EXTI registers.

Generic "interrupt does not fire" checklist here.

JW

This is the second time you've asked this question.

Please use the Code Formatting tool (</> icon,second screen after ...)

If you expect EXTI1 to fire you should be enabling EXTI1 not EXTI2, and enabling a Px1 pin

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

> we are using EXTI1 interrupt

> HAL_NVIC_EnableIRQ(EXTI2_IRQn);

Code says you're using EXTI2, not EXTI1.

> Please help to rectify this issue.

Show a screenshot of the relevant info such as GPIO and EXTI registers. Show that your interrupt handler exists.

If you feel a post has answered your question, please click "Accept as Solution".

So either working together or copying each others home work..

https://community.st.com/t5/stm32-mcus-boards-and-hardware/exti-interrupt-handler-not-trigger-for-stm32f446re/m-p/626281

Present this is a more complete fashion, where the code compiles, and the defines and handlers can be reviewed more critically.

Think through the problem as if you need someone else to understand it, and perhaps in doing so you might see the errors, and the cause rather than the symptoms.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..