2017-10-16 12:24 PM
Hello All.
I am new to STM32F microcontrollers, though I have worked with Freescale/NXP Kinetis ARM processors for quiet a few years.
I am trying to get and external interrupt (on port C bit 13) to work on a 48 pin STM32F091 MCU.
A push button is pulled up with an external 10k ohm resistor. Pushing button pulls Port C13 to ground.
Here is what I am doing...
Initialization...
void init( void )
// Enable Port C clock
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
// Connect PORTC bit 13 to EXTI13
SYSCFG->EXTICR[3] = SYSCFG_EXTICR4_EXTI13_PC;
// Interrupt on falling edge
EXTI->FTSR |= EXTI_FTSR_TR13;
// Unmask EXTI interrupt
EXTI->EMR |= EXTI_IMR_MR13;
// Set EXTI4_15 irq to priority 2
NVIC_SetPriority( EXTI4_15_IRQn, 2 );
// Enable EXTI4_15 IRQ in NVIC
NVIC_EnableIRQ( EXTI4_15_IRQn );
// Enable global interrupts
_enable();
}
The ISR
void EXTI_4_15_Handler( void )
{
if( EXTI->PR & EXTI_PR_PR13 ) // EXTI 13 occur?
{
EXTI->PR |= EXTI_PR_PR123; // If so, clear pending bit
cout('*'); // Show a * on console
}
}
My main loop code polls GPIOC->IDR for a valid push button closure, and when pushed, the bit in the IDR reads 0 (1 otherwise), however, the ISR never executes.
When I simulate an external interrupt by setting bit 13 in the EXTI->SWIER |= EXTI_SWIER_SWIER13,, the ISR executes, printing a '*' on the console.
I have read in the STM32F0 reference manual that Port C13 is also part of the RTC domain, but it does not appear that PC13 plays any part in the RTC.
What could possibly be wrong?
Thanks in advance
Mike
Solved! Go to Solution.
2017-10-16 12:52 PM
Problem solved.
I forgot to enable the SYSCFG clock.
2017-10-16 12:52 PM
Problem solved.
I forgot to enable the SYSCFG clock.