Method for controlling a heat engine comprising intake valves able to be moved by a first camshaft , exhaust valves able to be moved by a second cam , a first phase shifter , called intake, and a second phase shifter , called exhaust, in order to be able to modify a respective relative position of the first camshaft and of the second camshaft with respect to a crankshaft of the heat engine , the said method comprising: - a step of operating the thermal engine in a nominal mode (M_nom) according to which crossing between the intake valves and the exhaust valves is prohibited or limited, via a control of the phase shifter intake and/or exhaust phase shifter , - a step of detecting conditions for activating a dynamic mode (M_dyn) linked to a degree of depression of an accelerator and to a torque condition (Cond_coup) of the heat engine , - and when the thermodynamic conditions of the heat engine are stabilized, said thermodynamic conditions of the heat engine corresponding to the temperature and the pressure in the intake and exhaust lines, said method comprises a step of activation of said dynamic mode (M_dyn) according to which crossing is authorized between the intake valves and the exhaust valves via a control of the intake phase shifter and/or of the exhaust phase shifter , the method being such that the torque condition (Cond_coup) is fulfilled when the torque of the heat engine enters a zone comprised between a torque from which a scavenging phenomenon is likely to appear and a torque torque (Cmax) of the heat engine , the torque condition (Cond_coup) being fulfilled when a difference between the maximum torque (Cmax) of the heat engine and the torque of the engine is less than or equal to a calibrated difference (Ecal) between a maximum torque (Cmax) of the heat engine and a torque from which a sweeping phenomenon of between 20 N.m to 40 N.m is likely to appear. - a step of operating the thermal engine in a nominal mode (M_nom) according to which crossing between the intake valves and the exhaust valves is prohibited or limited, via a control of the phase shifter intake and/or exhaust phase shifter , - a step of detecting conditions for activating a dynamic mode (M_dyn) linked to a degree of depression of an accelerator and to a torque condition (Cond_coup) of the heat engine , - and when the thermodynamic conditions of the heat engine are stabilized, said thermodynamic conditions of the heat engine corresponding to the temperature and the pressure in the intake and exhaust lines, said method comprises a step of activation of said dynamic mode (M_dyn) according to which crossing is authorized between the intake valves and the exhaust valves via a control of the intake phase shifter and/or of the exhaust phase shifter , the method being such that the torque condition (Cond_coup) is fulfilled when the torque of the heat engine enters a zone comprised between a torque from which a scavenging phenomenon is likely to appear and a torque torque (Cmax) of the heat engine , the torque condition (Cond_coup) being fulfilled when a difference between the maximum torque (Cmax) of the heat engine and the torque of the engine is less than or equal to a calibrated difference (Ecal) between a maximum torque (Cmax) of the heat engine and a torque from which a sweeping phenomenon of between 20 N.m to 40 N.m is likely to appear. <EOS>