FM

Dependencies:   SimpleDMA eeprom mbed-rtos mbed FreescaleIAP

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
samp1234
Date:
Mon Feb 06 16:36:46 2017 +0000
Parent:
351:a89a46894ec0
Child:
353:e1803e801e20
Commit message:
Working I2c: Importing to test Comperssion code

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
COM_POWER_OFF_TX.h Show annotated file Show diff for this revision Revisions of this file
COM_POWER_ON_TX.h Show annotated file Show diff for this revision Revisions of this file
COM_SND_TM.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
EEPROM.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
OBSRS.h Show annotated file Show diff for this revision Revisions of this file
TEST_PL.h Show diff for this revision Revisions of this file
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
common_functions.h Show annotated file Show diff for this revision Revisions of this file
i2c.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	Sun Jan 22 04:47:11 2017 +0000
+++ b/CDMS_HK.h	Mon Feb 06 16:36:46 2017 +0000
@@ -17,17 +17,18 @@
 AnalogIn CDMS_temp_sensor(PIN53);
 AnalogIn COMRX_RSSI_VOLTAGE(PIN70);
 AnalogIn EPS_BTRY_VOLT (PIN54);
+AnalogIn BAE_CURRENT_MUX_OUT (PIN53);
 
 DigitalOut SelectLinec3 (PIN79); // MSB of Select Lines
 DigitalOut SelectLinec2 (PIN78);
-DigitalOut SelectLinec1 (PIN76);
-DigitalOut SelectLinec0 (PIN77); // LSB of Select Lines
+// SBC V1.0
+//DigitalOut SelectLinec1 (PIN76);
+//DigitalOut SelectLinec0 (PIN77); // LSB of Select Lines
 
-/*
-Before SBC. To be restored in FM model
+// SBC V2.0
 DigitalOut SelectLinec1 (PIN77);
 DigitalOut SelectLinec0 (PIN76); // LSB of Select Lines
-*/
+
 
 Convolution CDMS_HEALTH;
 Convolution BAE_HEALTH;
@@ -186,7 +187,7 @@
      //  gPC.printf("BAE_HK_");
             crc = crc16_gen((unsigned char *)BAE_HK,132);
             if(crc == ((uint16_t)BAE_HK[132] << 8) | (uint16_t)BAE_HK[133]) {
-                //gPC.printf("BAE HK data recieved through I2C\t");
+                gPC.printf("BAE HK data recieved through I2C\t");
                 TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7;
                 /*for(int i = 0; i<15; i++)
                     gPC.printf("\r 0x%02X\n",BAE_HK[i]);*/
@@ -226,8 +227,10 @@
 
         } else {
             gPC.printf("BAE HK data not recieved through I2C\t");
+            gPC.printf("/r/n ack= %d",BAE_HK_I2C);
             for(int i = 0; i<134; i++)
                 BAE_HK[i] = 0;
+                
         }
         // gPC.printf("Completed BAE HK\n");
 
@@ -482,12 +485,16 @@
     if(SD_STATUS != DEVICE_DISABLED) {
         if(SD_STATUS == DEVICE_OC_FAULT) {
             gPC.printf("Switching on SD card");
+            SD_CARD_fromuC_ENA3 = 1; 
+            SD_CARD_fromISO_ENA4 = 1;
             SD_SW_EN_DS = 1; //powering on SD
             wait_ms(10);
         }
 
         if(SD_OC_FAULT == 0) {
             gPC.printf("Switching off SD card");
+            SD_CARD_fromuC_ENA3 = 0; 
+            SD_CARD_fromISO_ENA4 = 0;
             SD_SW_EN_DS = 0; //switching off SD card
             SD_FAULTCOUNT++;
             SD_STATUS = (SD_FAULTCOUNT == 3) ? DEVICE_DISABLED :DEVICE_OC_FAULT;
--- a/COM_MNG_TMTC.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/COM_MNG_TMTC.h	Mon Feb 06 16:36:46 2017 +0000
@@ -1616,6 +1616,8 @@
             if (DEBUG)\
                 gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\
             /*EXITED DUE TO ABORT ON NACK:*/\
+            COM_DATA_fromuC_ENAIN = 0;\
+            COM_DATA_fromISO_ENAOUT=0;\
             COM_TX_CNTRL = 0;\
             RX1M.attach(&rx_read, Serial::RxIrq);\
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
@@ -1624,6 +1626,8 @@
         else if( (gFLAGS & COM_PA_HOT_FLAG) || (gFLAGS & COM_PA_OC_FLAG) ){\
             /*PA HOT: WAIT FOR TIMEOUT*/\
             gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\
+            COM_DATA_fromuC_ENAIN = 0;\
+            COM_DATA_fromISO_ENAOUT=0;\
             COM_TX_CNTRL = 0;\
             RX1M.attach(&rx_read, Serial::RxIrq);\
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
--- a/COM_POWER_OFF_TX.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/COM_POWER_OFF_TX.h	Mon Feb 06 16:36:46 2017 +0000
@@ -71,6 +71,8 @@
 
 #define COM_POWER_OFF_TX {\
     /*gPC.puts("Inside COM_POWER_OFF_TX\r\n");*/\
+    COM_DATA_fromuC_ENAIN = 0;\
+    COM_DATA_fromISO_ENAOUT=0;\
     COM_TX_CNTRL = 0;\
     RX1M.attach(&rx_read, Serial::RxIrq);\
     gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
--- a/COM_POWER_ON_TX.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/COM_POWER_ON_TX.h	Mon Feb 06 16:36:46 2017 +0000
@@ -221,6 +221,8 @@
     }
     gPC.puts("swd off BAE\r\n");
     COM_TX_CNTRL = 1;
+    COM_DATA_fromuC_ENAIN = 1;
+    COM_DATA_fromISO_ENAOUT=1;
     uint8_t adfConfigPass = 0xFF;
     for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){
         /*PENDING: CONFIGURE ADF and set adfConfigPass*/
--- a/COM_SND_TM.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/COM_SND_TM.h	Mon Feb 06 16:36:46 2017 +0000
@@ -383,6 +383,7 @@
  
                 if(eos_f){
                     transmit[RB_c] = EoS[EOS_c++];
+                    EOS_c = EOS_SIZE;
                     if(EOS_c == EOS_SIZE){
                         EOS_c = 0;
                         eos_f = false;
--- a/DefinitionsAndGlobals.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/DefinitionsAndGlobals.h	Mon Feb 06 16:36:46 2017 +0000
@@ -17,8 +17,8 @@
     #define SPI_CLK PTE2
     #define SPI_CS_ADF PTA15
     #define SPI_CS_SDC PIN20
-  //#define SPI_CS_RTC PIN26 // actual
-     #define SPI_CS_RTC PIN60 // sbc with jumper v1.0
+     #define SPI_CS_RTC PIN26 // actual
+  //   #define SPI_CS_RTC PIN60 // sbc with jumper v1.0
     
 // COM_TX
     #define COM_TX_CONFIG_LIMIT 3
@@ -33,20 +33,20 @@
     DigitalOut PL_I2C_GPIO(PTC1);
             
 //I2C - CDMS to BAE
-    //DigitalIn BAE_I2C_GPIO(PIN67);//PTB21 from bae to cdms
-    //DigitalOut CDMS_I2C_GPIO(PIN39);//PTA5 from cdms to bae 
+  //  DigitalOut CDMS_I2C_GPIO(PIN67);//PTB21 from bae to cdms
+  //  DigitalIn BAE_I2C_GPIO(PIN39);//PTA5 from cdms to bae 
     
-    #define SBC 1
+ //   #define SBC 1
     
-    #if SBC
-    DigitalOut CDMS_I2C_GPIO(PIN67,1);
-    DigitalIn BAE_I2C_GPIO(PIN1);
-    #endif
+ //   #if SBC
+ //   DigitalOut CDMS_I2C_GPIO(PIN67,1);
+ //   DigitalIn BAE_I2C_GPIO(PIN1);
+ //   #endif
     
-    #if !SBC
+  //  #if !SBC
     DigitalIn BAE_I2C_GPIO(PIN67);
     DigitalOut CDMS_I2C_GPIO(PIN39,0);    
-    #endif
+   // #endif
 
 // TC LIST
     #define TCL_STATE_INCOMPLETE 0x00
@@ -155,8 +155,8 @@
     #define BAE_RESET_PID 0x33
 
 //RF RELAY
-    #define RF_RELAY_CNTRL_TX PTB7
-    #define RF_RELAY_CNTRL_BCN PTB17 
+    #define RF_RELAY_CNTRL_TX PTA12
+    #define RF_RELAY_CNTRL_BCN PTA7 
     
 //CDMS HK
 #define HK_SIGNAL 0x05
@@ -180,6 +180,7 @@
 DigitalOut gLEDR(LED_RED);
 DigitalOut gLEDG(LED_GREEN);
 
+
 // COM_RX
 RawSerial RX1M( COM_RX_UART_TX, COM_RX_UART_RX );
 COM_RX_DATA_NODE *gRX_HEAD_DATA_NODE = NULL;
@@ -268,8 +269,8 @@
 float RSSI_VOLTAGE;
 uint8_t COM_ADF_TMP = 0;
 uint8_t COM_PA_IC_TMP = 0;
-uint8_t BAE_HK_SD_DATA_READY = 1;
-uint8_t CDMS_HK_SD_DATA_READY = 1;
+uint8_t BAE_HK_SD_DATA_READY = 0;
+uint8_t CDMS_HK_SD_DATA_READY = 0;
 
 CDMS_HK_actual actual_data;
 CDMS_HK_quant quant_data;
@@ -288,7 +289,7 @@
 DigitalIn COMRX_OC_FAULT (PIN68);
 //DigitalIn COMTX_OC_FAULT (PIN69);
 DigitalIn BAE_OC_FAULT (PIN92);
-DigitalOut PL_GPIO_1_STATUS (PIN71,0); // PYLD EPS CNTRL Signal1 / PYLD_EPS_CNTRL_SIG1
+DigitalOut PL_GPIO_1_STATUS (PIN71,1); // PYLD EPS CNTRL Signal1 / PYLD_EPS_CNTRL_SIG1
 DigitalOut PL_GPIO_2_STATUS (PIN81);//PYLD EPS CNTRL 2 / PYLD_EPS_CNTRL_2
 DigitalOut PL_GPIO_3_STATUS (PIN80);// PYLD EPS CNTRL 3 / PYLD_EPS_CNTRL_3
 DigitalIn PL_BEE_SW_OC_FAULT (PIN91);
@@ -315,6 +316,15 @@
 
 DigitalOut DMA_LED1(PIN61,0);
 DigitalOut SCI_LED1(PIN62,0);
+DigitalOut WDTrigger(PIN33,0);
+
+// Digital Isolator SD card
+    DigitalOut SD_CARD_fromuC_ENA3(PIN85,1); 
+    DigitalOut SD_CARD_fromISO_ENA4 (PIN84,1);    
+
+// COM TX Digital Isolator
+    DigitalOut COM_DATA_fromuC_ENAIN(PIN6,0);
+    DigitalOut COM_DATA_fromISO_ENAOUT(PIN7,0);   
 
 //SD HK
 uint32_t FSC_CURRENT[6];
--- a/EEPROM.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/EEPROM.h	Mon Feb 06 16:36:46 2017 +0000
@@ -47,23 +47,23 @@
     }
     
     gPC.printf("Reading intial parametrs from flash\n");
-    EPS_V_A_EN_STATUS         = READ_FROM_EERPOM(0);
-    BAE_STATUS                = READ_FROM_EERPOM(1);
-    SD_STATUS                 = READ_FROM_EERPOM(2);
-    PL_STATUS                 = READ_FROM_EERPOM(3);
-    PL_EPS_LATCH_SW_EN        = READ_FROM_EERPOM(4);
+    EPS_V_A_EN_STATUS         = READ_FROM_EERPOM(0); // ok
+    BAE_STATUS                = READ_FROM_EERPOM(1); //ok
+    SD_STATUS                 = READ_FROM_EERPOM(2); //ok
+    PL_STATUS                 = READ_FROM_EERPOM(3); //ok
+    PL_EPS_LATCH_SW_EN        = READ_FROM_EERPOM(4); //ok
     RTC_INIT_STATUS           = READ_FROM_EERPOM(5);
-    CDMS_RTC_DISABLE          = READ_FROM_EERPOM(6);
-    CDMS_RESET_COUNTER        = READ_FROM_EERPOM(7);
-    TIME_LATEST_CDSMS_RESET   = READ_FROM_EERPOM(8);
-    COM_TC_BYTES_LIMIT        = READ_FROM_EERPOM(9);
-    COM_RX_CURRENT_MAX        = READ_FROM_EERPOM(10);
-    COM_RX_DISABLE_TIMEOUT    = READ_FROM_EERPOM(11);
-    COM_PA_TMP_HIGH           = READ_FROM_EERPOM(12);
-    COM_PA_RECOVERY_TIMEOUT   = READ_FROM_EERPOM(13);
-    COM_SESSION_TIMEOUT       = READ_FROM_EERPOM(14);
-    COM_RSSI_MIN              = READ_FROM_EERPOM(15);
-    SD_LIB_BLK_CURRENT        = READ_FROM_EERPOM(16);
+  //  CDMS_RTC_DISABLE          = READ_FROM_EERPOM(6);
+    CDMS_RESET_COUNTER        = READ_FROM_EERPOM(7);  //ok
+ //   TIME_LATEST_CDSMS_RESET   = READ_FROM_EERPOM(8);
+ //   COM_TC_BYTES_LIMIT        = READ_FROM_EERPOM(9);
+ //   COM_RX_CURRENT_MAX        = READ_FROM_EERPOM(10);
+ //   COM_RX_DISABLE_TIMEOUT    = READ_FROM_EERPOM(11);
+ //   COM_PA_TMP_HIGH           = READ_FROM_EERPOM(12);
+  //  COM_PA_RECOVERY_TIMEOUT   = READ_FROM_EERPOM(13);
+  //  COM_SESSION_TIMEOUT       = READ_FROM_EERPOM(14);
+ //   COM_RSSI_MIN              = READ_FROM_EERPOM(15);
+    SD_LIB_BLK_CURRENT        = READ_FROM_EERPOM(16); 
 }
 
 #endif
\ No newline at end of file
--- a/FMS_all.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/FMS_all.h	Mon Feb 06 16:36:46 2017 +0000
@@ -81,6 +81,8 @@
 
 void CDMS_SD_SW_ON()
 {
+    SD_CARD_fromuC_ENA3 = 1; 
+    SD_CARD_fromISO_ENA4 = 1;
     SD_SW_EN_DS = 1;
     SD_STATUS = DEVICE_POWERED;
     WRITE_TO_EEPROM(2,DEVICE_POWERED);
@@ -89,6 +91,8 @@
 
 void CDMS_SD_SW_OFF()
 {
+    SD_CARD_fromuC_ENA3 = 0; 
+    SD_CARD_fromISO_ENA4 = 0;
     SD_SW_EN_DS = 0;
     SD_STATUS = DEVICE_DISABLED;
     WRITE_TO_EEPROM(2,DEVICE_DISABLED);
@@ -202,8 +206,12 @@
 
 void RST_SD()
 {
+    SD_CARD_fromuC_ENA3 = 0; 
+    SD_CARD_fromISO_ENA4 = 0;
     SD_SW_EN_DS = 0;
     wait_ms(10);
+    SD_CARD_fromuC_ENA3 = 1; 
+    SD_CARD_fromISO_ENA4 = 1;
     SD_SW_EN_DS = 1;
     SD_STATUS = DEVICE_POWERED;
     WRITE_TO_EEPROM(2,DEVICE_POWERED);
--- a/OBSRS.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/OBSRS.h	Mon Feb 06 16:36:46 2017 +0000
@@ -240,6 +240,7 @@
     }\
     else if(send_EoS_and_stop){\
         buffer_112[counter_buffer_112] = EoS[counter_EoS++];\
+       counter_EoS=120;\
         if(counter_EoS == 120){\
             /*gPC.printf("A eos sent\r\n");*/\
             /*cout<<"EoS sent"<<ENDL;*/\
@@ -252,6 +253,7 @@
     }\
     else if(adf_limit){\
         buffer_112[counter_buffer_112] = EoS[counter_EoS++];\
+       counter_EoS=120;\
         if(counter_EoS == 120){\
             counter_EoS = 0;\
             /*gPC.printf("EoS sent");*/\
@@ -480,6 +482,7 @@
         }
         else if(adf_limit){
             buffer_112[counter_buffer_112] = EoS[counter_EoS++];
+            counter_EoS=120;\
             if(counter_EoS == 120){
 //                cout<<"EoS sent"<<ENDL;
                 restart_adf();
@@ -560,6 +563,7 @@
 //            send_EoS();
             /*gPC.printf("eos2");*/
             buffer_112[counter_buffer_112] = EoS[counter_EoS++];
+            counter_EoS=120;\
             if(counter_EoS == 120){
 //                cout<<"segments_sent = "<<segments_sent<<ENDL;
 //                cout<<"EoS sent"<<ENDL;
--- a/TEST_PL.h	Sun Jan 22 04:47:11 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,575 +0,0 @@
-//F11 to exit full screen mode
-/*---------------------------------------------------------------------------
-                            Testing PL_MAIN
-----------------------------------------------------------------------------*/
-
-
-/* Testing as per the flow chart  */
-/* columns of the array schedule1[][] correspond to Year,Month,Day,Hours,Minutes,Seconds,SID and EXEC_STATUS in integer formats*/
-Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr);
-
-extern uint8_t schedule1[32][8]=
-                        {
-                            {0,1,1,0,0,15,3,3},
-                            {0,1,1,0,0,45,2,3},
-                            {0,1,1,0,1,0,1,3},
-                            {0,1,1,0,1,25,0,3},     
-                            {0,1,1,0,1,50,3,3},
-                            {0,1,1,0,2,10,2,3},
-                            {0,1,1,0,1,40,2,3},
-                            {0,1,1,0,1,10,2,3},
-                            {0,1,1,0,3,40,2,0},
-                            {0,1,1,0,4,10,2,3},
-                            
-                            {0,1,1,0,4,40,0,1},
-                            {0,1,1,0,5,10,3,3},
-                            {0,1,1,0,5,40,3,3},
-                            {0,1,1,0,6,10,2,3},
-                            {0,1,1,0,6,40,1,0},
-                            {0,1,1,0,7,10,2,3},
-                            {0,1,1,0,7,40,3,3},
-                            {0,1,1,0,8,10,0,3},
-                            {0,1,1,0,8,40,1,3},
-                            {0,1,1,0,9,10,1,2},                           
-
-                            {0,1,1,0,9,40,2,3},
-                            {0,1,1,0,10,10,3,1},
-                            {0,1,1,0,10,40,3,3},                         
-                            {0,1,1,0,11,10,2,1},
-                            {0,0,0,0,11,40,0,0},
-                            {0,1,1,0,12,10,0,0},
-                            {0,1,1,0,12,40,0,0},
-                            {0,1,1,0,13, 0,0,0},
-                            {0,1,1,0,0, 0,0,0},
-                            {0,1,1,0,0, 0,0,0},
-
-                            {0,1,1,0,0, 0,0,0},
-                            {0,1,1,0,0, 0,0,0},
-                        };
-
-void convert(Base_tc* test_tc)
-{    
-    for(uint8_t k=3;k<=127;k+=4)
-    {
-        /*-----------1st byte of a block----------*/
-        test_tc->TC_string[k] &= 0x00;
-        //setting Year (2 bits)
-        //test_tc->TC_string[k] &= (~0xC0);
-        test_tc->TC_string[k] |= ((schedule1[(k-3)/4][0] & 0x03)<<6);
-
-        //setting Month (4 bits)
-        //test_tc->TC_string[k] &= (~0x3C);
-        test_tc->TC_string[k] |= ((schedule1[(k-3)/4][1] & 0x0F)<<2);
-
-        //setting first two bits(MSB) of Day
-        //test_tc->TC_string[k] &= (~0x03);
-        test_tc->TC_string[k] |= ((schedule1[(k-3)/4][2] & 0x18)>>3);
-        /*------------end of 1st byte-------------*/
-
-        /*-----------2nd byte of a block----------*/
-        test_tc->TC_string[k+1] &= 0x00000000;
-        //setting remaining 3 bits of Day
-        //test_tc->TC_string[k+1] &= (~0xE0);
-        test_tc->TC_string[k+1] |= ((schedule1[(k-3)/4][2] & 0x07)<<5);
-
-        //setting Hours (5 bits)
-        //test_tc->TC_string[k+1] &= (~0x1F);
-        test_tc->TC_string[k+1] |= ((schedule1[(k-3)/4][3] & 0x1F));
-        /*------------end of 2nd byte-------------*/
-
-        /*-----------3rd byte of a block----------*/
-        test_tc->TC_string[k+2] &= 0x00000000;
-        //setting Minutes (6 bits)
-        //test_tc->TC_string[k+2] &= (~0xFC);
-        test_tc->TC_string[k+2] |= ((schedule1[(k-3)/4][4] & 0x3F)<<2);
-
-        //setting first 2 bits(MSB) of Seconds
-        //test_tc->TC_string[k+2] &= (~0x03);
-        test_tc->TC_string[k+2] |= ((schedule1[(k-3)/4][5] & 0x30)>>4);
-        /*------------end of 3rd byte-------------*/        
-
-        /*-----------4th byte of a block----------*/
-        test_tc->TC_string[k+3] &= 0x00;
-        //setting remaining 4 bits of Seconds
-        //test_tc->TC_string[k+3] &= (~0xF0);
-        test_tc->TC_string[k+3] |= ((schedule1[(k-3)/4][5] & 0x0F)<<4);
-
-        //setting STATE_ID (2 bits)
-        //test_tc->TC_string[k+3] &= (~0x0C);
-        test_tc->TC_string[k+3] |= ((schedule1[(k-3)/4][6] & 0x03)<<2);
-
-        //setting EXEC_STATUS (2 bits)
-        //test_tc->TC_string[k+3] &= (~0x03);
-        test_tc->TC_string[k+3] |= ((schedule1[(k-3)/4][7] & 0x03));
-        /*------------end of 4th byte-------------*/                
-    }    
-}
-/*void test_schedule_1(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x71;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}
-
-void test_schedule_2(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x72;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}
-
-void test_schedule_3(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x73;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}
-
-void test_schedule_4(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x74;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}
-
-void test_schedule_5(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x75;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}
-
-void test_schedule_6(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x76;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}
-
-void test_schedule_F(Base_tm *test_tm_ptr)
-{
-    Base_tc *test_tc = new Long_tc;
-    test_tc->next_TC = NULL;
-    test_tc->TC_string[0] = 0x01;
-    test_tc->TC_string[1] = 0xB2;
-    test_tc->TC_string[2] = 0x7F;
-    convert(test_tc);
-    test_tc->TC_string[131] = 0x00;
-    test_tc->TC_string[132] = 0x00;
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);
-}*/
-#define test_schedule_1(test_tm_ptr) {\
-    Base_tc *test_tc = NULL;\
-    if(!(test_tc  = new Long_tc))\
-    {\
-       gPC.printf("\n\rError: out of memory");\
-       return;\
-    }\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x71;\
-    convert(test_tc);\
-    test_tc->TC_string[131] = 0x00;\
-    test_tc->TC_string[132] = 0x00;\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-#define test_schedule_2(test_tm_ptr) {\
-    Base_tc *test_tc = new Long_tc;\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x72;\
-    convert(test_tc);\
-    test_tc->TC_string[131] = 0x00;\
-    test_tc->TC_string[132] = 0x00;\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-#define test_schedule_3(test_tm_ptr) {\
-    Base_tc *test_tc = new Long_tc;\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x73;\
-    convert(test_tc);\
-    test_tc->TC_string[131] = 0x00;\
-    test_tc->TC_string[132] = 0x00;\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-#define test_schedule_4(test_tm_ptr) {\
-    Base_tc *test_tc = new Long_tc;\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x74;\
-    convert(test_tc);\
-    test_tc->TC_string[131] = 0x00;\
-    test_tc->TC_string[132] = 0x00;\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-#define test_schedule_5(test_tm_ptr) {\
-    Base_tc *test_tc = new Long_tc;\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x75;\
-    convert(test_tc);\
-    test_tc->TC_string[131] = 0x00;\
-    test_tc->TC_string[132] = 0x00;\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-#define test_schedule_6(test_tm_ptr) {\
-    Base_tc *test_tc = new Long_tc;\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x76;\
-    convert(test_tc);\
-    test_tc->TC_string[131] = 0x00;\
-    test_tc->TC_string[132] = 0x00;\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-#define test_schedule_F(test_tm_ptr) {\
-    Base_tc *test_tc = NULL;\
-    if(!(test_tc  = new Long_tc))\
-    {\
-       gPC.printf("\n\rError: out of memory");\
-       return;\
-    }\
-    test_tc->next_TC = NULL;\
-    test_tc->TC_string[0] = 0x01;\
-    test_tc->TC_string[1] = 0xB2;\
-    test_tc->TC_string[2] = 0x7F;\
-    for(uint8_t i=3;i<133;i++)\
-    {\
-        test_tc->TC_string[i] = 0;\
-    }\
-    uint16_t crc16 = crc16_gen(test_tc->TC_string,133);\
-    test_tc->TC_string[133] = (uint8_t)(crc16 & 0xFF00)>>8;\
-    test_tc->TC_string[134] = (uint8_t)(crc16 & 0x00FF);\
-    test_tm_ptr =  FCTN_CDMS_RLY_TMTC(test_tc);\
-    delete test_tc;\
-}
-void send_verify_0xF(Base_tm* test_tm_ptr)
-{
-    uint32_t temp_blk[4] = {0};
-    uint8_t j=0,tm_data_err_count=0;
-    Base_tm* temp_ptr;
-    test_schedule_F(test_tm_ptr);
-    gPC.printf("\n\r----------------------------------------------------------------------------------");
-    gPC.printf("\n\rTC_Schedule_Report(0xF):\n");
-    temp_ptr=test_tm_ptr;
-    while(temp_ptr!=NULL)
-    {
-        /*gPC.printf("\n\rTM[0] = %02X",temp_ptr->TM_string[0]);
-        gPC.printf("\tTM[1] = %02X",temp_ptr->TM_string[1]);
-        gPC.printf("\tTM[2] = %02X",temp_ptr->TM_string[2]);
-        gPC.printf("\tTM[3] = %02X",temp_ptr->TM_string[3]);*/
-        for(uint8_t i=0;i<=112;i+=16)
-        {
-            temp_blk[0] &= 0x00000000;
-            temp_blk[0] |= (((uint32_t)(temp_ptr->TM_string[i+4]))&0x000000FF)<<24;
-            temp_blk[0] |= (((uint32_t)(temp_ptr->TM_string[i+5]))&0x000000FF)<<16;
-            temp_blk[0] |= (((uint32_t)(temp_ptr->TM_string[i+6]))&0x000000FF)<<8;
-            temp_blk[0] |= (((uint32_t)(temp_ptr->TM_string[i+7]))&0x000000FF);
-
-            temp_blk[1] &= 0x00000000;
-            temp_blk[1] |= (((uint32_t)(temp_ptr->TM_string[i+8]))&0x000000FF)<<24;
-            temp_blk[1] |= (((uint32_t)(temp_ptr->TM_string[i+9]))&0x000000FF)<<16;
-            temp_blk[1] |= (((uint32_t)(temp_ptr->TM_string[i+10]))&0x000000FF)<<8;
-            temp_blk[1] |= (((uint32_t)(temp_ptr->TM_string[i+11]))&0x000000FF);
-
-            temp_blk[2] &= 0x00000000;
-            temp_blk[2] |= (((uint32_t)(temp_ptr->TM_string[i+12]))&0x000000FF)<<24;
-            temp_blk[2] |= (((uint32_t)(temp_ptr->TM_string[i+13]))&0x000000FF)<<16;
-            temp_blk[2] |= (((uint32_t)(temp_ptr->TM_string[i+14]))&0x000000FF)<<8;
-            temp_blk[2] |= (((uint32_t)(temp_ptr->TM_string[i+15]))&0x000000FF);
-            
-            temp_blk[3] &= 0x00000000;
-            temp_blk[3] |= (((uint32_t)(temp_ptr->TM_string[i+16]))&0x000000FF)<<24;
-            temp_blk[3] |= (((uint32_t)(temp_ptr->TM_string[i+17]))&0x000000FF)<<16;
-            temp_blk[3] |= (((uint32_t)(temp_ptr->TM_string[i+18]))&0x000000FF)<<8;
-            temp_blk[3] |= (((uint32_t)(temp_ptr->TM_string[i+19]))&0x000000FF);
-
-            if(temp_blk[0]!=pl_block[(i/4)+j])
-                tm_data_err_count++;
-            if(temp_blk[1]!=pl_block[(i/4)+j+1])
-                tm_data_err_count++;
-            if(temp_blk[2]!=pl_block[(i/4)+j+2])
-                tm_data_err_count++;
-            if(temp_blk[3]!=pl_block[(i/4)+j+3])
-                tm_data_err_count++;
-            //gPC.printf("\n\r%03d-0x%08X\t%03d-0x%08X",(i/4)+j,temp_blk[0],(i/4)+1+j,temp_blk[1]);
-            //gPC.printf("\t%03d-0x%08X\t%03d-0x%08X\n",(i/4)+2+j,temp_blk[2],(i/4)+3+j,temp_blk[3]);             
-        }
-        j+=32;
-        //gPC.printf("\n");
-        temp_ptr = temp_ptr->next_TM;
-    }
-    if(tm_data_err_count!=0)
-    {
-        gPC.printf("\n\rTM Data(0xF) not matching pl_block!!!");
-        gPC.printf("\n\rNumber of mismatches = %d",tm_data_err_count);
-    }
-    else if(tm_data_err_count==0)
-    {
-        gPC.printf("\n\rNo errors in TM Data(0xF)");
-    }
-    gPC.printf("\n\r----------------------------------------------------------------------------------");
-    Base_tm *temp;\
-    temp = test_tm_ptr;\
-    while(test_tm_ptr!=NULL)\
-    {\
-        temp = temp->next_TM;\
-        delete test_tm_ptr;\
-        test_tm_ptr = temp;\
-    }\
-}
-void verify_extracted(uint8_t c)
-{
-    uint8_t wrong_extracted=0;
-    uint8_t temp_extracted[8] = {0};
-    for(uint8_t z=(32*(c-1));z<(32*c);z++)
-    {        
-        temp_extracted[0] = (uint8_t)((pl_block[z]&0xC0000000)>>30);
-        temp_extracted[1] = (uint8_t)((pl_block[z]&0x3C000000)>>26);
-        temp_extracted[2] = (uint8_t)((pl_block[z]&0x03E00000)>>21);
-        temp_extracted[3] = (uint8_t)((pl_block[z]&0x001F0000)>>16);
-        temp_extracted[4] = (uint8_t)((pl_block[z]&0x0000FC00)>>10);
-        temp_extracted[5] = (uint8_t)((pl_block[z]&0x000003F0)>>4);
-        temp_extracted[6] = (uint8_t)((pl_block[z]&0x0000000C)>>2);
-        temp_extracted[7] = (uint8_t)((pl_block[z]&0x00000003));
-        
-        for(uint8_t y=0;y<8;y++)
-        {
-            if(temp_extracted[y]!=schedule1[z-(32*(c-1))][y])
-                wrong_extracted++;
-        }
-    }
-    if(wrong_extracted!=0)
-    {
-        gPC.printf("\n\rExtracted values do not match input values!!!");
-        gPC.printf("\n\rNumber of wrong extracted values = %d",wrong_extracted);
-        wrong_extracted = 0;
-    }
-    else if(wrong_extracted==0)
-        gPC.printf("\n\rExtracted values are correct(0x%d)",c);        
-}
-void test_pl_main()
-{
-    uint32_t temp_pl_block[192] = {0};
-    uint8_t wrong_modify=0,z;
-    Base_tm* test_tm_ptr;    
-    for(z=0;z<192;z++)
-        pl_block[z] = 0xFFFFFFFF;
-   // testing 0xF
-    send_verify_0xF(test_tm_ptr);
-    for(z=0;z<192;z++)  
-        temp_pl_block[z] = pl_block[z];
-        
-    //testing TC = 0x1,0x2...0x6
-    int w =1;
-    for(uint8_t v=1;v<7;v++)
-    {        
-        switch(v)
-        {
-            case 1: test_schedule_1(test_tm_ptr);
-                    break;
-            case 2: test_schedule_2(test_tm_ptr);
-                    break;
-            case 3: test_schedule_3(test_tm_ptr);
-                    break;
-            case 4: test_schedule_4(test_tm_ptr);
-                    break;
-            case 5: test_schedule_5(test_tm_ptr);
-                    break;
-            case 6: test_schedule_6(test_tm_ptr);
-                    break;
-        }
-        //gPC.printf("\n\rIndex:%d",w);
-        if(v==1)
-        {
-            test_schedule_1(test_tm_ptr);
-        }
-        else if(v==2)
-        {
-            test_schedule_2(test_tm_ptr);
-        }
-        else if(v==3)
-        {
-            test_schedule_3(test_tm_ptr);
-        }
-        else if(v==4)        
-        {
-            test_schedule_4(test_tm_ptr);
-        }
-        else if(v==5)
-        {
-            test_schedule_5(test_tm_ptr);
-        }
-        else if(v==6)
-        {
-            test_schedule_6(test_tm_ptr);
-        }
-        for(z=0;z<192;z++)
-        {
-            if((z>=((v-1)*32)) && (z<=((v*32)-1)))
-                z++;
-            else
-            {
-                if(temp_pl_block[z]!=pl_block[z])
-                    wrong_modify++;
-            }
-        }
-        if(wrong_modify!=0)
-        {
-            gPC.printf("\n\rWrong values of pl_block modified by TC = 0x%d",v);
-            gPC.printf("\n\rNumber of wrong modifications = %d",wrong_modify);
-            wrong_modify = 0;
-        }
-        else if(wrong_modify==0)
-        {
-            gPC.printf("\n\rTC(0x%d) updated pl_block correctly",v);
-            for(uint8_t i=0;i<=188;i+=4)
-            {
-                //gPC.printf("\n\r%03d-0x%08X\t%03d-0x%08X",(i),pl_block[i],(i)+1,pl_block[(i)+1]);
-                //gPC.printf("\t%03d-0x%08X\t%03d-0x%08X\n",(i)+2,pl_block[(i)+2],(i)+3,pl_block[(i)+3]);
-            }
-        }
-        send_verify_0xF(test_tm_ptr);
-        verify_extracted(v);
-        for(z=0;z<192;z++)
-            temp_pl_block[z] = pl_block[z];
-        wait(1);
-    }
-    gPC.printf("\n\rTesting TC_TM block processing complete");
-}
\ No newline at end of file
--- a/ThreadsAndFunctions.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/ThreadsAndFunctions.h	Mon Feb 06 16:36:46 2017 +0000
@@ -268,6 +268,8 @@
                             //gPC.puts("P_com_hk !!\r\n");
                             if( (gFLAGS & COM_PA_HOT_FLAG) || ( gFLAGS & COM_PA_OC_FLAG ) ){
                                 gPC.puts("Pahot or paoc !!\r\n");
+                                COM_DATA_fromuC_ENAIN = 0;
+                                COM_DATA_fromISO_ENAOUT=0;
                                 COM_TX_CNTRL = 0;
                                 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);
                                 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
@@ -288,7 +290,10 @@
                             reset_all;
                             gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
                             // ENABLE THREADS
+                          
                             HK_counter->start(10000);
+                            
+                           
                             resume_pl_dma = 1;
                             //gPAY_SPI->bulkRead_resume(&payload_isr_fun);
                             gSESSION_TIMEOUT.detach();
@@ -326,6 +331,8 @@
                         //gPC.puts("\r\n");
                         COM_POWER_ON_TX();
                         // PENDING : POWER OFF TX
+                        COM_DATA_fromuC_ENAIN = 0;
+                        COM_DATA_fromISO_ENAOUT=0;
                         COM_TX_CNTRL = 0;
                         RX1M.attach(&rx_read, Serial::RxIrq);
                         gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
@@ -335,6 +342,8 @@
                     COM_POWER_ON_TX();
                     // POWER OFF TX transmitter only
                     // WARNING: reset_all ? clear com_session ?
+                    COM_DATA_fromuC_ENAIN = 0;
+                    COM_DATA_fromISO_ENAOUT=0;
                     COM_TX_CNTRL = 0;
                     reset_all;
                     gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
@@ -358,6 +367,8 @@
             gPC.puts("checking for PA hot in main\r\n");
             P_COM_HK;
             if((gFLAGS & COM_PA_HOT_FLAG) || (gFLAGS & COM_PA_OC_FLAG)){
+                COM_DATA_fromuC_ENAIN = 0;
+                COM_DATA_fromISO_ENAOUT=0;
                 COM_TX_CNTRL = 0;
                 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);
             }
--- a/common_functions.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/common_functions.h	Mon Feb 06 16:36:46 2017 +0000
@@ -145,6 +145,8 @@
         gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG);\        
     if (gFLAGS & COM_PA_OC_FLAG){\
         COM_TX_CNTRL = 1;\
+        COM_DATA_fromuC_ENAIN = 1;\
+        COM_DATA_fromISO_ENAOUT=1;\
         wait_ms(5);\
     }\
     isPAoc(returnHere);\
--- a/i2c.h	Sun Jan 22 04:47:11 2017 +0000
+++ b/i2c.h	Mon Feb 06 16:36:46 2017 +0000
@@ -140,7 +140,7 @@
    //  gPC.printf("i2C_wr\r\n");
     CDMS_I2C_GPIO = 1;
     write_ack = master.write(addr_bae|0x00,data,tc_len2);    
-    Thread::wait(1);    //As per the tests Thread::wait is not required on master side but its safe to give 1ms
+    Thread::wait(1);   //As per the tests Thread::wait is not required on master side but its safe to give 1ms
     pdirw1=PTE->PDIR;
     uint8_t i2c_count = 0;
     if(write_ack == 0)
--- a/main.cpp	Sun Jan 22 04:47:11 2017 +0000
+++ b/main.cpp	Mon Feb 06 16:36:46 2017 +0000
@@ -33,11 +33,11 @@
 #include "COM_POWER_ON_TX.h"
 #include "OBSRS.h"
 #include "ThreadsAndFunctions.h"
-#include "TEST_PL.h"
+//#include "TEST_PL.h"
 
 int main()
 {    
-    
+   
     //RELAY SWITCHING 
     
     
@@ -70,10 +70,14 @@
     // COMMON SPI
     spi.format(8,0);
     spi.frequency(500000);
-
+    SD_CARD_fromuC_ENA3 = 0; 
+    SD_CARD_fromISO_ENA4 = 0;
     SD_SW_EN_DS = 0; 
     wait(1);
+    SD_CARD_fromuC_ENA3 = 1; 
+    SD_CARD_fromISO_ENA4 = 1;
     SD_SW_EN_DS = 1;
+    
     wait(1);
     // SD CARD
     cs_sd = 1;
@@ -83,16 +87,19 @@
     
     FCTN_CDMS_INIT_RTC();/* rtc initialization*/
     FCTN_CDMS_SD_INIT();/* sd card initialization*/
-    
+    INIT_EEPROM(); // added by samp
+
     CDMS_RESET_COUNTER++;
     WRITE_TO_EEPROM(7,CDMS_RESET_COUNTER);
     TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7;
     WRITE_TO_EEPROM(8,TIME_LATEST_CDSMS_RESET);
-    
+  /*  
     uint8_t test[512];
+  
     for(int i =0; i<512; i++)
         test[i] = 0;
-    disk_write(test,80000);
+    disk_write(test,8000);
+   */
     //SD_MNG_SECT = SD_LIB_BLK_CURRENT;
     FCTN_SD_MNGR();
 
@@ -128,7 +135,10 @@
     
     HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL);
     gHK_THREAD->signal_set(HK_SIGNAL);
+   HK_counter->stop();
+   wait_ms(0.1);
    HK_counter->start(10000);
+  // HK_counter->start(10000);
     
     sys_reset_cdms_timer = new RtosTimer(sys_pwr_reset, osTimerPeriodic, (void * )NULL);
     sys_reset_cdms_timer->start(cdms_reset_timeout);