Atmel has a great app note for a battery charger reference design that they sell. I considered using an AVR uC before finally settling on the BQ2031. If you read through the whole thing cover to cover you will learn a ton about what you are trying to put together.