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.

Can I use the cc2530 timer 4 in this way?

Other Parts Discussed in Thread: CC2530

Hi,everyone

Can I use the cc2530 timer 4 in this way?Below is my code.I want to use timer 4.For example , i want to delay 13us , but watching the pulse in the oscilloscope,

while(1){
     
    P0_6 ^=1; 
    Time4_wait(13);
   
    }

the time is not right .The actual time is about 22us.

 

void Time4_wait(uint16 t)
{
   static uint16 m,n,i;

          n = t%255;

          if(t >= 255){ 
             m = t/255;
             for(i=0;i<m;i++){

                T4CTL |= (1<<2);      //add by stones
                T4CC0 = 255;
                T4CTL |= 0x10;
                while((TIMIF & (1 << 3)) == 0)
                {}
                T4CTL &= ~0x10;
                T4CTL |= (1<<2); //counter clr
                TIMIF &= ~(1 << 3);
                      
            }
          }
            
           if(0!=n){ 
              
        T4CC0 = n;
               T4CTL |= (1<<2);      //counter clr
               TIMIF &= ~(1 << 3); //flag clr
        T4CTL |= 0x10; 
              
              
               while((TIMIF & (1 << 3)) == 0)
               {}
              
              
               T4CTL &= ~0x10; //suspend
               T4CTL |= (1<<2); //counter clr
               TIMIF &= ~(1 << 3); //flag clr
                         
            }

}