EEVblog® Electronics Community Forum

Electronics => Microcontrollers => Topic started by: koray692 on April 29, 2016, 08:20:09 am

Title: timer problem ?
Post by: koray692 on April 29, 2016, 08:20:09 am
Hello friends , I am working on a project I need to use timer in this project but .At first time timer and its interrupt working without timer counting after that it works very well what is the reason first time timer start timer interrupt without counting to I wanted 2 second.When AA becomes 1 it start to count than it create a interrupt.

void InitTimer3(){
  RCC_APB1ENR.TIM3EN = 1;
  TIM3_CR1.CEN = 0;
  TIM3_PSC = 279;
  TIM3_ARR = 59999;
  NVIC_IntEnable(IVT_INT_TIM3);
  TIM3_DIER.UIE = 1;
  TIM3_CR1.CEN = AA;
}

void Timer3_interrupt() iv IVT_INT_TIM3 {
   TIM3_SR.UIF = 0;
   GPIOD_ODR.B12=0;     //ve dur
   AA=0;
}

 if(4<ACI_ACCx && r )
{

 GPIOD_ODR.B12=1;   // sa? ip çek   ye?il

 AA=1;
 h=h+1;
 r=~r;

}