A switching power circuit having a counter which periodically counts a
value between a first value and a second value, a determining unit which
continuously determines a third value between the first value and the
second value, based on a voltage difference between an output voltage and
a reference voltage, a driving unit which alternately switches a first
switching element and a second switching element, base on a small and
large relation between a counting value of the counter and the third
value, and a control unit which resets the counting value of the counter
to the first value, based on the voltage difference or a current value at
the second switching element.