Measure of Duty Cicle of a PWM signal

Rolaro:
Yes, thanks, with that i can detect the change of flank, the problem is that micros() function can be too slow to read the duty cicle with high accuracy.

If micros() is to slow for the resolution your looking for then you need to move to a faster MCU or some external hardware to do the timing. IIRC the AVR micro() function updates in steps of 4 so your getting errors to begin with without the code overhead.