cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 pin interrupt configuration from code not working

Bigdan
Associate II

I'm using  STM32G030F6 chip.  Try configure on pin PA8 external interrupt. When it make in UI "PInout & Configuration" tab it works as expected. But I want configure it from code. Here example: 

Added to main.h pin naming 

 

#define FC_ON_Pin GPIO_PIN_8
#define FC_ON_GPIO_Port GPIOA
#define FC_ON_EXTI_IRQn EXTI4_15_IRQn

 

function for pin setup 

 

void FlyControler_Init(void){
#ifdef FC_PINIO
	GPIO_InitTypeDef GPIO_InitStruct = {0};

	/*Configure GPIO pins : FC_ON_Pin */
	  GPIO_InitStruct.Pin = FC_ON_Pin;
	  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
	  GPIO_InitStruct.Pull = GPIO_PULLUP;
	  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	  HAL_GPIO_Init(FC_ON_GPIO_Port, &GPIO_InitStruct);
#endif
}

 

After call this function interrupt is not triggered.

What I do wrong?

2 REPLIES 2
KnarfB
Principal III

Compare carefully to the generated code. The is a _it.c file implementing the raw interrupt handlers and dispatching the corresponding HAL function that will finally call the HAL callback.  

hth

KnarfB

Bigdan
Associate II

Fixed:

void EXTI4_15_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI4_15_IRQn 0 */

  /* USER CODE END EXTI4_15_IRQn 0 */
  HAL_GPIO_EXTI_IRQHandler(POWER_Pin);
  /* USER CODE BEGIN EXTI4_15_IRQn 1 */
#ifdef FC_PINIO
  HAL_GPIO_EXTI_IRQHandler(FC_ON_Pin);
#endif
 /* USER CODE END EXTI4_15_IRQn 1 */
}

Thanks!