cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 Interrupt

Daattavya Aggarwal
Associate II
Posted on August 13, 2017 at 18:48

I am trying to test interrupts on the stm32f429 discovery board. I don't know how to enable the NVIC function as there is nothing mentioned in the user manual. Also, my ide is telling me that the syntax for the syscfg function is wrong. I am simply measuring the number of interrupts and blinking leds corresponding to the counter value.

&sharpinclude <stm32f4xx.h>

int cnt = 0;

void clk_start()

{

RCC ->CFGR |= RCC_CFGR_MCO1_0;

RCC ->CFGR |= RCC_CFGR_MCO1_1;

RCC ->CR |= RCC_CR_PLLON;

RCC ->APB1ENR |= RCC_APB1ENR_TIM2EN;

RCC ->AHB1ENR |= RCC_AHB1ENR_GPIOGEN;

RCC ->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

}

void led_init1()

{

RCC ->AHB1ENR |= RCC_AHB1ENR_GPIOGEN; //Enables port G input output pins by setting the corresponding bit in advanced high performance bus 1 register.

GPIOG ->MODER |= GPIO_MODER_MODER13_0; //Configures pin 13 as a general purpose output pin by setting the corresponding bit in the mode register

GPIOG ->OTYPER &= ~(GPIO_OTYPER_OT_13); //Makes the output type as push-pull by resetting the corresponding bit in output type register.

GPIOG ->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR13_0;//Makes the output medium speed.

GPIOG ->PUPDR &= ~(GPIO_PUPDR_PUPDR13);//No pull up or pull down.

}

void led_init2()

{

RCC ->AHB1ENR |= RCC_AHB1ENR_GPIOGEN; //Enables port G input output pins by setting the corresponding bit in advanced high performance bus 1 register.

GPIOG ->MODER |= GPIO_MODER_MODER14_0; //Configures pin 13 as a general purpose output pin by setting the corresponding bit in the mode register

GPIOG ->OTYPER &= ~(GPIO_OTYPER_OT_14); //Makes the output type as push-pull by resetting the corresponding bit in output type register.

GPIOG ->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR14_0;//Makes the output medium speed.

GPIOG ->PUPDR &= ~(GPIO_PUPDR_PUPDR14);//No pull up or pull down.

}

void EXTI1_IRQHandler()

{

if(EXTI ->PR & EXTI_PR_PR1 == 0)

{

EXTI ->PR |= EXTI_PR_PR1;

}

cnt++;

if(cnt %2 == 0)

{

GPIOG ->BSRRH |= GPIO_BSRR_BS_14;

GPIOG ->BSRRL |= GPIO_BSRR_BS_13;

}

else

{

GPIOG ->BSRRH |= GPIO_BSRR_BS_13;

GPIOG ->BSRRL |= GPIO_BSRR_BS_14;

}

}

void interrupt()

{

SYSCFG->EXTICR[1 >> 2] &= ~(0x0F << (0x04 * (1 & 0x03)));

SYSCFG->EXTICR[1 >> 2] |= (0<< (0x04 * (1 & 0x03)));

EXTI ->IMR |= EXTI_IMR_MR1;

EXTI ->RTSR |= EXTI_RTSR_TR1;

}

int main()

{

clk_start();

led_init1();

led_init2();

while(1)

{

interrupt();

}

}

#interrupt #stm32
1 REPLY 1
Posted on August 13, 2017 at 20:12

The NVIC is part of the core, review the ARM TRM, and CMSIS libraries.

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