Index: trunk/fw_g473rct/SES/src/ah_counter.c
===================================================================
--- trunk/fw_g473rct/SES/src/ah_counter.c	(revision 26)
+++ trunk/fw_g473rct/SES/src/ah_counter.c	(revision 27)
@@ -39,4 +39,8 @@
 }
 
+void AH_COUNTER_SetDetectedAh(void)
+{
+  sys_data.s.values.detectedCapacity = sys_data.s.values.mAh_AutoMode >= 0 ? sys_data.s.values.mAh_AutoMode : -sys_data.s.values.mAh_AutoMode;
+}
 
 //	--- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------
@@ -188,5 +192,5 @@
   		  {
   			  // This line is not so important anymore, because we do not allow mAh_AutoMode to be greater than zero
-  			  sys_data.s.values.detectedCapacity = sys_data.s.values.mAh_AutoMode >= 0 ? sys_data.s.values.mAh_AutoMode : -sys_data.s.values.mAh_AutoMode;
+  			  AH_COUNTER_SetDetectedAh();
   			  WH_COUNTER_SetDetectedEnergy();
   			  startMeasurement = 0;			  
@@ -214,6 +218,6 @@
   		  if ((sys_data.s.values.lastTimeVbatFull >= 3600U) && (sys_data.s.values.lastTimeVbatFull <= 240U * 3600U)) 	// This line prevents from very high discharge-currents to be used to estimate battery capacity
   		  {
-  			  // This line is not so important anymore, because we do not allow mAh_AutoMode to be greater than zero
-  			  sys_data.s.values.detectedCapacity = sys_data.s.values.mAh_AutoMode >= 0 ? sys_data.s.values.mAh_AutoMode : -sys_data.s.values.mAh_AutoMode;
+  			  
+  			  AH_COUNTER_SetDetectedAh();
   			  WH_COUNTER_SetDetectedEnergy();
   			  startMeasurement = 0;			  
Index: trunk/fw_g473rct/SES/src/eeprom.c
===================================================================
--- trunk/fw_g473rct/SES/src/eeprom.c	(revision 26)
+++ trunk/fw_g473rct/SES/src/eeprom.c	(revision 27)
@@ -3,5 +3,4 @@
 #include "eeprom.h"
 #include "stdio.h"
-#include "math.h"
 #include "modbus.h"
 
@@ -20,4 +19,7 @@
 #define PAGE_SIZE 64     // in Bytes
 #define PAGE_NUM  4096    // number of pages
+	
+	
+#define PADDRPOSITION 6 //MUST BE calculated  for every eeprom type --//int paddrposition = log(PAGE_SIZE)/log(2);
 
 /********************************************************/
@@ -76,5 +78,5 @@
   uint16_t	  uBatFull;
   uint16_t	  uBatEmpty;
-  uint8_t	  socCalcMode;
+  uint16_t	  socCalcMode;
   uint16_t	  cellRatedDischargeTime;
 
@@ -100,4 +102,5 @@
   int16_t	  extraDischargeStrom_mA;					// For example, current that consumes LiPro itself
   uint16_t	  cefW;
+  int16_t	  batteryEmptyDetectionMode;		
 
 } eeprom_data_t;
@@ -221,5 +224,5 @@
 	/* tBatFull					*/											2,				// t-batt full 2 Sekunden
 	/* uBatFull					*/											0,				// 14V olt Ubatt full, Neu: Bei 0: Erkung von Lipro LVP als 0% 
-	/* uBatEmpty				*/											-1,				// 11,312V Ubatt Empty
+	/* uBatEmpty				*/											11312,				// 11,312V Ubatt Empty
 	/* socCalcMode				*/											1,				// SoC calculation mode: 0(default)
 	/* cellRatedDischargeTime	*/											2,				// cell rated current discharge time [C/x]. For example, if 40Ah cell is rated as 0.5c, then rated discharge time is 2
@@ -257,4 +260,5 @@
 	/* extraDischargeStrom_mA	*/											7,				// mA, current that LiPro consumes itself
 	/* cefW		*/															90,				// 90% cef for Wh calculations
+	/* Battery Empty Detection Mode*/										1,				// Auto, from BMS
 	
 
@@ -371,4 +375,5 @@
   dataToStore->changedData.extraDischargeStrom_mA									= defaultEepromData.extraDischargeStrom_mA;
   dataToStore->changedData.cefW														= defaultEepromData.cefW;
+  dataToStore->changedData.batteryEmptyDetectionMode								= defaultEepromData.batteryEmptyDetectionMode;
   
 
@@ -475,4 +480,5 @@
   dataToStore->changedData.extraDischargeStrom_mA									= defaultEepromData.extraDischargeStrom_mA;
   dataToStore->changedData.cefW														= defaultEepromData.cefW;
+  dataToStore->changedData.batteryEmptyDetectionMode								= defaultEepromData.batteryEmptyDetectionMode;
  
 
@@ -570,5 +576,6 @@
   dataToStore->changedData.extraDischargeStrom_mA = data->s.parameter.extraDischargeStrom_mA;
   dataToStore->changedData.cefW = data->s.parameter.cefW;
- 
+  dataToStore->changedData.batteryEmptyDetectionMode = data->s.parameter.batteryEmptyDetectionMode;
+
   // Eeprom Status Infos
   dataToStore->eepromState.writeCounter++;
@@ -672,4 +679,6 @@
   data->s.parameter.extraDischargeStrom_mA										= dataToStore->changedData.extraDischargeStrom_mA;
   data->s.parameter.cefW														= dataToStore->changedData.cefW;
+  data->s.parameter.batteryEmptyDetectionMode									= dataToStore->changedData.batteryEmptyDetectionMode;
+	
 
 
@@ -713,5 +722,6 @@
 void EEPROM_Read (uint16_t page, uint16_t offset, uint8_t *data, uint16_t size)
 {
-	int paddrposition = log(PAGE_SIZE)/log(2);
+	//int paddrposition = log(PAGE_SIZE)/log(2);
+	int paddrposition = PADDRPOSITION;
 
 	uint16_t startPage = page;
@@ -731,4 +741,5 @@
 		pos += bytesremaining;
 	}
+
 }
 
@@ -738,5 +749,5 @@
 
 	// Find out the number of bit, where the page addressing starts
-	int paddrposition = log(PAGE_SIZE)/log(2);
+	int paddrposition = PADDRPOSITION;
 
 	// calculate the start page and the end page
@@ -758,5 +769,4 @@
 
 		HAL_I2C_Mem_Write(EEPROM_I2C, EEPROM_ADDR, MemAddress, 2, &data[pos], bytesremaining, 1000);  // write the data to the EEPROM
-
 		startPage += 1;  // increment the page, so that a new page address can be selected for further write
 		offset=0;   // since we will be writing to a new page, so offset will be 0
Index: trunk/fw_g473rct/SES/src/modbus.c
===================================================================
--- trunk/fw_g473rct/SES/src/modbus.c	(revision 26)
+++ trunk/fw_g473rct/SES/src/modbus.c	(revision 27)
@@ -180,4 +180,5 @@
 	if (HAL_UART_Init(mb_data->uart) != HAL_OK)
 	{
+	  printf("ERROR Uart INIT\r\n");
 	  Error_Handler();
 	}
