From 79cae3dd667cef8c0504164c4bda07297184bc79 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Mon, 21 Nov 2022 22:08:25 -0500 Subject: [PATCH] (somewhat) fix counter --- firmware/rtl/control_loop/control_loop.v | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/rtl/control_loop/control_loop.v b/firmware/rtl/control_loop/control_loop.v index a6d23c0..45d3a85 100644 --- a/firmware/rtl/control_loop/control_loop.v +++ b/firmware/rtl/control_loop/control_loop.v @@ -229,7 +229,7 @@ always @ (posedge clk) begin if (state == CYCLE_START && timer == 0) begin counting_timer <= 1; last_timer <= counting_timer; - end else begin + end else if (running) begin counting_timer <= counting_timer + 1; end end @@ -353,6 +353,7 @@ always @ (posedge clk) begin state <= CYCLE_START; dac_ss <= 0; dac_arm <= 0; + timer <= 0; stored_dac_val <= from_dac[DAC_DATA_WID-1:0]; end end