Rewrite of the question
The circuit shown does not function correctly. The relay remains energized. Without Q5 RA4 behaves under influence of the code as wanted (open drain as mentioned in the specsheet table 5-1).
With Q5 is in place RA4 remains at 0,01 V all the time.
For a test Q5 was removed and replaced with a LED in on Q5be. Here a strange behaviour was detected. At the expected moment the LED lights up for a moment (pulse) but does not stay on.
After placing an emmiter follower in between to isolate RA4 the LED started to behave as expected.
In code RA4 is controlled with:
During init MOVLW B'00100000' ; Port RA5 input, others outputs MOVWF TRISA During run BSF PORTA,OUTPUT ;* Set OUTPUT RA4 (Counting not in Progress) BCF PORTA,OUTPUT ;* Clear OUTPUT RA4 (Counting in progress)
It all ends in one single question:
Why does RA4 stay low at 0.01V,consequently keep the relay energized, when Q5 is in place instead of going up to 0,65V under influence of the instructions in the code.