I would think, you need a timer to keep count of the seconds. Any timer would do fine as long as you know how to extend it, in code, to count 1 second. This timer can then be further extended to count the 30 seconds interval you want.

Similarly, the pulses could come into the INT pin on your device and you could count the interrupt when it occurs.

Just ideas you could evaluate