current based on said first voltage signals and said first current signals, determine an instantaneous maximum allowable regeneration current based on the measured voltage level and the prefixed parameter corresponding to a maximum absolute active current or regeneration by means of the following equation: iaIstAbs(t)=coV*IaMaxAbs, wherein c V is a weight coefficient that depends on the voltage Vdc(t) and a nominal DC-link voltage Vdcnom and on a highvoltage limit Vhigh; calculate a current value indicative of the difference between said active current and said maximum allowable regeneration current, performing a proportional-integral function on said current value to calculate said torque limit. Preferably said inverter-based apparatus further comprises comparator means which are configured to: receive in input the motor speed, receive in input said torque limit, receive a torque target which is indicative of a torque requested to said electric motor, compare said torque target with the said torque limit, set the torque reference with the torque limit when said motor speed is positive and said torque target is lower or equal to said torque limit. Preferably said comparator means are further configured to set the torque reference with the torque limit, when the motor speed is negative and the torque target is greater than, or equal to the torque limit. The present invention further relates to a method to control a laundry treating machine comprising: a casing, a laundry drum mounted inside said casing to rotate about a rotation axis, an electric motor designed to rotate said laundry drum about said rotation axis, an inverter-based apparatus, which is configured to control said electric motor and comprises: an input stage which is connected to mains lines for receiving AC lines currents and AC mains voltage and configured to convert said alternating mains voltage AC to a rectified DC voltage, an electrolytic capacitor-less inverter configured to generate output currents to be fed to said electric motor based on duty cycles of switching signals, a DC-link which connects said electrolytic capacitor-less inverter to said input stage and is crossed by DC-link currents from, or towards, said electrolytic capacitor-less inverter, a DC-link capacitor connected to said DC-link, a regulator system, which is configured to control the duty cycles of switching signals