2009-09-24 10:25 AM
External Interrupt - STM32F10C-EVAL
2011-05-17 04:21 AM
Hello,
I am trying to setup the external interrupt for the tamper button and can't seem to get it trigger. I have moved JP1 to the correct location 2-3. My code for setting up the external interrupt for PC13 is shown below.Code:
RCC->APB2ENR |= 1 << 4; /*Enable GPIOC clock*/ /*Enable PC13 as an input*/ GPIOB->CRH &= 0xFF0FFFFF; GPIOB->CRH |= 0x00800000; AFIO->EXTICR[3] &= 0xFFFFFFDF; // clear used pin AFIO->EXTICR[3] |= (0x00000020); // set pin to use EXTI->IMR |= ((1U << 13) ); // unmask interrupt EXTI->EMR |= ((1U << 13) ); // unmask event EXTI->RTSR |= ((1U << 13) ); // set rising edge //EXTI->FTSR |= ((1U << 13) ); // set falling edge NVIC_EnableIRQ(EXTI15_10_IRQn); /* enable pin interrupt at PC13*/ /*Clear interrupt bit*/ EXTI->PR |= (1U<<13); the code for the handler is shown below.Code:
void EXTI15_10_IRQHandler(void) { if (EXTI->PR & (1U<<13)) { // EXTI0 interrupt pending? GPIOD->BSRR = 1<<13; //Set LED EXTI->PR |= (1U<<13); // clear pending interrupt } } Cheers Paul2011-05-17 04:21 AM
Clock to AFIO enabled, too? Btw. you set GPIOB instead of GPIOC, moreover to input pull-up/down, while you don't define if pull-up/down is activated.
Pls check if the pending bit is set in the EXTI (eg. in a main loop) and if the GPIOC->IDR changes, too.