Our app note for the day:
The Battery Charger Application Library easily allows
adding battery charging functionality to portable
applications. Since it is very compact (uses less than
2k words of program space and less than 128 bytes of
RAM) it fits on small, cost-effective parts like the 14-pin
PIC16F616. The library is available in a zip file.