2019-10-27 02:56 PM
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)
{
}
}
Solved! Go to Solution.
2019-10-27 06:43 PM
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);
2019-10-27 06:43 PM
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);
2019-10-27 10:00 PM
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)?
2019-10-28 02:37 AM
you're right, i correct it but it still not work.
2019-10-28 02:39 AM
thanks, this is not the problem, it seems like i forget something in the configuration.