To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: CDMS_HK.h
- Revision:
- 328:2242ebc71be8
- Parent:
- 327:5a967a66c10f
- Child:
- 329:a43494bb338f
--- a/CDMS_HK.h Fri Dec 16 08:53:12 2016 +0000 +++ b/CDMS_HK.h Tue Dec 20 08:36:41 2016 +0000 @@ -65,7 +65,7 @@ hk_count = 2; } // gPC.printf("\n\rEntering HK thread\n"); - gPC.printf("\n\r%d\n",CDMS_WR_SD_FAULT_COUNTER); + //gPC.printf("\n\r%d\n",CDMS_WR_SD_FAULT_COUNTER); if(EN_CDMS_HK == 0x00) continue; CDMS_HK_MAIN_STATUS = 0x01; @@ -73,13 +73,13 @@ FCTN_CDMS_HK(); //collects temperatures RSSI_volatge = COMRX_RSSI_volatge.read() * 3.3;//to be checked - //gPC.printf("\n\rRSSI voltage = %f",RSSI_volatge); - VERIFY_COMRX(); + //VERIFY_COMRX(); VERIFY_RTC(); HANDLE_HW_FAULTS(); FUNC_CDMS_GPIO_STATUS(); uint8_t CDMS_quant[20]; + CDMS_quant[0]= COM_ADF_TMP+40; CDMS_quant[1]= (uint8_t)quant_data.CDMS_temp_quant; CDMS_quant[2]= (uint8_t)RSSI_volatge; CDMS_quant[3]= (uint8_t)(EPS_BTRY_VOLT*33*(62.0/11)); @@ -116,16 +116,18 @@ CDMS_HEALTH_DATA[122] = SD_LIB_BLK_CURRENT>>8; CDMS_HEALTH_DATA[122] = SD_LIB_BLK_CURRENT; - uint64_t time = FCTN_CDMS_RD_RTC() >> 7; //Reading Time from RTC + uint32_t time = FCTN_CDMS_RD_RTC() >> 7; //Reading Time from RTC for(int i = 124; i<128; i++) - CDMS_HEALTH_DATA[i] = time >> (i-124)*8; - gPC.printf("0x%d\n",time); - gPC.printf("HK ARCH TIME TAGGED"); + CDMS_HEALTH_DATA[i] = time >> (127-i)*8; + + gPC.printf("\t\t%d/%d/%d ",((time & 0x003E0000)>>17),((time & 0x03C00000)>>22),((time & 0x0C000000)>>26)+2016); + gPC.printf("%d:%d:%d\n",((time & 0x0001F000)>>12),((time & 0x00000FC0)>>6),(time & 0x0000003F)); + FCTN_SD_MNGR(); //Adding FSC & TMID to TM frame CDMS_HK_FRAME[0] = 0x20; - CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1; + CDMS_HK_FRAME[1] = (FSC_CURRENT[4]+1) >> 16; CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8; - CDMS_HK_FRAME[3] = (FSC_CURRENT[4]+1) >> 16; + CDMS_HK_FRAME[3] = FSC_CURRENT[4]+1; // gPC.printf("\n"); for(int i = 0; i<128; i++){ /*Adding actual CDMS Health data to TM frame*/ CDMS_HK_FRAME[i+4] = CDMS_HEALTH_DATA[i]; @@ -133,8 +135,8 @@ } // gPC.printf("\n"); uint16_t crc = crc16_gen(CDMS_HK_FRAME,132); /*Adding CRC to TM frame*/ + CDMS_HK_FRAME[132] = crc >> 8; CDMS_HK_FRAME[133] = crc; - CDMS_HK_FRAME[132] = crc >> 8; exor(CDMS_HK_FRAME); CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK); @@ -166,16 +168,16 @@ /*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] = time >> i; + BAE_HK[i] = time >> (3-i)*8; BAE_HK_FRAME[0] = 0x28; - BAE_HK_FRAME[1] = FSC_CURRENT[5]+1; + BAE_HK_FRAME[1] = (FSC_CURRENT[5]+1) >> 16; BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8; - BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16; + BAE_HK_FRAME[3] = FSC_CURRENT[5]+1; for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ BAE_HK_FRAME[4+i] = BAE_HK[i]; crc = crc16_gen(BAE_HK_FRAME,132); /*Adding CRC to TM frame*/ + BAE_HK_FRAME[132] = crc >> 8; BAE_HK_FRAME[133] = crc; - BAE_HK_FRAME[132] = crc >> 8; exor(BAE_HK_FRAME); BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK); BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135); @@ -232,8 +234,9 @@ beacon_array[133] = crc >> 8; bool y; y = FCTN_I2C_WRITE((char *)beacon_array,134); - if(y == 0) - gPC.printf("long Bcn sent\n\r"); + if(y == 0){ + //gPC.printf("long Bcn sent\n\r"); + } else gPC.printf("long Bcn not sent\r\n"); //gPC.printf("\rCompleted Beacon\n"); @@ -322,7 +325,7 @@ } else if(Iteration<14) { - resistance=24000*actual_data.temp_actual[Iteration]*3.3/(3.3-actual_data.temp_actual[Iteration]*3.3); + resistance=22000*actual_data.temp_actual[Iteration]*3.3/(3.3-actual_data.temp_actual[Iteration]*3.3); if(actual_data.temp_actual[Iteration]*3.3<1.47) //Document says 1.378 .Pls Check @@ -338,7 +341,10 @@ for(Iteration=0; Iteration<16; Iteration++) { if(Iteration<4) - quant_data.temp_quant[Iteration]=actual_data.temp_actual[Iteration] * 10; + { + quant_data.temp_quant[Iteration]=actual_data.temp_actual[Iteration]; + wait(0.001); + } else if(Iteration<14) quant_data.temp_quant[Iteration]=quantiz(tstart_thermistor,tstep_thermistor,actual_data.temp_actual[Iteration]); // quant_data.temp_quant[Iteration]=quantiz(0,1,actual_data.temp_actual[Iteration]); @@ -391,7 +397,7 @@ //EPS_V_D_EN_STATUS GPIO_STATUS=(COM_TX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<1)):(GPIO_STATUS)&(~((uint16_t)(0x1<<1))); // gPC.printf("%04x\n",GPIO_STATUS); - gPC.printf("\rBAE_OC STATE = %04x \n",GPIO_STATUS); + gPC.printf("\n\rBAE_OC STATE = %04x",GPIO_STATUS); } void VERIFY_COMRX()