A switching power supply with protection function includes a transistor
controlled to be on or off by a PWM signal from a PWM controller to
convert a DC voltage into a square wave signal, a filter filtering the
square wave signal into an output voltage signal, the output voltage
signal being fed back to the PWM controller to be compared with a
predetermined voltage, and a switch device having an input terminal for
receiving the output voltage signal from the filter, an output terminal
for connecting to a load, and a control terminal. If the voltage of the
output voltage signal from the filter is not equal to the predetermined
output voltage, the PWM controller will not output a signal to the
control terminal of the switch device and the switch device will be in an
off state. The PWM controller adjusts the duty ratio of the PWM signal
until the voltage of the output voltage signal from the filter is equal
to the predetermined output voltage such that the PWM controller outputs
a control signal to turn on the switch device to allow the load receiving
the output voltage signal via the switch device.