This is a question regarding STM32F0 TIM3.
I have written this code in keil compiler
GPIO_Init(); // Intializing PA5
// Enable clock for GPIOA
RCC->AHBENR |= (1<<17);
//Configuration of PA5
GPIOA->MODER |= (1<<10); // PA5 as general purpose output mode
GPIOA->OTYPER &= ~(1<<5); // PA5 as output push pull
GPIOA->OSPEEDR |= ((1<<10)|(1<<11)); // PA5 at high speed
GPIOA->PUPDR &= ~((1<<10)|(1<<11)); // PA5 as no pull-up, pull-down
GPIOA->ODR = 0; // PA5 as Output Low
RCC->APB1ENR |= (1<<1); // Enable clock for TIM3
TIM3->PSC = 999; // Int clk divided by 1000(999+1)
TIM3->ARR = 7999; // Counts from 0 to 7999
TIM3->DIER = 1; // Update interrupt enable
__NVIC_SetPriority(TIM3_IRQn, 0); // Set TIM3 interrupt vector priority to 0
__NVIC_EnableIRQ(TIM3_IRQn); // Enable TIM3 interrupt vector
TIM3->CR1 = 1; // Enable TIM3 counter
TIM3->SR = 0;
GPIOA->ODR ^= (1<<5); // Toggle PA5 Output
Here system clock freq and timer clock freq is 8Mhz(internal oscillator).
when I run this code I found that my led on PA5 toggles per second that should be as per code.
But there is an problem in output that when microcontroller is done reset by a reset button the PA5 Is immediately high and then toggles @ per second i.e. the tim3 generate a update interrupt when it is enabled. I want that first interrupt should come after timer completion means 1 sec. so that when I reset the microcontroller output can be at low and after 1 sec it toggles( goes high) and so on.