This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timer2 in Capture Mode

I tried to use Timer2 in Capture Mode, I have to measure frequency from 8 to 10 KHz. I used the following code but no way to work.
To set Timer2
T2CON=9;
T2MOD=0;
TL2=0;
TH2=0;
RCAP2L=0;
RCAP2H=0;
TR2=1;

in the main loop

while(!EXF2);

now i suppose to fine value in RCAP2L e RCAP2H but nothing.
Frequency to measure arrives to P1.1 (T2EX).
Is it correct?
Thank you very much

Raffaele

  • Hi,Raff
    I have just finished my frequency counter which can measure 20Hz~30MHz with timer2 working in capture mode,it works well.I just finished the first version:

    	T2CON = 0x0d;
          TH2   = 0;
          TL2   = 0;
          EXF2  = 0;
          TF2   = 0;
          EA    = 1;
          TR2   = 1;
    
    Maybe you forgot to set EA!
    Good luck!