On Mon, 9 Feb 2004 07:11, James Nick Sears wrote: > How are you connecting to your PIC. I would try using Timer1 with TMR1CS > set (Timer1 clocks on the rising edge of RC0) Then you can clear Timer1 > and it will count rising edges until it overflows or you clear it again. > Make sure your prescaler settings, etc. are appropriate. > Thanks Nick, and everyone else who replied to my earlier pulse counting question. Unfortunately, I couldn't get the RC filter idea to work and due, partly to storm damage, I had abandoned the project but have now decided to have another look at it again purely for programming practise (this is my first project, by the way). The way I understand timer1's use is that a rising edge on port C0 (16F876A) causes TMR1L to increment and overflow into TMR1H. So far that doesn't happen and I suspect that there is more to it than just setting a few bits in the T1CON register. This is my initialisation code: clrf PORTB ; Initialise Port B clrw ; Clear W register bsf STATUS,RP0 ; Select Register Bank 1 movwf TRISB ; Set port B to all outputs movlw b'00000001' movwf TRISA ; Port A0 input the rest outputs movlw b'00000011' movwf TRISC ; Port C0 & C1 inputs the rest outputs bsf T1CON,0 ; Enable timer1 bsf T1CON,1 ; External clock input from C0 bsf T1CON,2 ; Don't sync external clock input movlw 0x06 movwf ADCON1 ; Set port A to digital i/o bcf STATUS,RP0 ; select Register Bank 0 The remainder of the code reads TMR1L and TMR1H (I took this from the Microchip's docs) and then displays the result on a LCD display. The counter register is always 0 and the display code actually works. Is there more to it? Are there other registers that I have to deal with? I have searched for example code without success. -- Regards, Phil. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body