Entering 'libHALWrapper'
Entering 'libarena'
Entering 'libbiwak'
diff --git a/include/biwak/flash.h b/include/biwak/flash.h
index 8a4a77b..43c2afc 100644
--- a/include/biwak/flash.h
+++ b/include/biwak/flash.h
@@ -47,7 +47,14 @@ class CFlash
       int m_writePageSize=1;
 
    public:
-      CFlash( address_t address, int size );
+      constexpr CFlash( address_t address, int size )
+         :m_startAddress( address )
+         ,m_userAddress( m_startAddress )
+         ,m_size( size )
+      {
+
+      }
+
       ~CFlash();
 
       uint32_t acquireMemory(int size);
diff --git a/include/biwak/flash_intern.h b/include/biwak/flash_intern.h
index 891713f..5c165b4 100644
--- a/include/biwak/flash_intern.h
+++ b/include/biwak/flash_intern.h
@@ -20,8 +20,9 @@
 
 //---Own------------------------------
 
-#include <lepto/lepto.h>      // address_t
-#include <biwak/flash.h>      // address_t
+#include <lepto/lepto.h>         // address_t
+#include <biwak/flash.h>         // address_t
+#include <biwak/linker_script.h>
 #if defined( STM32 )
     #include <HALWrapper/stm32_flash.h>  // FLASH_PAGE_SIZE
 #else
@@ -36,17 +37,23 @@
 //---Defines------------------------------------------------------------------
 
 
+#define _override override
+extern char _start_user_flash;
+
 
 //---Declaration--------------------------------------------------------------
 
 
 class CFlashIntern
+      #if 1
          :public CFlash
+      #endif
 {
 
    private:
 
    public:
+      //constexpr
       CFlashIntern( );
       void init();
       ~CFlashIntern();
@@ -66,7 +73,7 @@ class CFlashIntern
          #endif
       }
 #endif
-      virtual int writeData(address_t address, const void *data, int size) override final;
+      virtual int writeData(address_t address, const void *data, int size) _override final;
       //#if defined IS_ENABLED( CONFIG_BIWAK_FLASH_32BIT_COMMANDS )
       
       #if defined FLASH_TYPEPROGRAM_WORD
@@ -75,8 +82,8 @@ class CFlashIntern
          virtual int writeData64(address_t address, const void *data, int size);
       #endif
       
-      virtual int readData(address_t address, void *data, int size) override final;
-      virtual int erasePage(address_t pageAddr, int count=1) override final;
+      virtual int readData(address_t address, void *data, int size) _override final;
+      virtual int erasePage(address_t pageAddr, int count=1) _override final;
 
       void clearPER() const;
       address_t flashStart() const;
@@ -85,8 +92,15 @@ class CFlashIntern
       void eraseUserFlash();
       address_t addressToPage( address_t address ) const;
 
-      address_t userStart() const;
-      int userSize() const;
+      constexpr address_t userStart() const
+      {
+         return( (address_t )&_start_user_flash );
+      }
+      constexpr int userSize() const
+      {
+         return( ( (address_t)FLASH_BASE + (address_t)(void *)&__flash_size )
+                 - (address_t)userStart() );
+      }
 };
 
 
diff --git a/src/flash.cpp b/src/flash.cpp
index 40a20c2..17ec7e7 100644
--- a/src/flash.cpp
+++ b/src/flash.cpp
@@ -27,11 +27,7 @@
 extern char _start_user_flash;
 
 
-CFlash::CFlash( address_t address, int size )
-   :m_size( size )
-{
-   m_userAddress = m_startAddress = address;
-}
+//constexpr CFlash::CFlash( address_t address, int size )
 
 
 CFlash::~CFlash()
diff --git a/src/stm32/biwak.cpp b/src/stm32/biwak.cpp
index f3e6612..85515bb 100644
--- a/src/stm32/biwak.cpp
+++ b/src/stm32/biwak.cpp
@@ -48,6 +48,38 @@ extern "C" {
    void SystemClock_Config( );
 }
 
+extern "C" {
+   uint32_t BIWAK_RCC_GetSysClockFreq();
+   HAL_StatusTypeDef BIWAK_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct);
+
+   uint32_t HAL_RCC_GetSysClockFreq();
+   HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct);
+}
+
+uint32_t BIWAK_RCC_GetSysClockFreq()
+{
+   return(48000000);
+}
+
+HAL_StatusTypeDef BIWAK_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct)
+{
+   return HAL_OK;
+}
+
+#if 0
+
+HAL_StatusTypeDef XYZ_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct)
+{
+   return HAL_OK;
+}
+
+uint32_t BIWAK_RCC_GetSysClockFreq()
+{
+   return(48000000);
+}
+
+#endif
+
 void biwakInitClock( )
 {
 #if defined ( MCU_PLATFORM_STM32 )
diff --git a/src/stm32/can.cpp b/src/stm32/can.cpp
index 5a57c25..f352419 100644
--- a/src/stm32/can.cpp
+++ b/src/stm32/can.cpp
@@ -759,7 +759,7 @@ void HAL_CAN_RxFifo0FullCallback(CAN_HandleTypeDef *hcan)
 {
    // This can happen when holding MCU via SWD
    //exception("Full Callback");
-   lWarning("CAN: RX fifo full");
+   lWarning( LDS("CRFF", "CAN: RX fifo full") );
 }
 
 void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan)
diff --git a/src/stm32/flash_intern.cpp b/src/stm32/flash_intern.cpp
index 52d2810..468f814 100644
--- a/src/stm32/flash_intern.cpp
+++ b/src/stm32/flash_intern.cpp
@@ -36,6 +36,7 @@ extern char _end_data_flash;
 extern char _start_user_flash;
 
 
+//constexpr
 CFlashIntern::CFlashIntern( )
          //:CFlash((address_t)flashStart() + (address_t)size(), size(), EAcquireDirection::highLow)
          :CFlash((address_t)userStart(), userSize() )
@@ -474,8 +475,8 @@ address_t CFlashIntern::flashEnd() const
 {
    return( (address_t)FLASH_BASE + (address_t)FLASH_SIZE );
 }
-
-address_t CFlashIntern::userStart() const
+#if 0
+constexpr address_t CFlashIntern::userStart() const
 {
    // when _start_user_flash would not be available:
    #if 0
@@ -493,7 +494,7 @@ address_t CFlashIntern::userStart() const
    #endif
 }
 
-int CFlashIntern::userSize() const
+constexpr int CFlashIntern::userSize() const
 {
    return(
       //(address_t)size()
@@ -506,7 +507,7 @@ int CFlashIntern::userSize() const
                   - (address_t)userStart() );
          #endif
 }
-
+#endif
 void CFlashIntern::eraseUserFlash()
 {
    // Check everything is alligned to pages
diff --git a/src/stm32/gpio.cpp b/src/stm32/gpio.cpp
index 9ff80a3..48d2386 100644
--- a/src/stm32/gpio.cpp
+++ b/src/stm32/gpio.cpp
@@ -212,8 +212,10 @@ void CGpio::setMode( const SGpioMode& gpioMode )
 
 CGpio::~CGpio()
 {
+   /*
    HAL_GPIO_DeInit( peripheralEnumToPeripheral( m_eGpioPeripheral )
                    , pinEnumToDefine( m_eGpioPin ) );
+   */
 }
 
 void CGpio::setValue(bool _value) const
diff --git a/src/stm32/systick.cpp b/src/stm32/systick.cpp
index de6c793..5387956 100644
--- a/src/stm32/systick.cpp
+++ b/src/stm32/systick.cpp
@@ -39,8 +39,10 @@
 //---Implementation------------------------------------------------------------
 
 
-lrtimer_t lrtPerMsec=-1;
-int systickCounter=0;
+const lrtimer_t lrtPerMsec=1;
+// #define lrtPerMsec 1
+
+// int systickCounter=0;
 
 #if ! IS_ENABLED( CONFIG_BIWAK_NO_HRT )
 // Fixed point float to increase precission
@@ -60,7 +62,11 @@ hrtimer_t hrtPerRt=-1;
 void initSystick( )
 {
    // How much ticks do we need till one lrtimer-step/1ms is reached?
-   systickCounter=( HAL_RCC_GetSysClockFreq() / MSECS_PER_SEC );
+   #if 1
+      // systickCounter=48000;
+   #else
+      systickCounter=( HAL_RCC_GetSysClockFreq() / MSECS_PER_SEC );
+   #endif
    
    // Calling HAL_SYSTICK_Config() and HAL_NVIC_SetPriority() is already done
    // via HAL_Init():
@@ -86,7 +92,7 @@ void initSystick( )
    hrtPerUsec = ( hrtMultiplikator / USECS_PER_MSEC );
    #endif
 
-   lrtPerMsec = 1;
+   /*lrtPerMsec = 1;*/
 
    // Must have higher priority than anything using timer values.
    //HAL_NVIC_SetPriority( SysTick_IRQn, NVI_HIGH_PRIORITY, 1);
@@ -172,27 +178,55 @@ hrtimer_t usecToHrtValue(int useconds)
 
 #else
 
+/*
 hrtimer_t msecToHrtValue(int mseconds)
 {
    exception( );
    return( 0 );
 }
+*/
 
 #endif
 
-int32_t lrtValueToMsec(lrtimer_t lrtValue)
+int32_t lrtValueToMsec(const lrtimer_t lrtValue)
+{
+   return( lrtValue /* / lrtPerMsec */ );
+}
+
+lrtimer_t msecToLrt(const int32_t msec)
 {
-   return( lrtValue / lrtPerMsec );
+   return( msec /* * lrtPerMsec */ );
 }
 
-lrtimer_t msecToLrt(int32_t msec)
+#if 1
+constexpr int div1000(const int x)
 {
-   return( msec * lrtPerMsec );
+    //return (x >> 10) + (x >> 16) + (x >> 17);
+   // 999,83
+   //return( ( x * 4195U ) >> 22 );
+   /*
+   int cnt=0;
+   while( x )
+   {
+      x-=1000;
+      cnt++;
+   }
+   return(cnt);
+   */
+   return( ( ( x >> 3 ) * 131 ) >> 14 );
+   // return( x / 1000 );
 }
+#endif
 
 int32_t lrtValueToSec(lrtimer_t lrtValue)
 {
-   return( (lrtValue / lrtPerMsec) / MSECS_PER_SEC );
+   //return( (lrtValue / lrtPerMsec) / MSECS_PER_SEC );
+   //return( lrtValue / MSECS_PER_SEC );
+   //static_assert( lrtPerMsec == 1 );
+   return( div1000( lrtValue ) );
+
+   //int cnt=0;
+   //while( lrtValue)
 }
 
 lrtimer_t secToLrt(int32_t sec)
@@ -200,13 +234,13 @@ lrtimer_t secToLrt(int32_t sec)
    return( sec * lrtPerMsec * MSECS_PER_SEC );
 }
 
-int usleepLr(useconds_t usecDelayValue
+void usleepLr(useconds_t usecDelayValue
             #if IS_ENABLED( CONFIG_BIWAK_DATA_EVENT )
                          , bool breakOnData
             #endif
              )
 {
-   lrtimer_t nowValue;
+   //lrtimer_t nowValue;
    lrtimer_t startValue=getLrTimerValue();
 
    #if IS_ENABLED( CONFIG_BIWAK_DETECT_NESTED_USLEEP )
@@ -234,14 +268,25 @@ int usleepLr(useconds_t usecDelayValue
             pending=false;
          #endif
             
-         return(0);
+         return; //(0);
       }
       //printf( "DATA: %d/%d\n", biwakDataAvailable, biwakDataAvailableOnLastExit );
    #endif
        
-   usecDelayValue/=USECS_PER_MSEC;
+   //usecDelayValue/=USECS_PER_MSEC;
+   //usecDelayValue=((uint64_t)usecDelayValue * 0x10624DD3ULL) >> 38;
+   //(usecDelayValue >> 10) + (usecDelayValue >> 16) + (usecDelayValue >> 17)
+   /*
+   static_assert( div1000_fast( 1000 ) == 1 );
+   static_assert( div1000_fast( 900 ) == 1 );
+   static_assert( div1000_fast( 10000 ) == 10 );
+   static_assert( div1000_fast( 234000 ) == 234 );
+   static_assert( div1000_fast( 567000 ) == 567 );
+   */
+   int msecDelayValue=div1000( usecDelayValue );
+   //usecDelayValue/=1000;
        
-   while( ( (nowValue=getLrTimerValue()) - startValue)/lrtPerMsec < (int)usecDelayValue )
+   while( /*div1000*/( (/*nowValue=*/getLrTimerValue()) - startValue ) < msecDelayValue )
    {
 // Low power modes can not be debugged on L100; Openocd communication
 // fails
@@ -269,7 +314,7 @@ int usleepLr(useconds_t usecDelayValue
       pending=false;
    #endif
       
-   return(0);
+   return; //(0);
 }
 
 #if ! IS_ENABLED( CONFIG_BIWAK_NO_HRT )
@@ -409,10 +454,11 @@ void clearWakeup()
    #pragma GCC diagnostic pop
 }
 
+/*
 int getSystickCounter()
 {
    return( systickCounter );
 }
-
+*/
 
 //---fin-----------------------------------------------------------------------
Entering 'libcampo'
diff --git a/include/campo/vagus.hpp b/include/campo/vagus.hpp
index 7684b64..ec1ce04 100644
--- a/include/campo/vagus.hpp
+++ b/include/campo/vagus.hpp
@@ -219,6 +219,7 @@ class CVagus
       void digestNmtObject( const Tdt::CMessage &msg );
 
       #if IS_ENABLED( CONFIG_VAGUS_CUSTOM_DIGEST_SEND_OBJECT )
+      as
       virtual bool digestSendObject( const Tdt::CMessage &msg ) = 0;
       #else
       bool digestSendObject( const Tdt::CMessage &msg );
@@ -230,6 +231,7 @@ class CVagus
             bool digestWriteObjectCustom( const Tdt::CMessage &msg );
          #else
             bool digestWriteObject( const Tdt::CMessage &msg );
+            asd
             virtual bool digestWriteObjectCustom( const Tdt::CMessage &msg ) = 0;
          #endif
       #else
@@ -237,12 +239,20 @@ class CVagus
       #endif
       
       #if IS_ENABLED( CONFIG_VAGUS_TDT_MMP )
-      void digestMmpObject( const Tdt::CMessage &msg );
-      virtual int handleMmpTransfer( const Tdt::CMmpTransferData& transferData );
+         void digestMmpObject( const Tdt::CMessage &msg );
+         int handleMmpTransfer( const Tdt::CMmpTransferData& transferData );
+         #if IS_ENABLED( CONFIG_VAGUS_PSEUDO_VIRTUAL )
+            int handleMmpTransferCustom( const Tdt::CMmpTransferData& transferData );
+         #else
+         sd
+            virtual int handleMmpTransferCustom( const Tdt::CMmpTransferData& transferData ) = 0;
+         #endif
       #endif
       
       #if IS_ENABLED( CONFIG_VAGUS_CUSTOM_SEND_INTRODUCTION )
+         asd
          virtual void sendIntroduction()=0;
+         asd
       #else
          void sendIntroduction();
       #endif
@@ -253,6 +263,7 @@ class CVagus
             #if IS_ENABLED( CONFIG_VAGUS_CUSTOM_SEND_CONFIG_PV )
                void sendConfigCustom();
             #else
+         sasd
                virtual void sendConfigCustom() = 0;
             #endif
          #endif
@@ -304,6 +315,7 @@ class CVagus
       #endif
 
       #if IS_ENABLED( CONFIG_VAGUS_CUSTOM_BUS )
+         sdf
       virtual int transmit( const SCanMessage &message ) = 0;
       #endif
       
diff --git a/src/vagus.cpp b/src/vagus.cpp
index 85096f4..337858a 100644
--- a/src/vagus.cpp
+++ b/src/vagus.cpp
@@ -210,11 +210,12 @@ void CVagus::eventLoop()
 
    #if IS_ENABLED( CONFIG_VAGUS_USE_OPERATINGTIME )
       #define OPT_UPDATES_PER_HOUR  4
+      #define OPT_UPDATES_PER_HOUR_SHIFT 2
       // The value is stored in seconds, but only stored every hour.
       // lifetime is usually 10⁶ erase/write cycles. Device will run > 100 years
-      if( lrElapsedSeconds(&m_lrTimerOperatingTime, SEC_PER_HOUR / OPT_UPDATES_PER_HOUR ) )
+      if( lrElapsedSeconds(&m_lrTimerOperatingTime, SEC_PER_HOUR >> OPT_UPDATES_PER_HOUR_SHIFT ) )
       {
-         VAGUS_CONFIG( operatingTime )+=SEC_PER_HOUR / OPT_UPDATES_PER_HOUR;
+         VAGUS_CONFIG( operatingTime )+=SEC_PER_HOUR >> OPT_UPDATES_PER_HOUR_SHIFT;
          storeConfig();
       }
    #endif
@@ -664,8 +665,8 @@ int CVagus::handleMmpTransfer( const Tdt::CMmpTransferData& transfer )
    }
    */
    
-   lCritical("MMP:NI");
-   return(0);
+   //lCritical("MMP:NI");
+   return( handleMmpTransferCustom( transfer ) );
 }
 
 #endif // ? CONFIG_VAGUS_TDT_MMP
Entering 'libfosh'
Entering 'libkokon'
diff --git a/include/kokon/kokon.hpp b/include/kokon/kokon.hpp
index ea20a12..e484558 100644
--- a/include/kokon/kokon.hpp
+++ b/include/kokon/kokon.hpp
@@ -29,6 +29,7 @@
 #include <biwak/retain.h>
 #include <biwak/linker_script.h>
 #include <biwak/i2c_slave.h>
+#include <biwak/flash_intern.h>
 #include <lepto/log.h>
 #include <campo/vagus.hpp>
 #include <tdt/message.hpp>
@@ -61,7 +62,7 @@ class CKokon: public CVagus
       static constexpr const uint8_t APPLICATION_DISABLED = 0xE0;
       
       #if IS_ENABLED( CONFIG_KOKON_SEND_EEPROM )
-            char eeprom[0x80];
+         char eeprom[0x80];
       #endif
       
       bool m_isReverse;
@@ -76,6 +77,7 @@ class CKokon: public CVagus
          //operator int(){ return((int)this); };
       };
       int operator =(EErrorCode e){ return((int)e); };
+      CFlashIntern m_flash;
       
    public:
       CKokon( );
@@ -86,6 +88,7 @@ class CKokon: public CVagus
       void bootApplication();
       void moveInterrupVectorTable();
       void addressInfo();
+      /*
       virtual bool digestWriteObject(const Tdt::CMessage& msg)
       {
          return( false );
@@ -93,11 +96,21 @@ class CKokon: public CVagus
       virtual void sendConfig() final
       {
       }
-      virtual void setDefaultConfig() final /* abstract */
+      */
+      #if IS_ENABLED( CONFIG_VAGUS_PSEUDO_VIRTUAL )
+      void setDefaultConfig()
+      #else
+      virtual void setDefaultConfig() override final
+      #endif
       {
          VAGUS_CONFIG( nodeId ) = 53;
       }
-      int handleMmpTransfer( const Tdt::CMmpTransferData& transferData ) override;
+
+      #if IS_ENABLED( CONFIG_VAGUS_PSEUDO_VIRTUAL )
+         int handleMmpTransfer( const Tdt::CMmpTransferData& transferData );
+      #else
+         virtual int handleMmpTransfer( const Tdt::CMmpTransferData& transferData ) override;
+      #endif
       //void transferAcknowledge(int sta);
 
       // Is the bootloader located in application flash area and supposed to
diff --git a/src/kokon.cpp b/src/kokon.cpp
index 74e79d6..41cbe07 100644
--- a/src/kokon.cpp
+++ b/src/kokon.cpp
@@ -202,7 +202,6 @@ int CKokon::handleMmpTransfer( const Tdt::CMmpTransferData& tdata ) /* virtual *
 {
    lDebug( LDS( "MCMD x%X", "MMP Command: 0x%X"), tdata.header().mmpCommand);
    
-   CFlashIntern flash;
    bool commandForReverse=false;
    //const Tdt::CMmpTransferData& tdata=transfer.m_data;
    int sta=(int)EErrorCode::unhandled;
@@ -234,7 +233,7 @@ int CKokon::handleMmpTransfer( const Tdt::CMmpTransferData& tdata ) /* virtual *
             }
             pages= m_workAreaSize / FLASH_PAGE_SIZE;
             
-            sta=flash.erasePage( m_workAreaAddress, pages );
+            sta=m_flash.erasePage( m_workAreaAddress, pages );
             //transferAcknowledge(sta);
          #endif
          break;
@@ -263,7 +262,7 @@ int CKokon::handleMmpTransfer( const Tdt::CMmpTransferData& tdata ) /* virtual *
             {
                dataLen = ( dataLen + 8 ) & ~7;
             }
-            sta=flash.writeData( m_workAreaAddress + tdata.header().flashAddress
+            sta=m_flash.writeData( m_workAreaAddress + tdata.header().flashAddress
                                   ,tdata.data(), dataLen );
             if(sta)
             {
@@ -383,4 +382,19 @@ void CVagus::bootApplication()
 }
 
 
+#if IS_ENABLED( CONFIG_VAGUS_PSEUDO_VIRTUAL )
+
+void CVagus::setDefaultConfig()
+{
+   static_cast<CKokon*>( this )->setDefaultConfig( );
+}
+
+int CVagus::handleMmpTransferCustom( const Tdt::CMmpTransferData& transferData )
+{
+   return( static_cast<CKokon*>( this )->handleMmpTransfer( transferData ) );
+}
+
+#endif
+
+
 //---fin----------------------------------------------------------------------
Entering 'liblepto'
Entering 'libtdt'
diff --git a/README.md b/README.md
index d756998..b6d9522 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,14 @@
 libTDT is an CAN based protocol for simple sensor values.
+
+ 1 | EObject  | ENmtObject | mmpSource |
+ 2 |          |            |           |
+   -------------------------------------
+ 3 |         EUnit         | mmpPos    |
+   ------------------------|           |
+ 4 |         Reserved      |           |
+   -------------------------------------
+ 5 |                                   |
+ 6 |              Data                 |
+ 7 |                                   |
+ 8 |                                   |
+   -------------------------------------
diff --git a/arena/apps/mainswitch.json b/arena/apps/mainswitch.json
index 8898a32..7b54590 100644
--- a/arena/apps/mainswitch.json
+++ b/arena/apps/mainswitch.json
@@ -7,7 +7,10 @@
    "comment": "must not disable _ctype_",
    "symbolMap": [
       "vfprintf = lepto_vfprintf",
-      "vsnprintf = lepto_vsnprintf"
+      "vsnprintf = lepto_vsnprintf",
+      "HAL_RCC_GetSysClockFreq = BIWAK_RCC_GetSysClockFreq",
+      "HAL_RCC_OscConfig = BIWAK_RCC_OscConfig",
+      "Xmain = abort"
    ],
    "X": "XHAL_RCC_OscConfig = b_RCC_OscConfig",
    "periphery": [
@@ -30,7 +33,7 @@
          "name": "1",
          "variant": "!Xbootloader"
       },
-      { 
+      {
          "type": "OPTION_BYTES",
          "name": "1",
          "variant": "!bootloader"
diff --git a/common/config.h b/common/config.h
index 9684227..e23a2b2 100644
--- a/common/config.h
+++ b/common/config.h
@@ -19,6 +19,8 @@
 #define CONFIG_LAYOUT_MAJOR                        1
 #define CONFIG_LAYOUT_MINOR                        0
 
+#define CONFIG_VAGUS_PSEUDO_VIRTUAL                1
+
 // writing config like node shutdown time
 #define CONFIG_VAGUS_CUSTOM_DIGEST_WRITE_OBJECT    1
 #define CONFIG_VAGUS_CUSTOM_DIGEST_WRITE_OBJECT_PV 1
diff --git a/libbiwak b/libbiwak
--- a/libbiwak
+++ b/libbiwak
@@ -1 +1 @@
-Subproject commit 8c1e9558f3391d24e7b9bda1a667e9da77c7640b
+Subproject commit 8c1e9558f3391d24e7b9bda1a667e9da77c7640b-dirty
diff --git a/libcampo b/libcampo
--- a/libcampo
+++ b/libcampo
@@ -1 +1 @@
-Subproject commit 8af6a6deda6ed8148193de2a2d1a7fd63ab0e966
+Subproject commit 8af6a6deda6ed8148193de2a2d1a7fd63ab0e966-dirty
diff --git a/libkokon b/libkokon
--- a/libkokon
+++ b/libkokon
@@ -1 +1 @@
-Subproject commit 83ed0a44e92edbcc2460a083001094f9ef389abb
+Subproject commit 83ed0a44e92edbcc2460a083001094f9ef389abb-dirty
diff --git a/libtdt b/libtdt
--- a/libtdt
+++ b/libtdt
@@ -1 +1 @@
-Subproject commit d6a851567089cdf5448560221f8271f785d6f4d5
+Subproject commit d6a851567089cdf5448560221f8271f785d6f4d5-dirty
diff --git a/mainswitch/include/mainswitch.h b/mainswitch/include/mainswitch.h
index 9feb765..e82cd96 100644
--- a/mainswitch/include/mainswitch.h
+++ b/mainswitch/include/mainswitch.h
@@ -72,13 +72,15 @@ class CMainSwitch: public CVagus
             // int reg;
             int mul;
             int add;
-            int div;
+            //int div;
+            int mul2;
+            int shift;
          };
       
-         static constexpr SLm25056Value LMTemp{ 0x8d, 100, 14500, 1580 * 10 };
-         static constexpr SLm25056Value LMCurr{ 0xd1, 1, 0, 1 };
+         static constexpr SLm25056Value LMTemp{ 0x8d, 100, 14500, /* 1580 * 10, */ 1, 1 };
+         static constexpr SLm25056Value LMCurr{ 0xd1, 1, 0, /* 1,*/ 1, 1 };
          // 0xDC is AVG
-         static constexpr SLm25056Value LMVolt{ 0x88, 100, 1343, 16296 };
+         static constexpr SLm25056Value LMVolt{ 0x88, 100, 1343, /* 16296, */ 263821, 32 };
       #endif
 
    private:
@@ -126,7 +128,11 @@ class CMainSwitch: public CVagus
       ~CMainSwitch();
 
       void prepareApplication();
-      virtual void setDefaultConfig() override final;
+      #if IS_ENABLED( CONFIG_VAGUS_PSEUDO_VIRTUAL )
+         void setDefaultConfig();
+      #else
+         virtual void setDefaultConfig() override final;
+      #endif
       void eventLoop();
       void poweroff() __attribute__((noreturn));
 
diff --git a/mainswitch/src/main.cpp b/mainswitch/src/main.cpp
index b92b7ab..890fe9d 100644
--- a/mainswitch/src/main.cpp
+++ b/mainswitch/src/main.cpp
@@ -23,13 +23,29 @@
 //---Implementation-----------------------------------------------------------
 
 
+extern "C" {
+   void SystemClock_Config( );
+   uint32_t BIWAK_RCC_GetSysClockFreq() __attribute__((used));
+   uint32_t HAL_RCC_GetSysClockFreq() __attribute__((used));
+   HAL_StatusTypeDef BIWAK_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct) __attribute__((used));
+   HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct) __attribute__((used));
+}
+
+
 int main(void)
 { 
    biwakInitNoClock();
    //biwakInit();
    //arenaInit();
+   //HAL_RCC_GetSysClockFreq();
 
    CMainSwitch *pMainSwitch=new CMainSwitch;
+   //printf("%d\n", (int)&BIWAK_RCC_OscConfig + (int)&BIWAK_RCC_GetSysClockFreq );
+   printf("%d\n", (int)&HAL_RCC_GetSysClockFreq );
+
+   //static CMainSwitch mainSwitch;
+   //CMainSwitch *pMainSwitch=&mainSwitch;
+
    pMainSwitch->prepareApplication();
 
    pMainSwitch->appInfo();
diff --git a/mainswitch/src/main_bootloader.cpp b/mainswitch/src/main_bootloader.cpp
index a237250..91ca868 100644
--- a/mainswitch/src/main_bootloader.cpp
+++ b/mainswitch/src/main_bootloader.cpp
@@ -22,8 +22,14 @@
 int main(void)
 {
    biwakInit();
-   
-   CKokon* pKokon=new CKokon;
+
+   //CKokon kokon;
+   //CKokon* pKokon=&kokon;
+
+   static CKokon kokon;
+   CKokon* pKokon=&kokon;
+
+   //CKokon* pKokon=new CKokon;
 
    #if ! IS_ENABLED( CONFIG_VAGUS_TDT_MMP )
       #error "MMP is not enabled."
diff --git a/mainswitch/src/mainswitch.cpp b/mainswitch/src/mainswitch.cpp
index f176368..e9f0585 100644
--- a/mainswitch/src/mainswitch.cpp
+++ b/mainswitch/src/mainswitch.cpp
@@ -338,7 +338,9 @@ void CMainSwitch::measureAdc()
    int value=m_adcLineBattery.accuireAdcValue();
    m_outputMeasureEnable.switchOff();
    
-   int milliVolt = ( value * 3000 ) / 4095;
+   // int milliVolt = ( value * 3000 ) / 4095;
+   static_assert( ( ( 4095 + 1 ) * 3000 ) / 4095 == 3000);
+   int milliVolt = ( ( value + 1 ) * 3000 ) >> 12;
    
    #if IS_ENABLED( CONFIG_ALERT_VOLTAGES )
       if( milliVolt <= MILLIVOLT_BATTERY_WARNING )
@@ -380,7 +382,10 @@ int CMainSwitch::lm25056(// uint8_t reg, int mul, int add, int div,
     */
    value=value16;
    // printf("RAW[0x%X]: 0x%X\n", v.reg, value16);
-   value = ( ( ( value * v.mul ) + v.add ) * 1000 ) / v.div;
+
+   //value = ( ( ( value * v.mul ) + v.add ) * 1000 ) / v.div;
+   value = ( ( ( ( value * v.mul ) + v.add ) * 1000 ) * v.mul2 ) >> v.shift;
+
    sendObject( object, unit, Tdt::SValue{ ._int = value } );
    
    return(value);
@@ -519,9 +524,9 @@ void CMainSwitch::sendConfigCustom() /* virtual  */
 void CMainSwitch::keepAwake()
 {
    // Extend the new timeout to half of the configured time
-   if( lrElapsedSeconds(m_wakeEventTimer) > (int)CUSTOM_CONFIG( shutdownTime )/2 )
+   if( lrElapsedSeconds(m_wakeEventTimer) > (int)CUSTOM_CONFIG( shutdownTime ) >> 2 )
    {
-      m_wakeEventTimer=lrNow() - secToLrt( CUSTOM_CONFIG( shutdownTime ) / 2 );
+      m_wakeEventTimer = lrNow() - secToLrt( CUSTOM_CONFIG( shutdownTime ) >> 2 );
    }
 }
 
@@ -538,7 +543,7 @@ void CMainSwitch::sendIntroduction() /* virtual override final */
 #if IS_ENABLED( CONFIG_VAGUS_CUSTOM_DIGEST_WRITE_OBJECT_PV )
 bool CVagus::digestWriteObjectCustom( const Tdt::CMessage &msg )
 {
-   return( static_cast<CMainSwitch*>( this )->digestWriteObject( msg ) );
+   return( static_cast<CMainSwitch*>( this )->digestWriteObjectCustom( msg ) );
 }
 #endif
 
@@ -551,5 +556,12 @@ void CVagus::sendConfigCustom( )
 }
 #endif
 
+#if IS_ENABLED( CONFIG_VAGUS_PSEUDO_VIRTUAL )
+void CVagus::setDefaultConfig()
+{
+   static_cast<CMainSwitch*>( this )->setDefaultConfig( );
+}
+#endif
+
 
 //---fin----------------------------------------------------------------------
