Index: trunk/FACT++/src/ftmctrl.cc
===================================================================
--- trunk/FACT++/src/ftmctrl.cc	(revision 11101)
+++ trunk/FACT++/src/ftmctrl.cc	(revision 11102)
@@ -898,4 +898,19 @@
     }
 
+    bool SetClockRegister(const uint64_t reg[])
+    {
+        for (int i=0; i<8; i++)
+        {
+            if (reg[i]>0xffffffff)
+                return false;
+
+            fStaticData.fClockConditioner[i] = reg[i];
+        }
+
+        CmdSendStatDat();
+
+        return true;
+    }
+
     bool EnablePixel(int16_t idx, bool enable)
     {
@@ -1390,4 +1405,61 @@
     }
 
+    int SetClockRegister(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "SetClockRegister", 8*16))
+            return T::kSM_FatalError;
+
+        const uint64_t *reg = evt.Ptr<uint64_t>();
+
+        if (!fFTM.SetClockRegister(reg))
+            T::Warn("SetClockRegister - Value out of range.");
+
+        return T::GetCurrentState();
+    }
+
+    //map<uint32_t, uint32_t> fClockConditionerMap;
+
+    int SetClockFrequency(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "SetClockFrequency", 4))
+            return T::kSM_FatalError;
+
+        const uint32_t freq = evt.GetUInt();
+
+        //map<uint32_t,uint32_t>::const_iterator = fClockConditionerMap.find(freq);
+
+        static const uint64_t R1  = 0x00010101;
+        static const uint64_t R8  = 0x10000908;
+        static const uint64_t R9  = 0xa0032a09;
+        static const uint64_t R11 = 0x0082000b;
+        static const uint64_t R13 = 0x020a000d;
+
+        static const uint64_t freq0700[8] = { 0x0003e000, R1, R8, R9, R11, R13, 0x0830400e, 0x1400f50f };
+        static const uint64_t freq1000[8] = { 0x0003a000, R1, R8, R9, R11, R13, 0x0830400e, 0x1400fa0f };
+        static const uint64_t freq2000[8] = { 0x00035000, R1, R8, R9, R11, R13, 0x0830400e, 0x1400fa0f };
+        static const uint64_t freq3000[8] = { 0x00037200, R1, R8, R9, R11, R13, 0x0830400e, 0x1420a30f };
+        static const uint64_t freq4000[8] = { 0x00032800, R1, R8, R9, R11, R13, 0x0830400e, 0x1400fa0f };
+        static const uint64_t freq5000[8] = { 0x00032000, R1, R8, R9, R11, R13, 0x0830400e, 0x1400fa0f };
+
+        const uint64_t *reg = 0;
+
+        switch (freq)
+        {
+        case  700: reg = freq0700; break;
+        case 1000: reg = freq1000; break;
+        case 2000: reg = freq2000; break;
+        case 3000: reg = freq3000; break;
+        case 4000: reg = freq4000; break;
+        case 5000: reg = freq5000; break;
+        default:
+            T::Warn("SetClockFrequency - Frequency not supported.");
+            return T::GetCurrentState();
+        }
+
+        if (!fFTM.SetClockRegister(reg))
+            T::Warn("SetClockFrequency - Register values out of range.");
+
+        return T::GetCurrentState();
+    }
 
     int Enable(const EventImp &evt, FTM::StaticData::GeneralSettings type)
@@ -1694,4 +1766,14 @@
             (boost::bind(&StateMachineFTM::SetCalibWindow, this, _1))
             ("");
+
+        AddEvent("SET_CLOCK_FREQUENCY", "I:1", kStateIdle)
+            (boost::bind(&StateMachineFTM::SetClockFrequency, this, _1))
+            ("");
+
+        AddEvent("SET_CLOCK_REGISTER", "X:8", kStateIdle)
+            (boost::bind(&StateMachineFTM::SetClockRegister, this, _1))
+            ("");
+
+
 
         AddEvent("RESET_CRATE", "S:1", kStateIdle)
