I have an application that needs to output a Lo bit after the ADCIN (10bit) sees a full 1023 count for a continuous 30 minites.

I know what I have to do, but don't know exactly how to code it in PICBASIC Pro. Can anyone steer me in the right direction?

I'm using a PIC16F877A and a 4Mhz clock.

I will be keeping track of the TMR1IF with interrupts off (TMR1IE=0). With a 16 bit counter and 4Mhz clock, 4 the clk to instruction cycle divider, and 8 the maximum timer prescaler value, the maximum timer1 rollover time is (65536*4*8/4e106)= 524ms

If I keep track of the TMR1IF with a counter loaded to a value of rollovers equal to 30 min (in the above example that would be 30*60/.524 = 3435)

If the ADC routine sees a value of less than 1023 it loads the timeout of 3435.
Every time throught the program loop, TMR1IF flag is checked. If it is set it is cleared and the counter decremented. When the counter gets to 0 the Lo bit is output to an analog switch.