Hi. Thanks for your code...
What about using this code (your code with a little changes) to measure the time that the signal stays high, because I think that with your code I have the problem that I could find the signal in an high level and didnīt count the correct time!
Take a look...
code:
' Program to measure time on two pins in a 1uSec increment
' Using PIC16F874 with TIMER1
TRISA=255 ' Set PORTA as INPUT
ADCON1 = 7 ' disable analog to digital converter
T1CON = 0 ' set timer clock source to internal (fosc/4)
Signal1TIME var word
Signal2TIME var word
Signal1 var PORTA.1
Signal2 var PORTA.2
Start:
I will measure the time staying high, but only in the second period
because I have a little chances that when I go to next pin find 'the pin in middle of a high level and I didnīt count the correct time
' measure time that RA.1 stays high
TMR1L=0
TMR1H=0
while signal1=0 ' waiting for rising edge
wend
While signal1 ' wait for falling edge
wend
while signal1 = 0 ' wait for the next rising edge
wend
T1CON.0 = 1 ' start Timer1
While signal1 ' wait for falling edge
Wend
T1CON = 0 ' stopTimer
signal1time.lowbyte = TMR1L
Signal1time.highbyte = TMR1H
' measure time that RA.2 stays high
TMR1L=0
TMR1H=0
while signal2=0 ' waiting for rising edge
wend
While signal2 ' wait for falling edge
wend
while signal2 = 0 ' wait for the next rising edge
wend
T1CON.0 = 1 ' start Timer1
While signal2 ' wait for falling edge
Wend
T1CON = 0 ' stopTimer
while signal2 = 0 ' wait for the next rising edge
wend
signal2time.lowbyte = TMR1L
Signal2time.highbyte = TMR1H
lcdout $fe,1 ,"RA1 : ",#signal1TIME," uSec",_
$fe,$c0,"RA2 : ",#signal2TIME," uSec"
pause 2000
goto start
Bookmarks