AnsweredAssumed Answered

Frequency Counter problem

Question asked by degreec on Feb 6, 2012
Latest reply on Feb 6, 2012 by MMA

Hi,

 

I am using Aduc814 in my project. I wants to measure the external signal frequency up to 62Khz.Currently i am using the external interupt (INT0) method and found  the 1 to 0 transition and starts the timer (16 bit). Calculate the frequency value by  TH1 & TL1 register.s. But its not working fine . It has lot of jumps. Kindly assist me which one is the best logic to measure the frequency?

 

(Using External crystal 32Khz.)

 

switch (Edge)

        {

            case FIRST_EDGE:

            {

                TH1=0x00;

                TL1=0x00;

                Tmr_overflow_cnt=0;

 

                ET1 =1;//timer

                TR1 =1;

 

                Edge = SECOND_EDGE;       

 

                break;

 

            }

 

            case SECOND_EDGE:

            {              

 

                TR1=0;

                Tmr_lowbyte = TL1;            // for frequency calculation

                Tmr_highbyte= TH1;   

 

                EX0 = 0;                          // disable INT1 Interrupt  

                IT0 = 1;                          // INT1 interrupt edge triggered

 

                TR1=0;

 

                TH1=0x00;

                TL1=0x00;

 

                Edge = 0;   

 

                Calc_freq_f =1; // flag to set calculate the frequency

 

                break;       

            }

          default:

          Edge = FIRST_EDGE;

          break;

Outcomes