Index: /firmware/FTM/FTM_central_control.vhd
===================================================================
--- /firmware/FTM/FTM_central_control.vhd	(revision 10327)
+++ /firmware/FTM/FTM_central_control.vhd	(revision 10328)
@@ -66,12 +66,20 @@
 architecture Behavioral of FTM_central_control is
 
-  signal reset_scaler_sig  : std_logic := '0';
-  signal scaler_counts_sig : integer := 0;
-  signal scaler_period_sig : integer range 0 to 128 * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER) := 128 * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER);
+  signal reset_scaler_sig    : std_logic := '0';
+  signal reset_period_sig    : std_logic := '0';
+  signal scaler_counts_sig   : integer := 0;
+  signal scaler_period_sig   : integer range 0 to 128 * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER) := 128 * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER);
+  signal period_finished_sig : std_logic := '0';
+  signal wait_cnt_sig        : integer range 0 to 10 := 0;
+  signal new_period_sr_sig   : std_logic_vector(1 downto 0) := (others => '0');
+  signal new_period_sig      : std_logic := '0';
+  signal new_period_ack_sig  : std_logic := '0';
+  signal prescaling_FTU01_sig : std_logic_vector(7 downto 0) := "00100111";
   
   type state_central_proc_type is (CP_INIT,
                                    CP_CONFIG_START, CP_CONFIG, CP_CONFIG_01,
                                    CP_CONFIG_CC, CP_CONFIG_CC_01,
-                                   CP_CONFIG_FTU, CP_CONFIG_FTU_01, CP_CONFIG_SCALER,
+                                   CP_CONFIG_FTU, CP_CONFIG_FTU_01,
+                                   CP_CONFIG_SCALER, CP_CONFIG_SCALER_01,
                                    CP_IDLE, CP_PING, CP_READ_RATES, CP_READ_RATES_01,
                                    CP_SEND_START, CP_SEND_END);
@@ -89,5 +97,4 @@
           
         when CP_CONFIG_START =>
-          reset_scaler_sig <= '1';
           if (config_started_ack = '1') then
             config_started <= '0';
@@ -96,5 +103,4 @@
 
         when CP_CONFIG =>
-          reset_scaler_sig <= '1';
           config_start_eth <= '1';
           if (config_started_eth = '1') then
@@ -133,21 +139,27 @@
             state_central_proc <= CP_CONFIG_SCALER;
           end if;
-
+          
         when CP_CONFIG_SCALER =>
-          --if ((conv_integer(unsigned(prescaling_FTU01))) mod 2 = 0) then
-            --scaler_period_sig <= ((((conv_integer(unsigned(prescaling_FTU01)) / 2)) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER)) + (LOW_FREQUENCY / (2 * SCALER_FREQ_DIVIDER)));
-          --else
-            --scaler_period_sig <= (((conv_integer(unsigned(prescaling_FTU01)) - 1) / 2) + 1) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER);
-          --end if;
-          reset_scaler_sig <= '1';
-          state_central_proc <= CP_IDLE;
-          
+          prescaling_FTU01_sig <= prescaling_FTU01;
+          --reset_period_sig <= '1';
+          state_central_proc <= CP_CONFIG_SCALER_01;
+
+        when CP_CONFIG_SCALER_01 =>
+          --reset_period_sig <= '0';
+          if wait_cnt_sig < 5 then
+            wait_cnt_sig <= wait_cnt_sig + 1;
+            reset_scaler_sig <= '1';
+            state_central_proc <= CP_CONFIG_SCALER_01;
+          else
+            wait_cnt_sig <= 0;
+            reset_scaler_sig <= '0';
+            state_central_proc <= CP_IDLE;
+          end if;
+            
         when CP_IDLE =>
-          reset_scaler_sig <= '0';
           if (new_config = '1') then
             config_started <= '1';
             state_central_proc <= CP_CONFIG_START;
           elsif (ping_ftu_start = '1') then
-          --else
             ping_ftu_start_ftu <= '1';
             if (ping_ftu_started_ftu = '1') then
@@ -158,7 +170,8 @@
             end if;            
           --elsif (scaler_counts_sig = scaler_period_sig) then
-          --  reset_scaler_sig <= '1';
-          --  rates_ftu <= '1';
-          --  state_central_proc <= CP_READ_RATES;
+          elsif (new_period_sig = '1') then
+            new_period_ack_sig <= '1';
+            rates_ftu <= '1';
+            state_central_proc <= CP_READ_RATES;
           end if;
 
@@ -173,5 +186,5 @@
 
         when CP_READ_RATES =>
-          reset_scaler_sig <= '0';
+          new_period_ack_sig <= '0';
           if (rates_started_ftu = '1') then
             rates_ftu <= '0';
@@ -202,25 +215,51 @@
   scaler_process: process(reset_scaler_sig, clk_scaler)
   begin
-    if reset_scaler_sig = '1' then
+    if (reset_scaler_sig = '1') then
       scaler_counts_sig <= 0;
+      period_finished_sig <= '0';
     elsif rising_edge(clk_scaler) then
       if (scaler_counts_sig < scaler_period_sig) then
         scaler_counts_sig <= scaler_counts_sig + 1;
+        period_finished_sig <= '0';
       else
-        scaler_counts_sig <= scaler_counts_sig;
+        period_finished_sig <= '1';
+        scaler_counts_sig <= 0;
       end if;
     end if;
   end process scaler_process;
 
-  process(reset_scaler_sig, prescaling_FTU01)
-  begin
-    if rising_edge(reset_scaler_sig) then
-      if ((conv_integer(unsigned(prescaling_FTU01))) mod 2 = 0) then
-        scaler_period_sig <= ((((conv_integer(unsigned(prescaling_FTU01)) / 2)) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER)) + (LOW_FREQUENCY / (2 * SCALER_FREQ_DIVIDER)));
+--  process(reset_period_sig)
+--  begin
+--    if rising_edge(reset_period_sig) then
+--      if ((conv_integer(unsigned(prescaling_FTU01))) mod 2 = 0) then
+--        scaler_period_sig <= ((((conv_integer(unsigned(prescaling_FTU01)) / 2)) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER)) + (LOW_FREQUENCY / (2 * SCALER_FREQ_DIVIDER)));
+--      else
+--        scaler_period_sig <= (((conv_integer(unsigned(prescaling_FTU01)) - 1) / 2) + 1) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER);
+--      end if;
+--    end if;
+--  end process;
+
+  process(prescaling_FTU01_sig)
+  begin
+    if ((conv_integer(unsigned(prescaling_FTU01_sig))) mod 2 = 0) then
+      scaler_period_sig <= ((((conv_integer(unsigned(prescaling_FTU01_sig)) / 2)) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER)) + (LOW_FREQUENCY / (2 * SCALER_FREQ_DIVIDER)));
+    else
+      scaler_period_sig <= (((conv_integer(unsigned(prescaling_FTU01_sig)) - 1) / 2) + 1) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER);
+    end if;
+  end process;
+  
+  detect_period_finished: process(clk)
+  begin
+    if rising_edge(clk) then
+      new_period_sr_sig <= new_period_sr_sig(new_period_sr_sig'left - 1 downto 0) & period_finished_sig;
+      if(new_period_ack_sig = '1') then
+        new_period_sig <= '0';
       else
-        scaler_period_sig <= (((conv_integer(unsigned(prescaling_FTU01)) - 1) / 2) + 1) * (LOW_FREQUENCY / SCALER_FREQ_DIVIDER);
+        if (new_period_sr_sig(1 downto 0) = "01") then
+          new_period_sig <= '1';
+        end if;
       end if;
     end if;
-  end process;
-
+  end process detect_period_finished;
+  
 end Behavioral;
Index: /firmware/FTM/FTM_top_tb.vhd
===================================================================
--- /firmware/FTM/FTM_top_tb.vhd	(revision 10327)
+++ /firmware/FTM/FTM_top_tb.vhd	(revision 10328)
@@ -117,10 +117,10 @@
       -- Clock conditioner LMK03000
       -------------------------------------------------------------------------------
-      -- CLK_Clk_Cond  : out STD_LOGIC;  -- MICROWIRE interface serial clock
-      -- LE_Clk_Cond   : out STD_LOGIC;  -- MICROWIRE interface latch enable   
-      -- DATA_Clk_Cond : out STD_LOGIC;  -- MICROWIRE interface data
+      CLK_Clk_Cond  : out STD_LOGIC;  -- MICROWIRE interface serial clock
+      LE_Clk_Cond   : out STD_LOGIC;  -- MICROWIRE interface latch enable   
+      DATA_Clk_Cond : out STD_LOGIC;  -- MICROWIRE interface data
    
-      -- SYNC_Clk_Cond : out STD_LOGIC;  -- global clock synchronization
-      -- LD_Clk_Cond   : in STD_LOGIC;   -- lock detect, should be checked for                  
+      SYNC_Clk_Cond : out STD_LOGIC;  -- global clock synchronization
+      LD_Clk_Cond   : in STD_LOGIC;   -- lock detect, should be checked for                  
 
     
@@ -379,9 +379,9 @@
       LED_ye        => LED_ye_sig,
       LED_gn        => LED_gn_sig,
---      CLK_Clk_Cond  => CLK_Clk_Cond_sig,
---      LE_Clk_Cond   => LE_Clk_Cond_sig,
---      DATA_Clk_Cond => DATA_Clk_Cond_sig,
---      SYNC_Clk_Cond => SYNC_Clk_Cond_sig,
---      LD_Clk_Cond   => LD_Clk_Cond_sig,               
+      CLK_Clk_Cond  => CLK_Clk_Cond_sig,
+      LE_Clk_Cond   => LE_Clk_Cond_sig,
+      DATA_Clk_Cond => DATA_Clk_Cond_sig,
+      SYNC_Clk_Cond => SYNC_Clk_Cond_sig,
+      LD_Clk_Cond   => LD_Clk_Cond_sig,               
       Bus1_Tx_En    => Bus1_Tx_En_sig,                               
       Bus1_Rx_En    => Bus1_Rx_En_sig,
Index: /firmware/FTM/ftm_definitions.vhd
===================================================================
--- /firmware/FTM/ftm_definitions.vhd	(revision 10327)
+++ /firmware/FTM/ftm_definitions.vhd	(revision 10328)
@@ -86,5 +86,6 @@
   constant INT_CLK_FREQUENCY_2 : integer := 250000000;  -- 250MHz
   constant LOW_FREQUENCY       : integer :=   1000000;  -- has to be smaller than INT_CLK_FREQUENCY_1
-  constant SCALER_FREQ_DIVIDER : integer :=         1;  -- for simulation, should normally be 1
+  --constant SCALER_FREQ_DIVIDER : integer :=     10000;  -- for simulation, should normally be 1
+  constant SCALER_FREQ_DIVIDER : integer :=         1;
   
   --FTM address and firmware ID
@@ -95,6 +96,6 @@
   constant FTU_RS485_BAUD_RATE   : integer := 250000;  -- bits / sec in our case
   constant FTU_RS485_TIMEOUT     : integer := (INT_CLK_FREQUENCY_1 * 2) / 1000;  -- 2ms @ 50MHz (100000 clk periods)
-  -- constant FTU_RS485_BAUD_RATE   : integer := 10000000;  -- for simulation
-  -- constant FTU_RS485_TIMEOUT     : integer := (INT_CLK_FREQUENCY_1 * 2) / 40000;  -- for simulation
+  --constant FTU_RS485_BAUD_RATE   : integer := 10000000;  -- for simulation
+  --constant FTU_RS485_TIMEOUT     : integer := (INT_CLK_FREQUENCY_1 * 2) / 40000;  -- for simulation
   constant FTU_RS485_NO_OF_RETRY : integer range 0 to 2 := 2;  -- in case of timeout, !!! HAS TO BE < 3 !!!
   constant FTU_RS485_BLOCK_WIDTH : integer := 224;  -- 28 byte protocol
Index: /firmware/FTM/ftu_control/FTM_ftu_control.vhd
===================================================================
--- /firmware/FTM/ftu_control/FTM_ftu_control.vhd	(revision 10327)
+++ /firmware/FTM/ftu_control/FTM_ftu_control.vhd	(revision 10328)
@@ -916,4 +916,5 @@
                 FTM_ftu_rs485_control_State <= RATES;
               else
+                retry_cnt <= 0;
                 FTU_cnt <= FTU_cnt;  -- move on
                 FTM_ftu_rs485_control_State <= RATES;
