Or use a PIC who provide this with a special register setup. ECCP module comes much popular now.

PIC16F684 could be a smart choice.