diff --git a/libraries/dsp/st/src/vhdl/st_histogram.vhd b/libraries/dsp/st/src/vhdl/st_histogram.vhd
index 2d32186cb7e0452ca7a0b151030fe87224c44a6f..9e1f1331f192c13a6d7abc79a6992175ecd68753 100644
--- a/libraries/dsp/st/src/vhdl/st_histogram.vhd
+++ b/libraries/dsp/st/src/vhdl/st_histogram.vhd
@@ -455,7 +455,7 @@ BEGIN
   -- Clear the RAM just before the next sync interval
   -------------------------------------------------------------------------------
   -- Count input data for automatic RAM clear before next sync interval
-  nxt_data_cnt <= (OTHERS=>'0') WHEN TO_UINT(data_cnt)=g_nof_data_per_sync-1 ELSE INCR_UVEC(data_cnt, 1) WHEN snk_in.valid='1' ELSE data_cnt;
+  nxt_data_cnt <= (OTHERS=>'0') WHEN snk_in.sync='1' ELSE INCR_UVEC(data_cnt, 1) WHEN snk_in.valid='1' ELSE data_cnt;
 
   -- Clear all g_nof_bins RAM addresses just before the next sync
   ram_clear <= '1' WHEN TO_UINT(data_cnt)=g_nof_data_per_sync-g_nof_bins-1 ELSE '0';