cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-C031 Pin Change interrupt not firing

MHank.1
Associate III

[Update]

Seems you can't mix C and C++ files easily, so I converted the main file to C and everything works fine.

[/update]

I am attempting to do what I thought would be a simple pin change interrupt on PB0.

I set up the pin change in HAL and it works, I do it in my C++ project and it doesn't. The registers look the same but I don't see what the problem is. I've been chasing it for hours.

I have a debounced external button, tested with other processors and with this board and HAL and it works as advertised.

The button is wired to pin CN10 34 @ 5V

void EXTI0_1_IRQHandler (void)
{
	EXTI->RPR1 |= 1;
}
 
int main(void)
{
	// Enable GPIOB clock
	RCC->IOPENR|= RCC_IOPENR_GPIOBEN;
 
	// Enable SYSCFGEN
	RCC->APBENR2 |= RCC_APBENR2_SYSCFGEN;
 
	// Configure PB0 as output with pull down
	GPIOB->MODER &= ~(3 << 0);
	GPIOB->PUPDR |= 2;
 
	// External interrupt select PB0
	EXTI->EXTICR[0] |= EXTI_EXTICR1_EXTI0_0;
	// wakeup with interrupt unmasked PB0
	EXTI->IMR1 |= EXTI_IMR1_IM0;
	// Rising edge select
	EXTI->RTSR1 |= EXTI_RTSR1_RT0_Msk;
 
        NVIC_SetPriority(EXTI0_1_IRQn, 1);
	NVIC_EnableIRQ(EXTI0_1_IRQn);
 
    /* Loop forever */
	for(;;);
}

Any help appreciateed.

PartsBin - An Electronic Parts Organizer for Windows
1 REPLY 1
S.Ma
Principal

Check IRQ_Self_Setlle.c here

The demo that runs on STM32C0316-DK enables MCO and by manually injecting it to an EXTI input pin to flood and swamp the core with interrupts. The demo countermeasure use a HW Timer to limit the core workload to avoid what would be similar to a DDOS attack-like.