Life cycle tester: I need to hold a pin (Relay1) high for about 10 seconds while I am doing other things with other pins. I want to drive a relay and that runs a Pic outputting a square wave at 20 Hz for 200 pulses. I want to count the pulses using TMR0. Then I need Relay1 to go low for about 3 seconds .

I have 2 problems right now:

1) Relay1 pin goes high for a blip then low so I need to get some kind of timing loop going for the relay cycle. But how do i keep other things going on with other pins at the same time?

2) my test cycle counter goes to 255 and resets and I want it to go to 9999 cycles before going back to 0 and so does my pulse counter.

Any help or push in the right direction would be great


Code:
Init:
           INTCON.7 = 0             'Disable interrupts
           OPTION_REG = %00111000 
           TRISB = %01100111        'Setup Port B
           PORTB = %00000000        'Clear port B pins
           T_cyc Var Byte    
           T_cyc = 0
           PAUSE 1000               'Pause for the LCD to wake
           
Relay:               
           T_cyc = T_cyc + 1        'Test cycle counter
           Relay1 var PORTB.5
           High Relay1              'Drive relay pin 26 high for 13 seconds
           Goto Main           

Main:      
           MP_Count var PORTB.6     ' Holds count value
           MP_Count = 0             ' Clear pulse counter
           TMR0 = 0                 ' Clear TMR0 counter
           MP_Count = TMR0          ' Get TMR0 count
           
           LCDout $fe, 1, "Test # ",dec4 T_cyc 'Test cycle (0-9999 tests)
           LCDout $fe,$c0, DEC5 MP_Count, " Pulses" 
           
           Low Relay1
           PAUSE 4000
           GOTO Relay                  
      
End
Using a Pic 16F870