lucas_mur
Newbie
Hello Everyone,
one of EXTI doesn't work. In fact, I have two EXTI interruptions from PB3 and PB4. whenever I push the button from PB3, the LED power_ON, and whenever I push the button from PB4, the LED power_OFF. The issue that I have, is EXTI3 work and EXTI4 doesn't.
First I activate AFIO clock :
second I enable RCC for GPIOB :
After that, I configure both EXTI3 and EXTI4 :
and Finally I call the function headers for both EXTIs:
I changed the pins but I got the same issue, where do you think the issue came from ?
one of EXTI doesn't work. In fact, I have two EXTI interruptions from PB3 and PB4. whenever I push the button from PB3, the LED power_ON, and whenever I push the button from PB4, the LED power_OFF. The issue that I have, is EXTI3 work and EXTI4 doesn't.
First I activate AFIO clock :
Code:
RCC->APB2ENR |= (1 << 0); //activate AFIO
second I enable RCC for GPIOB :
C:
RCC->APB2ENR &=~(1 << 3)); // clear RCC for GPIOB
RCC->APB2ENR |= (1 << 3)); // Enable RCC for GPIOB
GPIOB->CRL &= ~((1 << 10) | (1 << 9) | (1 << 11) | (1 << 8)); // Clear GPIO PB2 MODE LED
GPIOB->CRL &= ~((1 << 12) | (1 << 13) | (1 << 14) | (1 << 15)); // Clear GPIO PB3 MODE Button1
GPIOB->CRL &= ~((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19)); // Clear GPIO PB4 MODE Button2
GPIOB->CRL |= 0x00000200; // Set GPIO PB2 (01 : output)
GPIOC->CRL |= ((1 << 15) | (1<<19)); // Set GPIO PB3 and PB4 MODE (10 : input)
After that, I configure both EXTI3 and EXTI4 :
C:
AFIO->EXTICR[0] &= ~AFIO_EXTICR2_EXTI3;
AFIO->EXTICR[1] &= ~AFIO_EXTICR2_EXTI4;
AFIO->EXTICR[0] |= AFIO_EXTICR2_EXTI3_PB;
AFIO->EXTICR[1] |= AFIO_EXTICR2_EXTI4_PB;
EXTI->RTSR |= EXTI_RTSR_TR3;
EXTI->RTSR |= EXTI_RTSR_TR4;
EXTI->FTSR &=~(EXTI_FTSR_FT3);
EXTI->FTSR &=~(EXTI_FTSR_FT4);
EXTI->IMR |= EXTI_IMR_MR3;
EXTI->IMR |= EXTI_IMR_MR4;
NVIC_SetPriority(EXTI3_IRQn, 0);
NVIC_SetPriority(EXTI4_IRQn, 0);
NVIC_EnableIRQ(EXTI3_IRQn);
NVIC_EnableIRQ(EXTI4_IRQn);
GPIOB->ODR &= ~(1<<2); //Initialize LED with power_OFF state
and Finally I call the function headers for both EXTIs:
C:
void EXTI3_IRQHandler(void)
{
if (EXTI->PR & EXTI_PR_PR3)
{
GPIOB->ODR |= 1<<2;
for(volatile int i=0; i<20000000; ++i){
__asm("nop");
}
EXTI->PR |= EXTI_PR_PR3;
}
}
void EXTI4_IRQHandler(void)
{
if (EXTI->PR & EXTI_PR_PR4)
{
GPIOB->ODR &= ~(1<<2);
for(volatile int i=0; i<20000000; ++i){
__asm("nop");
}
EXTI->PR |= EXTI_PR_PR4;
}
}
I changed the pins but I got the same issue, where do you think the issue came from ?