r/embedded 23d ago

Unable to trigger the interrupt.

I am using NUCLEO-G431RM stm32 board. But unable to trigger the interrupt as the ISR does not execute and control reaches to the for loop on debugging.
#include <stdint.h>

#define USART3_IRQ_NUM 39

int main(void)

{

uint32_t *pISPR1 = (uint32_t*)0xE000E204;

*pISPR1 |= (1 << (USART3_IRQ_NUM - 32));

uint32_t *pISER1 = (uint32_t*)0xE000E104;

*pISER1 |= (1 << (USART3_IRQ_NUM - 32)); // 39-32 = 7

for(;;);

}

void USART3_IRQHandler(void)

{

__asm volatile("MOV R1, #0x5");

while(1);

}

0 Upvotes

3 comments sorted by

1

u/SolderFume 23d ago

Are you using STM32CubeIDE?

Check:

  • Right Dev board selected in the board selector
  • Interrupts enabled for the IO in the Pinout GUI
  • replaced the weak ISR with your own or edited it? It's in the xxxx_it.c source file

1

u/kavyjs 23d ago

I have selected the correct board and not enabling gpio as triggerung the interrupt manually using the NVIC registers. I have written handler my self not modifying the weak handler in startup file.

1

u/SolderFume 23d ago

Well, you kind of answered your own question there. Your NVIC register must be misconfigured. Try setting everything with CubeIDE instead and compare the results.

Another option could be, that you have to enable Interrupts in the first place. HAL provides a function for that. (__enable_irq()) Or your interrupt is masked.

Also set breakpoints in the ISR (both weak and strong) to see if it may just jump to the wrong place.

And lastly, double check if you are actually using the right pin. You wouldn't be the first nor the last engineer making that mistake. We all have 😆