A method of charging a lithium-ion battery. It is assumed that the battery has a cooling system. A desired temperature profile for the battery during charging is determined. The charge current is pulse width modulated (PWM), as is the activation of the cooling system. During charging, various parameters of either or both of the PWM signals are adjusted such that the desired temperature profile is maintained.