A switching mode power supply is configured to have two modes, a normal
mode and a measure mode. To determine a compensation factor to compensate
the switching mode power supply in the normal mode, the switching mode
power supply is switched to the measure mode to measure a frequency
response of the switching mode power supply, by which the switching mode
power supply is accurately compensated and optimized.