This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

timer1 an timer 3 diferents result to counts tick cc2541

Other Parts Discussed in Thread: CC2541

hello people i use timer 1 and timer 3 to count tiks  (timer 1 is a 16bits, timer 3 is 8 bits)   the 2 are configured in free mode and prescaler = 1 and uste timer 4 how the timer ( for example when the pass x cicles stop  the other times)

and mi code is this:

 static uint32 countMeasure,countMeasure1, contador ;

uint16 minutes=1000;//5858;

int main(void)
{
 
  // TICKS  and clock To 32Mhz
  CLKCONCMD =0X00; 

  T1IE = 1;
    T3IE = 1;
  T4IE = 1;
    // Enable global interrupt by setting the [IEN0.EA=1].
    EA = 1;   
  // divide preescaler to 1.
 T4CC0 = 0xF0;
 T4CTL = T4CTL_DIV_128 | T4CTL_OVFIM | T4CTL_MODE_FREERUN  | T4CTL_START;
T3CTL = 0x18;
T1CTL = 0x01;

   BLUE =0;
 RED  =0;
 

for(;;){


  }
        

}



/*******************************************************************************
* @fn      t1_isr
*
* @brief   Interrupt handler for Timer 3 overflow interrupts. LED1 is turned
*          off and LED3 is turned on. Interrupts from Timer 3 are level
*          triggered, so the module interrupt flag is cleared
*          prior to the CPU interrupt flag.
*
* @param   void
*
* @return  void
*
*******************************************************************************/

#pragma vector = T1_VECTOR
__interrupt void t1_isr(void)
{
    // Clears the module interrupt flag.
   T1STAT = 0;
   //T3OVFIF = 0;    

    
      //while is wqual to  1 is count
     if (count==1){
           countMeasure1++;
   
     } else {
      // countMeasure1= (countMeasure1); // multiply countMeasure to *65535;
         printf("tiks = %ld \n", countMeasure1);
      //stop interrupts 
       T1IE = 0;
     //   EA = 0;
     //stop timer
     T1CTL=0X00;   
      }
    T1IF = 0;

}
/*******************************************************************************
* @fn      t3_isr
*
* @brief   Interrupt handler for Timer 3 overflow interrupts. 
*
* @param   void
*
* @return  void
*
*******************************************************************************/

#pragma vector = T3_VECTOR
__interrupt void t3_isr(void)
{
    // Clears the module interrupt flag.
 
   T3OVFIF = 0;    

    
      //while is wqual to  1 is count
     if (count==1){
           countMeasure++;
   
     } else {
       countMeasure= (countMeasure); // multiply countMeasure to *65535;
         printf("tiks = %ld\n", countMeasure);
      //stop interrupts 
       T3IE = 0;
      //  EA = 0;
     //stop timer
     T3CTL=0X00;   
      }
    T3IF = 0;

}






 // in mi case use  when the time in t4 is expire  change count to zero
#pragma vector = T4_VECTOR
__interrupt void t4_isr(void)
{
    // Clears the module interrupt flag.
    T4OVFIF = 0;
     
      if (contador>=minutes) // minutes is variable to control the time stop the count
      {
        count=0;
       RED =!RED;
        BLUE  =!BLUE ;
         T4CTL=0X00;  
      } contador++;
    T4IF = 0;
   // 
}

when stop the timers i  print  the times overflows, in timer 1  print 500, and in timer 3  print = 44611

and to find the total tiks multiplied by bits

timer 1= 500 x65535 = 32767500 tiks

timer 3= 44611 x 255 = 11375805 tiks

but when mutupli the tiks total is very diferent, timer 1 is  near to frecuency the internal clock (32 Mhz )  AND TIMER 3 is It is much lower

i dont undertand because the totals tiks is diferents,