Can i count square wave?
First you will have to decide what you want to count: The number of pulses, the pulse width or the pulse frequency. For number or frequency you just need one or two counters (one to gate the time measure frequency).
For pulse width you will need to count a clock with known frequency while thi input is high.
if use counter to count the number of pulses,how to get the number of pulse.
Read the counter with an API. Read datasheets for counters.