新手,有一段马达运行的程序,现在需要控制马达运行2分钟以后,自动停止,请高手们帮帮忙,谢谢!
always@(posedge clk or negedge reset)
if(!reset)
begin
PWM_clear_ctrl <= 32'd0;
end
else if(start_clear_control)
begin
if(PWM_clear_ctrl == 218000) //110Hz //调周期 //24MHz
PWM_clear_ctrl <= 32'd0;
else
PWM_clear_ctrl <= PWM_clear_ctrl + 1'b1;
end else
always@(posedge clk or negedge reset)
if(!reset)
begin
clear_ctrl <= 1'b0;
end
else if(start_clear_control)
begin
if(PWM_clear_ctrl < 21800 ) // 调占空比 10900
clear_ctrl <= 1'b1;
else
clear_ctrl <= 1'b0;
end else
clear_ctrl <= 1'b0; |