cancel
Showing results for 
Search instead for 
Did you mean: 

Hello!! what is wrong ? I want to do an external interrupt with button (gpio A0) to turn on the led (gpio D14) (STM32F407DISC) and do not work..

MHMallek
Associate II

void init_led(){

RCC->AHB1ENR|=0x8;

GPIOD->MODER|=0x10000000;

}

void led_on(){

GPIOD->ODR |= 0x4000;

}

void led_off(){

GPIOD->ODR &= 0xBFFF;

}

void init_button(){

RCC->AHB1ENR|=0X1; //ENABLE CLOCK TO GPIOA

GPIOA->MODER &= ~0x03; // make gpioa0 mode input

EXTI->FTSR |=0x01;

EXTI->IMR |=0x1;

// EXTI->EMR |=0x1;

NVIC->ISER[0] |=(1<EXTI0_IRQn);

}

void EXTI0_IRQHandler(){

if ((EXTI->PR & 0x01)){

EXTI->PR = 0x01;

led_on();

}

}

void init_syscfg(){

RCC->APB2ENR|=0x4000;

(*((uint32_t*)0x40013808)) &= ~0x15;

}

int main(void)

{

init_button();

init_syscfg();

init_led();

while (1)

{

}

}

1 ACCEPTED SOLUTION

Accepted Solutions

If you want to program like this you need to be able to user a debugger to check your work and cross check with the reference manual.

Use a shift here

NVIC->ISER[0] |=(1<EXTI0_IRQn);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

If you want to program like this you need to be able to user a debugger to check your work and cross check with the reference manual.

Use a shift here

NVIC->ISER[0] |=(1<EXTI0_IRQn);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
turboscrew
Senior III

Check this: (*((uint32_t*)0x40013808)) &= ~0x15;

It seems to say : SYSCFG_EXTICR1.EXTI1 &= 0%1110, SYSCFG_EXTICR1.EXTI0 &= 0%1010

What should be left? Maybe you meant to write 15 (decimal, not hex)?

you're right, i correct it but it still not work.

0690X00000ArKgXQAV.png

thanks, this is not the problem, it seems like i forget something in the configuration.