Patent ID: 8711578

Claim:
A power supply controller comprising: a switching control circuit configured to form a switching control signal to control a power switch to regulate an output current through a transformer to a desired value, the switching control signal having a period, the transformer including a secondary winding to conduct a secondary current, the transformer also including an auxiliary winding to form an auxiliary voltage, and the transformer further including a parasitic leakage inductance; a demag detect circuit configured to receive a signal representative of the auxiliary voltage and form a zero detect signal representative of a demagnetization time of the transformer; a leakage detect circuit configured to form a leakage reset signal responsively to completion of a discharge time of the parasitic leakage inductance; a compensation circuit configured to receive the leakage reset signal and the zero detect signal and form a compensation control signal that is representative of a difference between the demagnetization time and the discharge time of the parasitic leakage inductance; and a reference generation circuit configured to use the compensation control signal to form a current reference signal having a value that varies responsively to the compensation control signal wherein the switching control circuit adjusts an ON-time of the power switch responsively to changes of the current reference signal.