Electronic – STM32F429 ignoring writes to EXTI mux registers

armcstm32

The following code is at the start of my main() function:

SystemInit();
SystemCoreClockUpdate();

SysTick_Config(168); // 1 us ticks
NVIC_SetPriority(SysTick_IRQn, 0);

RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN;

// Set EXTI on PB0 for CLK
SYSCFG->EXTICR[0] |= 0b0001;
SET(EXTI->RTSR, EXTI_RTSR_TR0);
SET(EXTI->IMR, EXTI_IMR_MR0);
NVIC_SetPriority(EXTI0_IRQn, 1);
NVIC_EnableIRQ(EXTI0_IRQn);

However, despite the fact that I'm setting the bit flag for the EXTI0 triggered by port B, it's still generating it when PA0 has a rising edge and not when PB0 does. When using a debugger to step through the code, EXTICR1 is indeed unchanged, despite the fact that it is being written to (verified through the disassembly) and even if I use the debugger to set the register, it does not actually change.

What am I doing wrong? I can't find any clock or flag that I need to enable. Stranger still, I recall it working previously with essentially the same code, although I was not using any sort of version control so I can't check the precise details of it.

Best Answer

You might need to enable the System Conifg Controller clock, bit 14 in register RCC_APB2ENR, before writing to EXTICR