STM32F4DISCOVERY Timers Compare Match Interrupt Issue
Dear All,
I am working on STM32F4Doscovery board timers. I want to make a timer interrupt for an application. It can be 1sec or 500ms interrupt. I have read the datasheet and written the program accordingly. But i dont know how to use interrupt in STM32. I have tried something, but nothing is happening. Can someone suggest me a solution??
&sharpinclude 'stm32f4xx.h'
// Component selectionvoid GPIO_Init(void);
void tim10_init(void);
int main(void)
{ GPIO_Init(); tim10_init(); while (1) { GPIOD->ODR|=(1<<15);}
}
void GPIO_Init(void)
{ RCC->AHB1ENR|=RCC_AHB1ENR_GPIODEN; GPIOD->MODER|=(1<<28); // pin 14 is output GPIOD->OTYPER&=~(1<<14);//pin 14 as push pull GPIOD->OSPEEDR|=(1<<29)|(1<<28);//LOW speed GPIOD->PUPDR&=~(1<<29)|(1<<28);//No push pull GPIOD->MODER|=(1<<30); // pin 15 is output GPIOD->OTYPER&=~(1<<15);//pin 15 as push pull GPIOD->OSPEEDR|=(1<<30)|(1<<31);//LOW speed GPIOD->PUPDR&=~(1<<30)|(1<<31);//No push pull }void tim10_init(void)
{ RCC->APB2ENR|=(1<<17); TIM10->CR1|=(1<<7); TIM10->DIER|=(1<<1); TIM10->SR|=(1<<1); TIM10->EGR|=(1<<1); TIM10->CCMR1|=(1<<3)|(0<<1)|(0<<0); TIM10->CCER|=(1<<0); //TIM10->CCR1=5; TIM10->PSC|=4200; TIM10->ARR|=1000; NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);}void TIM10_IRQHandler(void){ GPIOD->ODR|=(1<<14); }#stm32f4-d #learning-stm32