This application note from the microchip site will help you get started

http://ww1.microchip.com/downloads/e...tes/00594B.PDF

and you must apply those notes with respect to the device you are using by referencing the specific datasheet.

have fun




...