If that's all your PIC is doing, and you don't mind doing it the easy way, then take a look at this.

http://www.pbpgroup.com/modules/wfse...p?articleid=12

That'll do exactly what you need, all in software. (You just won't have many cycles left over for other things).