Configuring EXTI->EXTICR on Nucleo STM32G031K8 (Cortex M0+)
Good afternoon,
I am attempting to write a bare metal C driver for an interrupt specifically on GPIOA8 for the nucleo-g031k8 (Cortex M0+). I believe there is an issue with how I am changing the register EXTICR in the EXTI. According to figure 29 (pg 322 of RM) I need to adjust the EXTI_EXTICR1.EXTI8 mux to access the PA8 gpio.But when I view the cmsis header file for this chip (stm32g031xx.h) there is no cr1 for pin 8. The only available register is EXTI_EXTICR3_EXTI8. Why is this the case? I would expect the CMSIS header file to follow the RM0444 manual you provided for the chip and have an available EXTICR1_EXTI8 variable available but there is none. Things get even more confusing when I debug the chip and step through the program. According to the debugger, EXTI_EXTICR3_EXTI8 doesn't actually adjust CR3 but instead changes the CR4 register. If any of you could provide a detailed explanation about the EXTICR in this reference manual specifically what m and x mean in the manual and how I am supposed to use this register I think this will fix my issue. I have pasted my code below. If you could explain what I'm doing wrong here, that would be a great help!
Important documents:
- Cortex M0 generic user guide
- RM0444 STM32G0x1 advanced Arm®-based 32-bit MCUs
void pa8_exti_init(void){
/*Disable global interrupts*/
__disable_irq();
/*Enable clock access for GPOIA*/
RCC->IOPENR |= RCC_IOPENR_GPIOAEN;
/*Set PA8 as input*/
GPIOA->MODER &= ~GPIO_MODER_MODE8_Msk; // ~(11) = 00: input
/*Enable clock access for SYSCFG*/
RCC->APBENR2 |= RCC_APBENR2_SYSCFGEN;
/*Select PORTA8 for EXTI*/
EXTI->EXTICR[3] &= ~EXTI_EXTICR3_EXTI8_Msk;
EXTI->EXTICR[3] |= EXTI_EXTICR3_EXTI8;
/*Unmask EXTI8*/
EXTI->IMR1 |= EXTI_IMR1_IM8;
/*Select falling edge trigger*/
EXTI->FTSR1 |= EXTI_FTSR1_FT8 ;
/*Enable EXTI8 line in NVIC*/
NVIC_EnableIRQ(EXTI4_15_IRQn);
/*Enable global interrupts*/
__enable_irq();
}
