Hi All,

I'm at a loss as why this is only making one pass through, any ideas?
I'm sending it a long (~100uS) or short (~50uS) pulse on RB.0 (INT) and it will grab the timer value for the appropriate length pulse.
That part is doing fine. Problem is that it will only make one pass, and then nothing. By one pass, I mean it will INT and start the timer, and on the next INT, it will grab the timer value and report it both on the LCD and out serially. The REM'd code is my attempt to build a byte from the captured bits, but so far, I can't get past single captures.
Code:
<html>
<head></head>
<body><!--StartFragment--><pre><code><font color="#0000FF"><i>'****************************************************************
'*  Name    : PulseGrab.BAS                                     *
'*  Author  : boroko                                            *
'*  Notice  : Copyright (c) 2009 Controlled Surroundings Inc.   *
'*          : All Rights Reserved                               *
'*  Date    : 7/19/2009                                         *
'*  Version : 1.0                                               *
'*  Notes   : testing on a 16F877A @ 20mHz on Lab-X1            *
'*          : Does one capture and displays, but no more.                                            *
'*          : it DOES differentiate the pulse length
'****************************************************************
' Test bed to build pulse length receiver code. 
' Short or long pulse on RB.0  ~ 50uS and ~100uS for &quot;1&quot; and &quot;0&quot;
' Display on a LCD and Transmit to test.

</i></font><b>INCLUDE </b><font color="#FF0000">&quot;AllDigital.pbp&quot; 
</font><b>INCLUDE </b><font color="#FF0000">&quot;DT_INTS-14.bas&quot;     </font><font color="#0000FF"><i>' Base Interrupt System
</i></font><b>INCLUDE </b><font color="#FF0000">&quot;ReEnterPBP.bas&quot;     </font><font color="#0000FF"><i>' Include if using PBP interrupts
</i></font><b>DEFINE  </b>OSC 20
<b>DEFINE  </b>LCD_DREG        PORTD
<b>DEFINE  </b>LCD_DBIT        4
<b>DEFINE  </b>LCD_RSREG       PORTE
<b>DEFINE  </b>LCD_RSBIT       0
<b>DEFINE  </b>LCD_EREG        PORTE
<b>DEFINE  </b>LCD_EBIT        1
<b>DEFINE </b>HSER_RCSTA 90h       <font color="#0000FF"><i>' enable serial port, %10010000
</i></font><b>DEFINE </b>HSER_TXSTA 24h       <font color="#0000FF"><i>' enable transmit,  BRGH hi, %00100100 
</i></font><b>DEFINE </b>HSER_BAUD 19200       <font color="#0000FF"><i>' set baudrate to 19200                   
</i></font><b>DEFINE </b>HSER_CLOERR  1       <font color="#0000FF"><i>' automatic clear overrun error
</i></font>T1CON   =   %00001000        <font color="#0000FF"><i>'TMR1 1:1 PS, Osc En, Int Clk, off to start
            ' returning 259 for short and 767 for long pulse @ 1:1
</i></font>Time       <b>VAR   WORD         
</b>CntState   <b>VAR   BIT


LCDOUT </b>$fe, 1                 <font color="#0000FF"><i>'blank flash to see if LCD updated
</i></font><b>PAUSE </b>100
<b>LCDOUT </b>$fe, 1, <font color="#FF0000">&quot;PulseGrab SubTest&quot;
</font><b>HSEROUT </b>[<font color="#FF0000">&quot;PulseGrab SubTest&quot;</font>,13]
<b>PAUSE </b>500
<b>LCDOUT </b>$FE,1
<font color="#0000FF"><i>'*********************************************************
</i></font><b>ASM
</b><font color="#008000">INT_LIST  macro   </font><font color="#0000FF"><i>; IntSource,        Label,  Type, ResetFlag?
        </i></font><font color="#008000">INT_Handler    INT_INT,    _pulse,   PBP,  no
    endm
    INT_CREATE               </font><font color="#0000FF"><i>; Creates the interrupt processor

    </i></font><font color="#008000">INT_ENABLE   INT_INT     </font><font color="#0000FF"><i>; enable external (INT) interrupts
</i></font><b>ENDASM   
</b><font color="#0000FF"><i>'*****************************************************************
</i></font>Main:
     <b>PAUSE </b>10
<font color="#0000FF"><i>'     if (Time &gt;230)&amp;&amp;(time &lt; 280) then    ' short pulse (1) received
'       PulseIn = 1                      ' maybe change window to improve
'       gosub CharBuild                  ' save the character
'       endif
'    if (Time &gt;750)&amp;&amp;(time &lt; 800) then   ' long pulse (0) received
'       PulseIn = 0                      ' maybe change window to improve
'       gosub CharBuild                  ' save the character
'       endif
'     else 
'       PulseIn = 8                         ' If nothing else, then no data
            ' ADD counter HERE to allow for a small gap before dumping
'       charcnt = 0                         ' Dump the counter and
'       char = 0                            '  dump the character received  
'     endif
</i></font><b>GOTO </b>Main
<font color="#0000FF"><i>''***************************************************************
' INT Handler
'****** Pulse capture using External Interrupt courtesy of DT *****************
</i></font>pulse:
    <b>IF </b>INTCON.1=1 <b>THEN         </b><font color="#0000FF"><i>' External Interrupt happened
        </i></font><b>IF </b>CntState=0 <b>THEN     </b><font color="#0000FF"><i>' 
            </i></font>T1CON.0=1          <font color="#0000FF"><i>' Enable Timer 
            </i></font>OPTION_REG.6 = 0   <font color="#0000FF"><i>' Next trigger is Falling edge
            </i></font>INTCON.1=0         <font color="#0000FF"><i>' Reset ExtInt Flag 
            </i></font>CntState =1

        <b>ELSE
            </b>Time.LowByte = TMR1L   <font color="#0000FF"><i>' Store the captured value in period variable
            </i></font>Time.HighByte = TMR1H            
            T1CON.0=0           <font color="#0000FF"><i>' Timer is OFF 
            </i></font>INTCON.4=0          <font color="#0000FF"><i>' ExtInt is OFF 
            </i></font>TMR1L=0             <font color="#0000FF"><i>' Reset Timer 
            </i></font>TMR1H=0             <font color="#0000FF"><i>' Remember Timer is OFF 
            </i></font>INTCON.1=0          <font color="#0000FF"><i>' Reset ExtInt Flag 
            </i></font>OPTION_REG.6 = 1    <font color="#0000FF"><i>' Next trigger is Rising edge
            </i></font>CntState=0
            <b>LCDOUT </b>$fe, 1, <font color="#FF0000">&quot;Int&quot;              </font><font color="#0000FF"><i>' Show that we had an Interrupt 
            </i></font><b>LCDOUT </b>$fe,$c0,<font color="#FF0000">&quot;time &quot;</font>,#Time      
            <b>HSEROUT </b>[<font color="#FF0000">&quot;Int&quot;</font>,13,10]
            <b>HSEROUT </b>[#Time,13]
        <b>ENDIF
    ENDIF
</b><font color="#008000">@ INT_RETURN
</font><font color="#0000FF"><i>'***************************************************************
'                    Subs
'******************************************************************
'CharBuild: 
'      char.0 = PulseIn                      ' Put the pulse value in bit 0 
'      Char = Char &lt;&lt;1                       ' rotate RX bit into byte
'         CharCnt = CharCnt+1                 ' increment counter to track fill
'      if CharCnt = 7 then                    ' RX byte is filled
'         RXbyte = Char                       ' valid Comm byte received
'         Lcdout $fe, 1, &quot;RXbyte= &quot;,RXbyte    ' Show what we got
'         hserout [&quot;RXbyte= &quot;,#RXbyte,13,10]  ' transmit what we got
'      endif
'return 
      
'ACprog:                                      ' look for lost power programming             
'         Lcdout $fe, 1, &quot;AC in&quot;              ' Show that we dropped into &quot;AC&quot;
'         hserout [&quot;AC in&quot;,13,10]
'         ' add test to gather data
'return
</i></font><b>END
</b></code></pre><!--EndFragment--></body>
</html>
To give proper credit, this is based on one of Darrel's suggestions in another thread concerning pulse timing.

Any suggestions?
Thanks
Bo