FvM is quite correct - this is a very confused thread.
First - you are using the words "polling" and "interrupts" -you will want to do one or the other.
Second - you have not defined exactly what you want to test for - there are comments here for 50% duty cycle 50 hz signal interspersed with PWM
and the topic also suggest you just want to know if its on or off but is that really all?
I would suggest you define what you need along the lines below then you might find help is clearer for us to offer:
1. If you have a signal that is either on or off but just happens to be 50hz and you want to know if its on or off - that is very easy to do with a simple pin/port change interrupt
2. If you want to actually verify that an input PWM signal is currently 50% 50Hz then thats a good deal more complicated and you need detailed specific help judging from responses here
3. If you want to just verify an incoming fixed 50Hz signal is actually a 50hz square wave at a particular moment thats a little easier than 2 and trickier than 1 but still you need to say
4. something else entirely - explain exactly
If you can define your problems better this will always help others to help you.
jack
- - - Updated - - -
OK having spotted your explanation on the mikroe web site I know understand better what you are trying to do.
You are using a TSOP1838 and trying to determine whether an IR beam has been broken or not.
You have 2 of these hence you cannot work out how to work with 2 pins at once.
Firstly forget all about 50Hz frequencies. The TSOP1838 demodulates the signal for you - see data sheet with example circuit here
https://uk.farnell.com/vishay/tsop4...8&whydiditmatch=rel_2&matchedProduct=TSOP1838
Second - you are indeed confused about interrupts and polling - something I think I warned about as starting to happen elsewhere
You are not polling - you are using interrupts - attempting to "poll an interrupt at 50hz" is a fun idea but as you can see - confusing.
Your solution is to drop the external AND gate - you dont need it.
Stop using timers - you dont need them.
Then perform a simple interrupt on change on 2 pins.
from the pic16F628A datasheet :
Four of PORTB’s pins, RB<7:4>, have an interrupt-onchange
feature. Only pins configured as inputs can
cause this interrupt to occur.
You configure the port as an input set for interrupt on change and connect your 2 input lines.
You write your interrupt() to dissable interrupts
test which line interrupted and process accordingly
then re-enable interrupts
There are many examples of how to do this with mikroe-c floating about. Its a fairly standard process.
Your IR detecter will simply change its logic state when the beam is broken - the pick will notice the change and interrupt for you.
Try to understand the difference between polling and interupts.
Hope that helps
jack
PS. Incidently I'm not convinced the device you are using is what I would choose for this application - I dont have time to read closer but it may operate only in burst mode - thereby
possibly giving you false triggers. Check this.