You just need to set up timer 0 to use the external clock and select the active edge (risig or falling). That means bit T0CS in the OPTION register must be set to 1 and bit T0SE of the same register will be set or clear dpending on what edge you need.
Generally you would not use a prescaler when you use the timer as a counter. So make sure bit PSA in the OPTION register is set to 1.
So it all boils down to writing the appropriate value to the OPTION register in order to use TMR0 as a counter.
Once you have done that, you can just read the TMR0 register in the normal fashion, using the movf TMR0,W instruction to see how many counts have accumulated. That's all there is to it.
For example, let's assume that you would not have the pullups enabled, you use a rising edge interrupt (or you don't care), you need rising edge on TMR0 input and the prescaler will be assigned to the WDT with a rate of 1:64. This is what you would do:
Code:
movlw B'11101110' ; no pullups on RB, ext interrupt on rising edge, TMR0 uses ext clock, increments on rising edge,
; WDT prescaler 1:64
movwf OPTION_REG ;set up option register with the above; TMR0 counts ext pulses
.
.
.
movf TMR0,W ;read TMR0 contents and use
.
.
.
thank you sir...can you give some idea about comparator..and other modules in pic 16f877a...i am newer sir..if you can,you can send answer to my selvabala.ece@gmail.com...thank you sir