IRQ5 for reading frequency input

I would like to have an example about how to use this IRQ . I have a frequency variable signal entering in port P56.

I would like to retrieve the period of such signal.

I tried to use a counter but I always fail. 

Can you provide an example of working code.

 

Thanks