CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
chaithanyarss
Date:
Fri Jul 08 12:53:24 2016 +0000
Parent:
235:c127b15409b2
Child:
249:1560c64adffb
Commit message:
Completed HK except Flash

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
DefinitionsAndGlobals.h Show annotated file Show diff for this revision Revisions of this file
FMS_all.h Show annotated file Show diff for this revision Revisions of this file
Flash.h Show annotated file Show diff for this revision Revisions of this file
RESET_functions.h Show annotated file Show diff for this revision Revisions of this file
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
cdms_rtc.h Show annotated file Show diff for this revision Revisions of this file
cdms_sd.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CDMS_HK.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/CDMS_HK.h	Fri Jul 08 12:53:24 2016 +0000
@@ -46,29 +46,28 @@
     HANDLE_HW_FAULTS();
     FUNC_CDMS_GPIO_STATUS(); //yet to be done
 
-    uint8_t CDMS_quant[19];
+    uint8_t CDMS_quant[20];
+    CDMS_quant[1]= (uint8_t)quant_data.CDMS_temp_quant;
+    CDMS_quant[2]= (uint8_t)RSSI_volatge;
     for(int i=0; i<16; i++) {
-        CDMS_quant[i]= (uint8_t)quant_data.temp_quant[i];
+        CDMS_quant[i+4]= (uint8_t)quant_data.temp_quant[i];
     }
-    CDMS_quant[16]= (uint8_t)RSSI_volatge;
-    CDMS_quant[17]= (uint8_t)quant_data.CDMS_temp_quant;
     minMaxHkData();
 
-    uint64_t time = FCTN_CDMS_RD_RTC();             //Reading Time from RTC
-    gPC.printf("0x%08X \n",time);
-    time = time>>7;
-    uint32_t HK_time = (uint32_t)time;
-    for(int i = 0; i<4; i++)
-        CDMS_HEALTH_DATA[i] = HK_time >> i;
+    CDMS_HEALTH_DATA[1] = GPIO_STATUS;            //Reading GPIO Pins
+    CDMS_HEALTH_DATA[0] = GPIO_STATUS >> 8;
+    COLLECT_CDMS_RAM();
+    for(int i = 0;i<84;i++)
+        CDMS_HEALTH_DATA[2+i] = CDMS_RAM[i];                  //Reading RAM parameters
+    for(int i = 0;i<20;i++)                                   //Collecting Data from Temp sensors
+        CDMS_HEALTH_DATA[86+i] = CDMS_quant[i];
 
-    // Here: Have to FIT flash data.
-    for(int i = 0; i<19; i++)                       //Collecting Data from Temp sensors
-        CDMS_HEALTH_DATA[i+24] = CDMS_quant[i];
+    // Here: Have to FIT flash data.    
+    
+    uint64_t time = FCTN_CDMS_RD_RTC() >> 7;             //Reading Time from RTC
+    for(int i = 124; i<128; i++)
+        CDMS_HEALTH_DATA[i] = time >> i*8;
 
-    COLLECT_CDMS_RAM();                             //Reading RAM parameters
-
-    CDMS_HEALTH_DATA[126] = GPIO_STATUS;            //Reading GPIO Pins
-    CDMS_HEALTH_DATA[127] = GPIO_STATUS >> 8;
     FCTN_SD_MNGR();                                 //Adding FSC & TMID to TM frame
     CDMS_HK_FRAME[0] = 0x20;
     CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1;
@@ -106,7 +105,7 @@
             for(int i = 0; i<15; i++)
                 gPC.printf("\r 0x%02X\n",BAE_HK[i]);
             for(int i = 0; i<4; i++)
-            BAE_HK[i] = HK_time >> i;
+            BAE_HK[i] = time >> i;
             BAE_HK_FRAME[0] = 0x28;
             BAE_HK_FRAME[1] = FSC_CURRENT[5]+1;
             BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8;
@@ -268,6 +267,10 @@
     GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5)));
     //PL_EPS_LATCH_SW_OC_FAULT // to be verified
     GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4)));
+    //EPS_V_C_EN_STATUS
+    GPIO_STATUS=(EPS_V_C_EN_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3)));
+    //EPS_V_D_EN_STATUS
+    GPIO_STATUS=(EPS_V_D_EN_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2)));
     
 }
 
@@ -382,76 +385,61 @@
             PL_FAULTCOUNT = 0;
         }
     }
+    
 }
 
 void COLLECT_CDMS_RAM()
 {
-    /*--------------------Current FSC's---------------------*/
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+43] = FSC_LAST[5] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+47] = FSC_CURRENT[5] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+51] = FSC_LAST[4] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+55] = FSC_CURRENT[4] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+59] = FSC_LAST[3] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+63] = FSC_CURRENT[3] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+67] = FSC_LAST[2] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+71] = FSC_CURRENT[2] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+75] = FSC_LAST[1] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+79] = FSC_CURRENT[1] >> (i*8);
-    /*---------------------Latest Time----------------------*/
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+83] = TIME_LATEST_SPI_SPEED >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+87] = TIME_LATEST_SD_RD >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+91] = TIME_LATEST_SD_WR >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+95] = TIME_LATEST_I2C_SPEED >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+99] = TIME_LATEST_I2C_BAE >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+103] = TIME_LATEST_RTC >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+107] = COMRX_RESET_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+107] = PL_RCV_SC_DATA_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+111] = PL_MAIN_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+113] = CDMS_HK_MAIN_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+115] = CDMS_I2C_ERR_BAE_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+117] = CDMS_I2C_ERR_SPEED_COUNTER >> (i*8);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | CDMS_STANDBY_PL << 7;
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_INIT_STATUS << 6) & 0x40);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_MAIN_STATUS << 5) & 0x20);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_STATUS << 3) & 0x18);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((COMRX_STATUS << 2) & 0x04);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_RTC_BL << 1) & 0x02);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] & 0xFE;
-
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | PL_RCV_SC_DATA_STATUS << 7;
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_SESSION << 6) & 0x40);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_RX << 5) & 0x20);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((RF_SW_STATUS << 4) & 0x10);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX << 3) & 0x08);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX_STATUS << 2) & 0x04);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_MNG_TMTC << 1) & 0x02);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | (CDMS_STANDBY_HK & 0x01);
-
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | PL_INIT_STATUS << 7;
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_MAIN_STATUS << 6) & 0x40);
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_LOW_POWER << 5) & 0x20);
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_STATE << 3) & 0x18);
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | (PL_STATUS & 0x07);
-}
\ No newline at end of file
+    CDMS_RAM[0] = ((PL_INIT_STATUS<<7)&0x80)|((PL_MAIN_STATUS<<6)&0x40)|((PL_LOW_POWER<<5)&0x20)|((PL_STATE<<3)&0x18)|(PL_STATUS&0x07);
+    CDMS_RAM[1] = ((PL_RCV_SC_DATA_STATUS<<7)&0x80)|((COM_SESSION<<6)&0x40)|((COM_RX<<5)&0x20)|((RF_SW_STATUS<<4)&0x10)|((COM_TX<<3)&0x08)|((COM_TX_STATUS<<2)&0x04)|((COM_MNG_TMTC<<1)&0x02)|(EN_CDMS_HK&0x01);
+    CDMS_RAM[2] = ((EN_PL<<7)&0x80)|((EN_RCV_SC<<6)&0x40)|((CDMS_INIT_STATUS<<5)&0x20)|((CDMS_HK_MAIN_STATUS<<4)&0x10)|((CDMS_HK_STATUS<<2)&0x0C)|((COM_RX_STATUS<<1)&0x02)|(CDMS_RTC_BL&0x01);
+    CDMS_RAM[3] = CDMS_I2C_ERR_SPEED_COUNTER >> 8;
+    CDMS_RAM[4] = CDMS_I2C_ERR_SPEED_COUNTER;
+    CDMS_RAM[5] = CDMS_I2C_ERR_BAE_COUNTER >> 8;
+    CDMS_RAM[6] = CDMS_I2C_ERR_BAE_COUNTER;
+    CDMS_RAM[7] = CDMS_HK_MAIN_COUNTER >> 8;
+    CDMS_RAM[8] = CDMS_HK_MAIN_COUNTER;
+    CDMS_RAM[9] = PL_MAIN_COUNTER >> 8;
+    CDMS_RAM[10] = PL_MAIN_COUNTER;
+    CDMS_RAM[11] = PL_RCV_SC_DATA_COUNTER >> 8;
+    CDMS_RAM[12] = PL_RCV_SC_DATA_COUNTER;
+    CDMS_RAM[13] = COMRX_RESET_COUNTER >> 8;
+    CDMS_RAM[14] = COMRX_RESET_COUNTER;
+    CDMS_RAM[15] = CDMS_WR_SD_FAULT_COUNTER >> 8;
+    CDMS_RAM[16] = CDMS_WR_SD_FAULT_COUNTER;
+    CDMS_RAM[17] = SD_LIB_WRITES >> 8;
+    CDMS_RAM[18] = SD_LIB_WRITES;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[19+i] = TIME_LATEST_RTC >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[23+i] = TIME_LATEST_I2C_BAE >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[27+i] = TIME_LATEST_I2C_SPEED >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[31+i] = TIME_LATEST_SD_WR >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[35+i] = TIME_LATEST_SD_RD >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[39+i] = TIME_LATEST_SPI_SPEED >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[43+i] = FSC_CURRENT[1] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[47+i] = FSC_LAST[1] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[51+i] = FSC_CURRENT[2] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[55+i] = FSC_LAST[2] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[59+i] = FSC_CURRENT[3] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[63+i] = FSC_LAST[3] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[67+i] = FSC_CURRENT[4] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[71+i] = FSC_LAST[4] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[75+i] = FSC_CURRENT[5] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[79+i] = FSC_LAST[5] >> i*8;
+    CDMS_RAM[83] = 0x00;
+}
--- a/COM_MNG_TMTC.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/COM_MNG_TMTC.h	Fri Jul 08 12:53:24 2016 +0000
@@ -50,7 +50,7 @@
 uint8_t ACK_CODE;
 
 void TM_PMS_PL_SCHEDULE(Base_tm* tm_pointer1,uint8_t psc);
-void ACK_L234(Base_tm* tm_pointer_short1,uint8_t ackCode,uint8_t psc);
+void ACK_L234(Base_tm* tm_pointer1,uint8_t ackCode,uint8_t psc);
 
 #define delete_TC(tc_ptr) {\
     if(tc_ptr == gHEAD_NODE_TCL){\
@@ -220,19 +220,19 @@
 /*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */
 
 // CDMS TEAM CODE START
-void ACK_L234(Base_tm* tm_pointer_short1,uint8_t ackCode,uint8_t psc)
+void ACK_L234(Base_tm* tm_pointer1,uint8_t ackCode,uint8_t psc)
 {
-    tm_pointer_short1->TM_string[0] = 0xB0; 
-    tm_pointer_short1->TM_string[1] = psc;
-    tm_pointer_short1->TM_string[2] = ackCode;
-    tm_pointer_short1->TM_string[3] = 0x00;
-    tm_pointer_short1->TM_string[4] = 0x00;
+    tm_pointer1->TM_string[0] = 0xB0; 
+    tm_pointer1->TM_string[1] = psc;
+    tm_pointer1->TM_string[2] = ackCode;
+    tm_pointer1->TM_string[3] = 0x00;
+    tm_pointer1->TM_string[4] = 0x00;
     for(uint8_t i=0;i<6;i++)
-        tm_pointer_short1->TM_string[i+5] = 0;
-    crc16 = crc16_gen(tm_pointer_short1->TM_string,11);
-    tm_pointer_short1->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-    tm_pointer_short1->TM_string[12] = (uint8_t)(crc16&0x00FF);
-    tm_pointer_short1->next_TM = NULL;                                                 
+        tm_pointer1->TM_string[i+5] = 0;
+    crc16 = crc16_gen(tm_pointer1->TM_string,11);
+    tm_pointer1->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
+    tm_pointer1->TM_string[12] = (uint8_t)(crc16&0x00FF);
+    tm_pointer1->next_TM = NULL;                                                 
 }
 void TM_PMS_PL_SCHEDULE(Base_tm *tm_pointer1,uint8_t psc)
 {
@@ -367,11 +367,8 @@
     //uint8_t ACKCODE = 0xB0;
     bool y;
     //gPC.printf("\rTC execution in progress\r\n");
-    Base_tm *tm_pointer = new Long_tm;
+    Base_tm *tm_pointer = new Base_tm;
     Base_tm *tm_ptr = tm_pointer;
-    //Base_tm *tm_ptr = new Long_tm;
-    Base_tm *tm_pointer_short = new Short_tm;
-    Base_tm *tm_ptr_short = tm_pointer_short;
     received = 0;
     switch(GETapid(tc_ptr))             //checking APID's
     {
@@ -385,8 +382,8 @@
                 
             if(y==1)                                                            
             {                                                                               
-                ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr));
-                return tm_ptr_short;
+                ACK_L234(tm_pointer,0x03,GETpacket_seq_count(tc_ptr));
+                return tm_ptr;
             }                                  
             else if(y==0)
             {
@@ -409,17 +406,17 @@
                     }
                     else if(y==1)
                     {
-                        ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr));                
+                        ACK_L234(tm_pointer,0x85,GETpacket_seq_count(tc_ptr));                
                         //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR);
-                        return tm_ptr_short;
+                        return tm_ptr;
                         break;  
                     }
                 }
                 else if(BAE_I2C_GPIO == 0)                                       //name to be changed later
                 {
                     gPC.printf("BAE_I2C_GPIO is not high\r\n");                    
-                    ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr));
-                    return tm_ptr_short;
+                    ACK_L234(tm_pointer,0x84,GETpacket_seq_count(tc_ptr));
+                    return tm_ptr;
                 }
             }
             BAE_I2C_mutex.unlock();
@@ -441,8 +438,8 @@
                             mid=((uint16_t)(tc_ptr->TC_string[3]<<4))+((uint16_t)(tc_ptr->TC_string[4]));                                                       
                             if(mid!=0x0000 && mid!=0x0001)
                             {
-                                ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }
                             FCTN_CDMS_RD_L_RAM(tm_pointer);
 
@@ -465,15 +462,15 @@
 
                             if(mid!= && mid!=)                                  //allowable MID values?
                             {
-                                ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                                                        
 
                             FCTN_CDMS_WR_S_FLASH(tc_ptr);                            
 
-                            ACK_L234(tm_ptr_short,???,GETpacket_seq_count(tc_ptr));                     //ackCode = ? for success
+                            ACK_L234(tm_pointer,???,GETpacket_seq_count(tc_ptr));                     //ackCode = ? for success
 
-                            return tm_ptr_short;
+                            return tm_ptr;
                         }
                         case 0x6:
                         {
@@ -483,20 +480,20 @@
 
                             if(mid<0x0002 || mid>0x000A)                                  //allowable MID values?
                             {
-                                ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));                     //ackCode = ? for invalid mid
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));                     //ackCode = ? for invalid mid
+                                return tm_ptr;
                             }    
 
                             ///Send TM for success after writing onto flash
                             FCTN_CDMS_WR_L_FLASH(mid);
 
-                            return tm_ptr_short;
+                            return tm_ptr;
                         }                                                    
                         default:
                         {
                             gPC.printf("INVALID SERVICE SUBTYPE\r\n");
-                            ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;
+                            ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;
                         }
                     } 
                 }  */                                                                 
@@ -513,13 +510,13 @@
                                 
                                 P_PL_INIT();
 
-                                ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                
                             else if(CDMS_STANDBY==0)
                             {
-                                ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
+                                return tm_ptr;
                             }
                         }                                
                         else if(GETpid(tc_ptr)==0x02)
@@ -530,13 +527,13 @@
                                 
                                 P_PL_MAIN();
 
-                                ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                
                             else if(CDMS_STANDBY==0)
                             {
-                                ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
+                                return tm_ptr;
                             }
                         }
                         else if(GETpid(tc_ptr)==0x03)
@@ -547,13 +544,13 @@
                                 
                                 P_COM_INIT();
 
-                                ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                
                             else if(CDMS_STANDBY==0)
                             {
-                                ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
+                                return tm_ptr;
                             }
                         }
                         else if(GETpid(tc_ptr)==0x04)
@@ -564,13 +561,13 @@
                                 
                                 P_CDMS_HK_MAIN();
 
-                                ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                
                             else if(CDMS_STANDBY==0)
                             {
-                                ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
+                                return tm_ptr;
                             }
                         }
                         else if(GETpid(tc_ptr)==0x05)
@@ -581,13 +578,13 @@
                                 
                                 P_PL_RCV_SC_DATA();
 
-                                ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                
                             else if(CDMS_STANDBY==0)
                             {
-                                ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
+                                return tm_ptr;
                             }
                         }
                         else if(GETpid(tc_ptr)==0x06)
@@ -598,13 +595,13 @@
                                 
                                 P_CDMS_INIT_SD();
 
-                                ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
                             }                
                             else if(CDMS_STANDBY==0)
                             {
-                                ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
-                                return tm_ptr_short;
+                                ACK_L234(tm_pointer,0x87,GETpacket_seq_count(tc_ptr));                        //TC cannot be processed now
+                                return tm_ptr;
                             }    
                         }
                         else if(GETpid(tc_ptr)==0x11)
@@ -613,8 +610,8 @@
                             
                             CDMS_SD_SW_ON();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                       
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                       
                         }
                         else if(GETpid(tc_ptr)==0x21)
                         {       
@@ -622,8 +619,26 @@
                             
                             CDMS_SD_SW_OFF();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;     
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;     
+                        }
+                        else if(GETpid(tc_ptr)==0x12)
+                        {       
+                            //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
+                            
+                            CDMS_RTC_ON();
+
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                       
+                        }
+                        else if(GETpid(tc_ptr)==0x22)
+                        {       
+                            //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
+                            
+                            CDMS_RTC_OFF();
+
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                       
                         }
                         else if(GETpid(tc_ptr)==0x13)
                         {                           
@@ -631,8 +646,8 @@
                             
                             SW_ON_BAE();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                            
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                            
                         }
                         else if(GETpid(tc_ptr)==0x23)
                         {                           
@@ -640,8 +655,8 @@
                             
                             SW_OFF_BAE();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                        
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                        
                         }
                         else if(GETpid(tc_ptr)==0x14)
                         {                            
@@ -649,8 +664,8 @@
                             
                             SW_ON_PL_BEE();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                        
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                        
                         }
                         else if(GETpid(tc_ptr)==0x24)
                         {                   
@@ -658,8 +673,8 @@
                             
                             SW_OFF_PL_BEE();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;    
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;    
                         }
                         else if(GETpid(tc_ptr)==0x15)
                         {                            
@@ -667,8 +682,8 @@
                             
                             SW_ON_PL_EPS();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));     
-                            return tm_ptr_short;                            
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));     
+                            return tm_ptr;                            
                         }
                         else if(GETpid(tc_ptr)==0x25)
                         {                            
@@ -676,8 +691,8 @@
                             
                             SW_OFF_PL_EPS();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                            
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                            
                         }
                         else if(GETpid(tc_ptr)==0x16)
                         {                            
@@ -686,8 +701,8 @@
                             
                             SW_ON_V_A_EN();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                        
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                        
                         }
                         else if(GETpid(tc_ptr)==0x26)
                         {                        
@@ -695,8 +710,8 @@
                             
                             SW_OFF_V_A_EN();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                    
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                    
                         }
                         else if(GETpid(tc_ptr)==0x31)
                         {                            
@@ -704,8 +719,8 @@
                             
                             RST_SD();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                        
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                        
                         }
                         else if(GETpid(tc_ptr)==0x33)
                         {                            
@@ -713,8 +728,8 @@
                             
                             RST_BAE();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                            
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                            
                         }
                         else if(GETpid(tc_ptr)==0x34)
                         {                            
@@ -722,15 +737,16 @@
                             
                             RST_PL_BEE();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                        
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                        
                         }
                         else if(GETpid(tc_ptr)==0x38)
                         {
                             //gPC.printf()
                             
                             CDMS_INTERNAL_RESET();
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;
                         }
                         else if(GETpid(tc_ptr)==0x40)
                         {                         
@@ -738,8 +754,8 @@
                             
                             RST_HK_COUNTER();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;                                                    
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;                                                    
                         }
                         else if(GETpid(tc_ptr)==0x41)
                         {                            
@@ -747,14 +763,14 @@
                             
                             RST_HK_COUNTER();
 
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr_short;    
+                            ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;    
                         }
                         else if(GETpid(tc_ptr)==0xF1)
                         {          
                             //gPC.printf("TC_CDMS_RD_RTC\r\n"); // call PWR_SWCH_ON function
                             
-                            /*uint32_t time_temp = FCTN_CDMS_RD_RTC();                        //RTC_RD_EROR has to incorporated
+                            uint32_t time_temp = FCTN_CDMS_RD_RTC();                        //RTC_RD_EROR has to incorporated
                             tm_pointer->TM_string[0] = 0x78;     
                             tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);                                    
                             tm_pointer->TM_string[2] = 0xA0;
@@ -770,27 +786,28 @@
                             crc16 = crc16_gen(tm_ptr->TM_string,132);
                             tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8);
                             tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF);
-                            tm_pointer->next_TM = NULL;                 
-                            return tm_ptr; */                                                    //incomplete
+                            tm_pointer->next_TM = NULL;                                                                     //incomplete
+                            return tm_ptr;
                         }
                         else if(GETpid(tc_ptr)==0xF0)
                         {
                             uint8_t statusbits[64];
                             CDMS_RD_SD_HK(statusbits);
-                            ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
+                            ACK_L234(tm_pointer,0xC0,GETpacket_seq_count(tc_ptr));
+                            return tm_ptr;
                         }                               
                         else 
                         {
                             gPC.printf("INVALID FID\r\n");
-                            ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));  
-                            return tm_ptr_short;
+                            ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));  
+                            return tm_ptr;
                         }
                     }
                     else 
                     {
                         gPC.printf("INVALID SERVICE SUBTYPE\r\n");
-                        ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));  
-                        return tm_ptr_short;
+                        ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));  
+                        return tm_ptr;
                     }                                    
                 }
                 case 0x70:
@@ -890,15 +907,15 @@
                     else
                     {
                         gPC.printf("INVALID SERVICE SUBTYPE\r\n");
-                        ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));  
-                        return tm_ptr_short;
+                        ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));  
+                        return tm_ptr;
                     }
                 }
                 default:
                 {
                     gPC.printf("ILLEGAL TC"); 
-                    ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
-                    return tm_ptr_short;                    
+                    ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));
+                    return tm_ptr;                    
                 }
             }
         }
@@ -914,8 +931,8 @@
                 
             if(y==1)                                                            
             {                                                                               
-                ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr));
-                return tm_ptr_short;
+                ACK_L234(tm_pointer,0x03,GETpacket_seq_count(tc_ptr));
+                return tm_ptr;
                 break;
             }                                  
             else if(y==0)
@@ -940,28 +957,27 @@
                     }
                     else if(y==1)
                     {
-                        ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr));                
+                        ACK_L234(tm_pointer,0x85,GETpacket_seq_count(tc_ptr));                
                         //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR);
-                        return tm_ptr_short;
+                        return tm_ptr;
                         break;  
                     }
                 }
                 else if(PL_I2C_Intr == 0)                                       //name to be changed later
                 {
                     gPC.printf("PL_I2C_Intr is not high\r\n");                    
-                    ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr));
-                    return tm_ptr_short;
+                    ACK_L234(tm_pointer,0x84,GETpacket_seq_count(tc_ptr));
+                    return tm_ptr;
                 }
             }                             
         }
         default:    //invalid TC
         {
             gPC.printf("INVALID TC\r\n");                 
-            ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
-            return tm_ptr_short;
+            ACK_L234(tm_pointer,0x02,GETpacket_seq_count(tc_ptr));
+            return tm_ptr;
         }
     }
-    return;
 }
 // CDMS TEAM CODE END
 // EXECUTE OBOSC
--- a/DefinitionsAndGlobals.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/DefinitionsAndGlobals.h	Fri Jul 08 12:53:24 2016 +0000
@@ -225,7 +225,7 @@
 // CDMS HK
 uint8_t CDMS_STANDBY;
 uint8_t CDMS_HEALTH_DATA[128];
-uint8_t CDMS_RAM[59];
+uint8_t CDMS_RAM[84];
 uint16_t GPIO_STATUS;
 uint8_t CDMS_HK_MAIN_STATUS;    
 uint8_t COMRX_STATUS;
@@ -245,6 +245,7 @@
 CDMS_HK_min_max min_max_data;
 bool firstCount=true;
 
+    
 //GPIO PINS
 DigitalIn V_A_PGOOD (PIN88);
 DigitalIn V_B_PGOOD_1 (PIN6);
@@ -253,12 +254,13 @@
 DigitalIn COMRX_OC_FAULT (PIN68);
 DigitalIn COMTX_OC_FAULT (PIN69);
 DigitalIn BAE_OC_FAULT (PIN92);
-DigitalIn PL_GPIO_1_STATUS (PIN71);
-DigitalIn PL_GPIO_2_STATUS (PIN81);
-DigitalIn PL_GPIO_3_STATUS (PIN80);
+DigitalOut PL_GPIO_1_STATUS (PIN71);
+DigitalOut PL_GPIO_2_STATUS (PIN81);
+DigitalOut PL_GPIO_3_STATUS (PIN80);
 DigitalIn PL_BEE_SW_OC_FAULT (PIN91);
 DigitalIn PL_EPS_LATCH_SW_OC_FAULT (PIN5);
-DigitalIn V_D_EN_STATUS (PIN56);
+DigitalOut EPS_V_C_EN_STATUS (PIN72);
+DigitalOut EPS_V_D_EN_STATUS (PIN56);
 
 
 DigitalIn SD_OC_FAULT (PIN90);
@@ -295,6 +297,8 @@
 uint16_t COMRX_RESET_COUNTER;
 uint16_t PL_MAIN_COUNTER;
 uint16_t PL_RCV_SC_DATA_COUNTER;
+uint16_t CDMS_WR_SD_FAULT_COUNTER;
+uint16_t SD_LIB_WRITES = 0;
 
 //CDMS RAM parameters
 uint8_t PL_INIT_STATUS;
@@ -308,8 +312,10 @@
 uint8_t COM_TX;
 uint8_t COM_TX_STATUS;
 uint8_t COM_MNG_TMTC;
-uint8_t CDMS_STANDBY_HK;
-uint8_t CDMS_STANDBY_PL;
+uint8_t EN_CDMS_HK;
+uint8_t EN_PL;
+uint8_t EN_RCV_SC;
 uint8_t CDMS_INIT_STATUS;
 uint8_t CDMS_HK_STATUS;
-uint8_t CDMS_RTC_BL;
\ No newline at end of file
+uint8_t COM_RX_STATUS;
+uint8_t CDMS_RTC_BL;
--- a/FMS_all.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/FMS_all.h	Fri Jul 08 12:53:24 2016 +0000
@@ -1,4 +1,5 @@
 
+/*===================================================FMS Functions=================================================*/
 //Run processes
 void P_PL_INIT();
 void P_PL_MAIN();
@@ -27,7 +28,7 @@
 void SW_RST_PL_BEE();
 void RST_BAE();
 void RST_PL_BEE();
-void CDMS_INTERNAL_RESET();
+void CDMS_RESET();
 void SYS_PWR_RESET();  // Have to be decided with EPS team.
 void EPS_V_A_EN();
 void EPS_V_C_EN();
@@ -36,7 +37,7 @@
 uint8_t CDMS_RD_SD_HK(uint8_t *);
 void CDMS_RD_RTC(uint64_t *);
 void CDMS_CALIB_RTC();
-void CDMS_RESET();
+void TOTAL_RESET_WITH_CDMS();
 
 
 void P_PL_INIT()
@@ -46,7 +47,7 @@
 
 void P_PL_MAIN()
 {
-   // FCTN_CDMS_PL_MAIN((void *)NULL);
+   FCTN_CDMS_PL_MAIN((void *)NULL);
 }
 
 void P_COM_INIT()
@@ -81,12 +82,23 @@
 
 void CDMS_RTC_ON()
 {
-    
+    //FCTN_CDMS_INIT_RTC();
+    SPI_mutex.lock();
+    gCS_RTC=1;
+    gCS_RTC=0;
+    spi.write(0x81); //register address with write flag
+    spi.write(0x00);//disabling stop bit in the seconds register
+    SPI_mutex.unlock();
 }
 
 void CDMS_RTC_OFF()
 {
-    
+    SPI_mutex.lock();
+    gCS_RTC=1;
+    gCS_RTC=0;
+    spi.write(0x81); //register address with write flag
+    spi.write(0x80);//enabling stop bit in the seconds register
+    SPI_mutex.unlock();
 }
 
 void SW_ON_BAE()
@@ -262,4 +274,16 @@
 {
     
 }
-*/
\ No newline at end of file
+*/
+
+
+/*===================================================MMS Functions=================================================*/
+
+void READ_RAM(uint8_t *);
+void WRITE_TO_FLASH();
+void READ_FLASH();
+
+void READ_RAM(uint8_t *RAM)
+{
+    
+}
\ No newline at end of file
--- a/Flash.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/Flash.h	Fri Jul 08 12:53:24 2016 +0000
@@ -1,28 +1,33 @@
 #include "FreescaleIAP.h"
 
-int strt_add = flash_size() - (4*SECTOR_SIZE);  
-uint32_t flasharray[256+(3*1024)];
-char *nativeflash = (char*)strt_add;
+int strt_add = flash_size() - (2*SECTOR_SIZE);
+uint32_t flasharray[8];    //256+(3*1024)
+/*corrected*/
+int *nativeflash = (int*)strt_add;
 
 /*Writing to the Flash*/
-void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t block)
+void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t fdata)  //j-position to write address  ; fdata - flash data to be written
 {
-    for(int64_t i=0;i<(256+(3*1024));i++)
+    for(int i=0;i<8;i++)
     {
         flasharray[i]=nativeflash[i];
     }
-    flasharray[j]=block;
+    flasharray[j]=fdata;
     erase_sector(strt_add);
-    program_flash(strt_add, (char*)&flasharray,4*(256+(1024*3)));
+    program_flash(strt_add, (char*)flasharray,32);
 }
+
 /*End*/
 
 /*Reading from Flash*/
-uint32_t FCTN_CDMS_RD_FLASH(uint16_t j)
+
+uint32_t* FCTN_BAE_RD_FLASH()
 {
-    for(int64_t i=0;i<(256+(3*1024));i++)
+    for(int i=0;i<8;i++)
     {
         flasharray[i]=nativeflash[i];
     }
-    return flasharray[j];
-}
\ No newline at end of file
+    return flasharray;
+}
+
+/*End*/
--- a/RESET_functions.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/RESET_functions.h	Fri Jul 08 12:53:24 2016 +0000
@@ -11,6 +11,7 @@
 
 void RESET_RTC()
 {
+    SPI_mutex.lock();
     gCS_RTC=1;
     gCS_RTC=0;
     spi.write(0x81); //register address with write flag
@@ -33,6 +34,7 @@
     gCS_RTC=0;
     spi.write(0x8F);
     spi.write(0x00);
+    SPI_mutex.unlock();
 }
 
 
--- a/ThreadsAndFunctions.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/ThreadsAndFunctions.h	Fri Jul 08 12:53:24 2016 +0000
@@ -24,7 +24,6 @@
         srp(gPAYLOAD_BUFFER);
         gPC.puts("exit_srp\r\n");
         //gPAY_SPI.bulkRead_start();
-        
     }
 }
 
--- a/cdms_rtc.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/cdms_rtc.h	Fri Jul 08 12:53:24 2016 +0000
@@ -12,6 +12,11 @@
     spi.write(0x81); //register address with write flag
     spi.write(0x80);//enabling stop bit in the seconds register
     gCS_RTC=1;
+    
+    gCS_RTC=0;
+    spi.write(0x81);
+    spi.write(0x00);//disabling the stop bit to restart the oscillator 
+    gCS_RTC=1;
         
     //clearing the halt bit 
     gCS_RTC=1;
@@ -31,12 +36,6 @@
     spi.write(0x80|0x03);
     spi.write(0x00);
     gCS_RTC=1;
-
-    
-    gCS_RTC=0;
-    spi.write(0x81);
-    spi.write(0x00);//disabling the stop bit to restart the oscillator 
-    gCS_RTC=1;
     
     gCS_RTC=0;
     spi.write(0x80); 
--- a/cdms_sd.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/cdms_sd.h	Fri Jul 08 12:53:24 2016 +0000
@@ -31,7 +31,6 @@
 uint32_t LOG_FIRST =5001;
 uint32_t LOG_LAST=6000;
 uint32_t SD_MNG_SECT=7000;
-uint16_t SD_LIB_WRITES = 0;
 
 extern uint8_t SD_INIT_FLAGS;
 
--- a/main.cpp	Wed Jul 06 08:09:22 2016 +0000
+++ b/main.cpp	Fri Jul 08 12:53:24 2016 +0000
@@ -86,6 +86,14 @@
                             gPC.puts("exit_adf\r\n");\
 }
 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
+
+
+void CDMS_INIT()
+{
+        
+}
+
+
 int main()
 {