To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Revision 328:2242ebc71be8, committed 2016-12-20
- Comitter:
- chaithanyarss
- Date:
- Tue Dec 20 08:36:41 2016 +0000
- Parent:
- 327:5a967a66c10f
- Child:
- 329:a43494bb338f
- Commit message:
- changed ADF temperature calibration; testing OBSRS
Changed in this revision
--- 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()
--- a/FMS_all.h Fri Dec 16 08:53:12 2016 +0000 +++ b/FMS_all.h Tue Dec 20 08:36:41 2016 +0000 @@ -1,3 +1,5 @@ +#ifndef FMS_ALL_INCLUDED +#define FMS_ALL_INCLUDED // Includes MMS RAM functions also @@ -359,10 +361,12 @@ tm_pointer->TM_string[i+26] = (uint8_t)min_max_data.temp_min[i]; } - tm_pointer->TM_string[47] = GPIO_STATUS &0xFF00; - tm_pointer->TM_string[48] |= (GPIO_STATUS<<11) & 0xF000; + tm_pointer->TM_string[42] = GPIO_STATUS>>8; + tm_pointer->TM_string[43] = (GPIO_STATUS<<3) & 0x00FF; TIME_LATEST_RTC= FCTN_CDMS_RD_RTC() >> 7; for(int i = 0; i<4; i++) - tm_pointer->TM_string[48+i] = TIME_LATEST_RTC >> (3-i)*8; -} \ No newline at end of file + tm_pointer->TM_string[44+i] = TIME_LATEST_RTC >> (3-i)*8; +} + +#endif \ No newline at end of file
--- a/OBSRS.h Fri Dec 16 08:53:12 2016 +0000 +++ b/OBSRS.h Tue Dec 20 08:36:41 2016 +0000 @@ -56,7 +56,7 @@ uint8_t T_frame_Ack_andcallsign_sent = 0; uint8_t T_frame_in_Ackandcallsign ; // needs to get from sukhdeep depends on size of Ack_L1 uint32_t block_counter = 0; -uint8_t no_of_frames =0; +uint16_t no_of_frames =0; //#define max_segments = 65415/(48+T_frames_in_segment*159) // data 288 byte with convolution without xoring 0x38,0x90,0x7B,0x40,0x01,0x56,0x45,0xE0,0x3C,0xA0,0x7A,0x90,0x3D,0xE6,0x3E,0x70,0x21,0x42,0x43,0x3C,0x0C,0x20,0x00,0x4C,0x83,0x12,0x67,0xF0,0x8F,0x36,0x60,0x3C,0x86,0x24,0x06,0x80,0x20,0x54,0x22,0x9C,0x07,0x2A,0x00,0x8C,0x0F,0x7A,0x25,0x50,0x88,0x50,0x5F,0x8C,0xAB,0x0A,0x7A,0xCC,0x10,0xC4,0x25,0x10,0xB3,0xCE,0x5F,0x40,0xA1,0x8A,0x05,0xD0,0x90,0x14,0x7E,0x00,0x09,0xCA,0x7F,0xA0,0x1B,0xDE,0x00,0x70,0x12,0x14,0x7D,0x50,0x2A,0xC0,0x7D,0x20,0x14,0x30,0x04,0x4C,0x3C,0xF0,0x02,0xEC,0x28,0x60,0x45,0xA0,0x04,0x04,0x47,0x1C,0x22,0x70,0x02,0xE0,0x26,0xF4,0x41,0xFC,0x04,0x84,0x04,0x9C,0x0A,0xB0,0x41,0x40,0x25,0x0C,0xBF,0x9C,0x2F,0x3C,0xF8,0x5C,0x0A,0x18,0x4A,0xC0,0x21,0x00,0xB2,0x80,0x58,0x9C,0x8A,0x00,0x79,0xBC,0x7D,0x00,0x10,0x28,0x3E,0x3C,0x46,0x94,0x7D,0xB8,0x21,0x20,0x42,0x04,0x77,0xB4,0xB7,0x84,0x53,0x94,0x03,0xA0,0x20,0x08,0xF4,0x00,0x47,0x34,0xF7,0x60,0x63,0x3C,0x01,0xC0,0x24,0x08,0xF3,0xA0,0x11,0xA0,0xF3,0x60,0x68,0x48,0x08,0xB8,0x7D,0xE8,0x0D,0xF8,0x14,0xE0,0x83,0xC0,0x48,0x00,0x8E,0xB8,0x91,0xC8,0x05,0x40,0xD8,0xC8,0x8B,0xF8,0xC9,0x00,0x0D,0x38,0x04,0x68,0x86,0x80,0x9A,0x11,0x7B,0xB8,0x9F,0x79,0xF8,0x38,0x05,0x38,0x99,0x80,0xD2,0x01,0x69,0x80,0x24,0x71,0x14,0x80,0xF6,0x30,0xFE,0x80,0x72,0x41,0xE9,0x00,0x01,0x19,0x17,0x80,0xE6,0x81,0xEA,0x40,0x67,0xD8,0xFD,0xC0,0x81,0x48,0x1E,0xF0,0x34,0x81,0x13,0x30,0x09,0x19,0x8D,0xC8,0xBD,0x88,0x84,0xF8,0x9C,0x90,0x1C,0x00,0x00,0x41,0x8C,0x78,0x39,0xA9,0x12,0x30,0x19,0xF8,0x87,0x48 @@ -659,8 +659,8 @@ FSC += tcp->TC_string[4] << 16; FSC += tcp->TC_string[5] << 8; FSC += tcp->TC_string[6]; - no_of_frames = tcp->TC_string[7] << 8; - no_of_frames += tcp->TC_string[8]; + no_of_frames = ((uint16_t)(tcp->TC_string[7]) << 8); + no_of_frames |= (uint16_t)tcp->TC_string[8]; } else{ no_of_frames = tcp->TC_string[3];
--- a/adf.h Fri Dec 16 08:53:12 2016 +0000 +++ b/adf.h Tue Dec 20 08:36:41 2016 +0000 @@ -249,9 +249,7 @@ spi.write(0x59); spi.write(0x08); gCS_ADF=1; - uint16_t sum_temp = 0; - for(int i =0; i< 10;i++) - { + gCS_ADF=0; spi.write(0x3B); spi.write(0x27); @@ -270,12 +268,12 @@ spi.write(0xFF); secondbyte = spi.write(0xFF); gCS_ADF=1; - COM_ADF_TMP = firstbyte<<6; - COM_ADF_TMP += secondbyte; - COM_ADF_TMP = (COM_ADF_TMP/1.83) - 118.43 + temp_correction_value; - sum_temp+=COM_ADF_TMP; - } - COM_ADF_TMP = sum_temp/10; + + COM_ADF_TMP = firstbyte & 0x03; + COM_ADF_TMP |= secondbyte & 0xfc; + COM_ADF_TMP = 0.9474*(COM_ADF_TMP - 28) +28.2; + + gPC.printf("\n\rCOM_ADF_TMP : %d",COM_ADF_TMP); uint8_t txcurr = (3.3*COM_TX_OC_FAULT)/(0.05)*100; }
--- a/cdms_sd.h Fri Dec 16 08:53:12 2016 +0000 +++ b/cdms_sd.h Tue Dec 20 08:36:41 2016 +0000 @@ -1,3 +1,6 @@ +#ifndef CDMS_SD_INLCUDED +#define CDMS_SD_INLCUDED + //SPI spi(PTE1, PTE3, PTE2); // MOSI,MISO, CLOCK microcontroller(in order) //DigitalOut cs_sd(PTE22); @@ -6,7 +9,7 @@ #define SD_COMMAND_TIMEOUT 325 -#define SD_DBG 0 +#define SD_DBG 1 #define R1_IDLE_STATE (1 << 0) #define R1_ERASE_RESET (1 << 1) @@ -18,7 +21,6 @@ uint32_t SD_DATABLOCK_START[] = {0, 1001, 11001, 21001, 31001, 41001}; uint32_t SD_DATABLOCK_END[] = {0, 11000, 21000, 31000, 41000, 51000}; - uint32_t SD_MNG_SECT=80000; extern uint8_t SD_INIT_FLAGS; @@ -109,114 +111,27 @@ disk_write(buffer,SD_MNG_SECT); disk_read(buffer,SD_MNG_SECT); - if(sid==0x01) { - fsc=(uint32_t)(buffer[0]<<24)+(uint32_t)(buffer[1]<<16)+(uint32_t)(buffer[2]<<8)+(uint32_t)buffer[3]; - fsc_old=(uint32_t)(buffer[4]<<24)+(uint32_t)(buffer[5]<<16)+(uint32_t)(buffer[6]<<8)+(uint32_t)buffer[7]; + if(sid>=0x01 && sid <=0x05) + { + fsc=(uint32_t)(buffer[0 + ((sid-1)*8)]<<24)+(uint32_t)(buffer[1 + ((sid-1)*8)]<<16)+(uint32_t)(buffer[2 + ((sid-1)*8)]<<8)+(uint32_t)buffer[3 + ((sid-1)*8)]; + fsc_old=(uint32_t)(buffer[4 + ((sid-1)*8)]<<24)+(uint32_t)(buffer[5 + ((sid-1)*8)]<<16)+(uint32_t)(buffer[6 + ((sid-1)*8)]<<8)+(uint32_t)buffer[7 + ((sid-1)*8)]; fsc++; - buffer[0]=(uint8_t) (fsc>>24 & 0xFF); - buffer[1]=(uint8_t) (fsc>>16 & 0xFF); - buffer[2]=(uint8_t) (fsc>>8 & 0xFF); - buffer[3]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_DATABLOCK_END[1]-SD_DATABLOCK_START[1]+1) { + buffer[0 + ((sid-1)*8)]=(uint8_t) (fsc>>24 & 0xFF); + buffer[1 + ((sid-1)*8)]=(uint8_t) (fsc>>16 & 0xFF); + buffer[2 + ((sid-1)*8)]=(uint8_t) (fsc>>8 & 0xFF); + buffer[3 + ((sid-1)*8)]=(uint8_t) (fsc & 0xFF); + if(fsc > SD_DATABLOCK_END[sid]-SD_DATABLOCK_START[sid]+1) { fsc_old = fsc_old+1; - buffer[4]=(uint8_t) (fsc_old>>24 & 0xFF); - buffer[5]=(uint8_t) (fsc_old>>16 & 0xFF); - buffer[6]=(uint8_t) (fsc_old>>8 & 0xFF); - buffer[7]=(uint8_t) (fsc_old & 0xFF); + buffer[4 + ((sid-1)*8)]=(uint8_t) (fsc_old>>24 & 0xFF); + buffer[5 + ((sid-1)*8)]=(uint8_t) (fsc_old>>16 & 0xFF); + buffer[6 + ((sid-1)*8)]=(uint8_t) (fsc_old>>8 & 0xFF); + buffer[7 + ((sid-1)*8)]=(uint8_t) (fsc_old & 0xFF); } i = disk_write(buffer,SD_MNG_SECT); if(i == 0) { - FSC_CURRENT[1] = fsc; - FSC_OLD[1] = fsc_old; - return i; - } - } - if(sid==0x02) { - fsc=(uint32_t)(buffer[8]<<24)+(uint32_t)(buffer[9]<<16)+(uint32_t)(buffer[10]<<8)+(uint32_t)buffer[11]; - fsc_old=(uint32_t)(buffer[12]<<24)+(uint32_t)(buffer[13]<<16)+(uint32_t)(buffer[14]<<8)+(uint32_t)buffer[15]; - fsc++; - buffer[8]=(uint8_t) (fsc>>24 & 0xFF); - buffer[9]=(uint8_t) (fsc>>16 & 0xFF); - buffer[10]=(uint8_t) (fsc>>8 & 0xFF); - buffer[11]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_DATABLOCK_END[2]-SD_DATABLOCK_START[2]+1) { - fsc_old = fsc_old+1; - buffer[12]=(uint8_t) (fsc_old>>24 & 0xFF); - buffer[13]=(uint8_t) (fsc_old>>16 & 0xFF); - buffer[14]=(uint8_t) (fsc_old>>8 & 0xFF); - buffer[15]=(uint8_t) (fsc_old & 0xFF); - } - i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) { - FSC_CURRENT[2] = fsc; - FSC_OLD[2] = fsc_old; - return i; - } - } - if(sid==0x03) { - fsc=(uint32_t)(buffer[16]<<24)+(uint32_t)(buffer[17]<<16)+(uint32_t)(buffer[18]<<8)+(uint32_t)buffer[19]; - fsc_old=(uint32_t)(buffer[20]<<24)+(uint32_t)(buffer[21]<<16)+(uint32_t)(buffer[22]<<8)+(uint32_t)buffer[23]; - fsc++; - buffer[16]=(uint8_t) (fsc>>24 & 0xFF); - buffer[17]=(uint8_t) (fsc>>16 & 0xFF); - buffer[18]=(uint8_t) (fsc>>8 & 0xFF); - buffer[19]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_DATABLOCK_END[3]-SD_DATABLOCK_START[3]+1) { - fsc_old = fsc_old+1; - buffer[20]=(uint8_t) (fsc_old>>24 & 0xFF); - buffer[21]=(uint8_t) (fsc_old>>16 & 0xFF); - buffer[22]=(uint8_t) (fsc_old>>8 & 0xFF); - buffer[23]=(uint8_t) (fsc_old & 0xFF); - } - i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) { - FSC_CURRENT[3] = fsc; - FSC_OLD[3] = fsc_old; - return i; - } - } - if(sid==0x04) { - fsc=(uint32_t)(buffer[24]<<24)+(uint32_t)(buffer[25]<<16)+(uint32_t)(buffer[26]<<8)+(uint32_t)buffer[27]; - fsc_old=(uint32_t)(buffer[28]<<24)+(uint32_t)(buffer[29]<<16)+(uint32_t)(buffer[30]<<8)+(uint32_t)buffer[31]; - fsc++; - buffer[24]=(uint8_t) (fsc>>24 & 0xFF); - buffer[25]=(uint8_t) (fsc>>16 & 0xFF); - buffer[26]=(uint8_t) (fsc>>8 & 0xFF); - buffer[27]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_DATABLOCK_END[4]-SD_DATABLOCK_START[4]+1) { - fsc_old = fsc_old+1; - buffer[28]=(uint8_t) (fsc_old>>24 & 0xFF); - buffer[29]=(uint8_t) (fsc_old>>16 & 0xFF); - buffer[30]=(uint8_t) (fsc_old>>8 & 0xFF); - buffer[31]=(uint8_t) (fsc_old & 0xFF); - } - i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) { - FSC_CURRENT[4] = fsc; - FSC_OLD[4] = fsc_old; - return i; - } - } - if(sid==0x05) { - fsc=(uint32_t)(buffer[32]<<24)+(uint32_t)(buffer[33]<<16)+(uint32_t)(buffer[34]<<8)+(uint32_t)buffer[35]; - fsc_old=(uint32_t)(buffer[36]<<24)+(uint32_t)(buffer[37]<<16)+(uint32_t)(buffer[38]<<8)+(uint32_t)buffer[39]; - fsc++; - buffer[32]=(uint8_t) (fsc>>24 & 0xFF); - buffer[33]=(uint8_t) (fsc>>16 & 0xFF); - buffer[34]=(uint8_t) (fsc>>8 & 0xFF); - buffer[35]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_DATABLOCK_END[5]-SD_DATABLOCK_START[5]+1) { - fsc_old = fsc_old+1; - buffer[36]=(uint8_t) (fsc_old>>24 & 0xFF); - buffer[37]=(uint8_t) (fsc_old>>16 & 0xFF); - buffer[38]=(uint8_t) (fsc_old>>8 & 0xFF); - buffer[39]=(uint8_t) (fsc_old & 0xFF); - } - i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) { - FSC_CURRENT[5] = fsc; - FSC_OLD[5] = fsc_old; + FSC_CURRENT[sid] = fsc; + FSC_OLD[sid] = fsc_old; return i; } } @@ -693,4 +608,6 @@ // receive the data return read(buffer,64); -} \ No newline at end of file +} + +#endif \ No newline at end of file
--- a/crc.h Fri Dec 16 08:53:12 2016 +0000 +++ b/crc.h Tue Dec 20 08:36:41 2016 +0000 @@ -1,3 +1,5 @@ +#ifndef CRC_H_INCLUDED +#define CRC_H_INCLUDED //EDITS //changed the initial remainder from 0x0000 to 0xffff according to the standards //made two seperate functions crc16_gen and crc8_gen @@ -74,4 +76,6 @@ } return remainder; -} \ No newline at end of file +} + +#endif \ No newline at end of file
--- a/i2c.h Fri Dec 16 08:53:12 2016 +0000 +++ b/i2c.h Tue Dec 20 08:36:41 2016 +0000 @@ -112,7 +112,7 @@ } if(((pdirr1 & 0x03000000)==0x03000000))//if SCL and SDA are both high { - gPC.printf("\n\rData received from BAE"); + //gPC.printf("\n\rData received from BAE"); } else { @@ -148,7 +148,7 @@ } if(((pdirw1 & 0x03000000)==0x03000000)) { - gPC.printf("\n\r Data sent"); + //gPC.printf("\n\r Data sent"); } else {