cancel
Showing results for 
Search instead for 
Did you mean: 

stm32n6 gpio interrupts: exti irqhandler missing

svogl
Associate III

Dear all,

I have been modifying the VENC_SDCard_ThreadX example and wanted to start some activity based on the user button, triggered by interrupt using the usual HAL + BSP helpers to init the gpio, and registering a handler function for falling flanks.

So I tried

	BSP_PB_Init(BUTTON_USER1, BUTTON_MODE_EXTI);

and implemented BSP_PB_Callback(). 

Symptom: Hitting the button turned the program to be stuck in some unrelated irqhandler (debugger name-clash -- the defaulthandler triggered), the callback has not been triggered.

I had a look at the BSP implementationn and retried the same with HAL functions, same effect, this code in BSP_PB_Init() sparked my interest:

    (void)HAL_EXTI_GetHandle(&hpb_exti[Button], BUTTON_EXTI_LINE[Button]);
    (void)HAL_EXTI_RegisterCallback(&hpb_exti[Button],  HAL_EXTI_COMMON_CB_ID, ButtonCallback[Button]);

which registers a callback,  and further down the line in stm32n6xx-hal-driver-exti.c there is an HAL_EXTI_IRQHandler  implementation which is not called.

Long story short, the example code seems to miss init code for the actual EXTIxx_IRQHandler. 

// GPIO C13  USER button / exti channel 13
void EXTI13_IRQHandler(void) {
    HAL_EXTI_ClearPending(&hpb_exti_user, EXTI_TRIGGER_FALLING);

    btnCallback(); // in my code I simply perform the action needed not going through HAL
}

the IRQ handler needs a reference to the exti configuration, which the BSP code initialized:

static EXTI_HandleTypeDef hpb_exti_user;

//... near the top of main(), after calling BSP_PB_Init():
	HAL_EXTI_GetHandle(&hpb_exti_user, EXTI_LINE_13);   // USER

I had a look at a fresh CubeMX project, and seemingly the EXTI...IRQHandler functions are not generated.

This code works, but it is a hack - did I miss some code generator option for EXTI? 

Thanks for some insights

Simon

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ANJS
ST Employee

Hello!
Have you checked the NVIC enabled in the GPIO config to generate interrupt?
Best regards
ANJS

 

View solution in original post

2 REPLIES 2
ANJS
ST Employee

Hello!
Have you checked the NVIC enabled in the GPIO config to generate interrupt?
Best regards
ANJS

 
svogl
Associate III

Ahhh, THERE it is, thanks :)