ソースを参照

Shutdown Cnt 25초로 변경 (오실레이터 오차 감안)/ Shutdown 알고리즘 오류 수정

PYJ 4 年 前
コミット
5d92cb0386
共有3 個のファイルを変更した147 個の追加48 個の削除を含む
  1. 144 45
      Bluecell_Src/Bluecell_operate.c
  2. 1 1
      Inc/main.h
  3. 2 2
      Src/main.c

+ 144 - 45
Bluecell_Src/Bluecell_operate.c

@@ -6299,6 +6299,7 @@ void DET_LevelAlarmCheck(){
6299 6299
 
6300 6300
 
6301 6301
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
6302
+//        if(i == 0) continue;
6302 6303
         if( Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] > 0 ){
6303 6304
             if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true
6304 6305
                 && (LimitData_DL_Shutdown - 2 >= Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
@@ -6307,7 +6308,7 @@ void DET_LevelAlarmCheck(){
6307 6308
                 if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6308 6309
                     if(DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){// Nomal Operate
6309 6310
                         DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] = 0;
6310
-    //                    printf("DL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i],bluecell_Currdatastatus.DLO_Shutdown_Retry_Count2);
6311
+//                        printf("1DL%d_PATH : %d\r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i]);
6311 6312
                     }
6312 6313
                 }
6313 6314
             }else{
@@ -6322,7 +6323,7 @@ void DET_LevelAlarmCheck(){
6322 6323
                 if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6323 6324
                     if(DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){// Nomal Operate
6324 6325
                         DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] = 0;
6325
-    //                    printf("DL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i],bluecell_Currdatastatus.DLO_Shutdown_Retry_Count2);
6326
+//                        printf("2DL%d_PATH : %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i]);
6326 6327
                     }
6327 6328
                 }
6328 6329
             }else{
@@ -6330,30 +6331,64 @@ void DET_LevelAlarmCheck(){
6330 6331
             }
6331 6332
 
6332 6333
         }
6334
+#if 0 // PYJ.2020.10.23_BEGIN -- 
6335
+        printf("=========================Start============================================\r\n");
6336
+        printf("DL_PathStatus : %d \r\n",DL_PathStatus[DET_Alarm_DL1_Shutdown_Index ]);
6337
+        printf("LimitData_DL_Shutdown : %d \r\n",LimitData_DL_Shutdown);        
6338
+        printf("Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);        
6339
+        printf("MBIC_DL_ShutdownCount : %d \r\n",MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index ]);        
6340
+        printf("ADC_Alarm_DL_Normal_Shutdown_Set : %d \r\n",ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index]);                
6341
+        printf("=========================End============================================\r\n"); 
6342
+        HAL_Delay(500);
6343
+#endif // PYJ.2020.10.23_END -- 
6333 6344
     }
6334 6345
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
6346
+//        if(i != 0) continue;
6335 6347
         if( Res_Down_DL_dBm[DET_Alarm_UL1_Index + i] > 0 ){
6336 6348
             if(LimitData_DL_Shutdown <= Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6337 6349
     //            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6338 6350
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6351
+//                printf("Shutdown On 1\r\n");
6339 6352
             }
6340 6353
             else{
6341
-    //             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6342
-                  if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)
6354
+                if(LimitData_DL_Shutdown - 2 <= Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]
6355
+                    && MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index ] > 0 )
6356
+                {
6357
+                    ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6358
+//                    printf("Shutdown On 1_1\r\n");
6359
+                }
6360
+                else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){
6343 6361
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6362
+//                    printf("Shutdown Off 1\r\n");                  
6363
+                }
6344 6364
             }
6345 6365
         }else{
6346 6366
             if(LimitData_DL_Shutdown <= Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6347 6367
     //            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6348 6368
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6369
+//                    printf("Shutdown On 2\r\n");                      
6349 6370
             }
6350 6371
             else{
6351
-    //             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6352
-                  if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)
6372
+                if(LimitData_DL_Shutdown - 2 <= Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]
6373
+                    && MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index ] > 0 ){
6374
+                        ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6375
+//                        printf("Shutdown On 2_1\r\n");
6376
+                }
6377
+                else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){
6353 6378
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6379
+//                    printf("Shutdown Off 2\r\n");                                          
6380
+                }
6354 6381
             }
6355 6382
 
6356 6383
         }
6384
+#if 0 // PYJ.2020.10.23_BEGIN -- 
6385
+        printf("======================================================\r\n");
6386
+        printf("Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);
6387
+        printf("LimitData_DL_Shutdown : %d \r\n",LimitData_DL_Shutdown);
6388
+        printf("Res_Up_DL_dBm : %d \r\n",Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);   
6389
+        HAL_Delay(500);
6390
+#endif // PYJ.2020.10.23_END -- 
6391
+
6357 6392
     }
6358 6393
 
6359 6394
 //    printf("======================================================\r\n");
@@ -6434,36 +6469,104 @@ void DET_LevelAlarmCheck(){
6434 6469
     for(int i = 0 ; i < DET_Alarm_UL_Shutdown_Index_MAX; i++){
6435 6470
 //          if(i != 0)
6436 6471
 //                continue;
6472
+//         printf("================================================================\r\n");
6437 6473
         /*UL Shutdown Cnt plus Condition Check */
6438
-        if(LimitData_UL_Shutdown <= Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] 
6474
+        if(UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] > 0){ // Retry Cnt > 0 
6475
+
6476
+        
6477
+            if((LimitData_UL_Shutdown     <= Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] 
6478
+            || LimitData_UL_Shutdown - 2 < Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] )
6439 6479
             && UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){
6440
-          
6441
-//            printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
6442
-            ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6443
-//            printf("1 Shutdown threas hold : %d | Curr Meas : %d Shutdown UL %d | Alarm ON Count : %d\r\n",LimitData_UL_Shutdown,Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6480
+                ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6481
+                ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6482
+//                printf("1 Shutdown threas hold : %d \r\n",LimitData_UL_Shutdown);
6483
+//                printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
6484
+//                printf("Res_Down_UL_dBm : %d \r\n",Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]);                
6485
+//                printf("Res_Up_UL_dBm : %d \r\n",Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]);
6486
+//                printf("Shutdown UL %d \r\n ",i + 1);
6487
+//                printf("Alarm ON Count : %d\r\n",UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i]);
6488
+            }
6489
+            else{
6490
+                if(UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){ 
6491
+                    ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6492
+                    ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6493
+                    if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6494
+                        if(UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] > 0){// Nomal Operate
6495
+                            UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] = 0;
6496
+//                            printf("UL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i],bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
6497
+                        }
6498
+                    }
6499
+                }
6500
+                else{// Shutdown Off -> ON Recovery 
6501
+                    ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6502
+                    ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6503
+                }
6504
+//                printf("1 Shutdown threas hold : %d \r\n",LimitData_UL_Shutdown);
6505
+//                printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
6506
+//                printf("Res_Down_UL_dBm : %d \r\n",Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]);                         
6507
+//                printf("Res_Up_UL_dBm : %d \r\n",Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]);
6508
+//                printf("Shutdown UL %d \r\n ",i + 1);
6509
+//                printf("Alarm OFF Count : %d\r\n",UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i]);
6510
+            }
6511
+        }
6512
+        else{ // Retry Cnt == 0 ;
6513
+            if(LimitData_UL_Shutdown <= Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]
6514
+            && UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){
6515
+                ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6516
+                ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;                
6517
+//                printf("2 Shutdown threas hold : %d \r\n",LimitData_UL_Shutdown);
6518
+//                printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
6519
+//                printf(" Res_Up_UL_dBm : %d \r\n",Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]);
6520
+//                printf("Shutdown UL %d \r\n ",i + 1);
6521
+//                printf("Alarm ON Count : %d\r\n",UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i]);                
6522
+            }else{
6523
+                ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6524
+                ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;                
6525
+//                printf("2 Shutdown threas hold : %d \r\n",LimitData_UL_Shutdown);
6526
+//                printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
6527
+//                printf(" Res_Up_UL_dBm : %d \r\n",Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]);
6528
+//                printf("Shutdown UL %d \r\n ",i + 1);
6529
+//                printf("Alarm OFF Count : %d\r\n",UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i]);  
6530
+            }
6531
+
6444 6532
         }
6533
+#if 0 // PYJ.2020.10.23_BEGIN -- 
6445 6534
         else{
6446
-//            if(i != 0)
6447
-//                continue;  
6448 6535
             /*UL Shutdown Minus Condition Check */            
6449
-            if(LimitData_UL_Shutdown - 2 >= Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] || UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == false)
6536
+            if(UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] > 0
6537
+            && LimitData_UL_Shutdown - 2 <= Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]
6538
+            && *PathStatus == true){
6539
+//                ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6540
+                ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6541
+                if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6542
+                    if(UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] > 0){// Nomal Operate
6543
+                        UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] = 0;
6544
+                        printf("UL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i],bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
6545
+                    }
6546
+                }
6547
+                printf("2_1 Shutdown threas hold : %d \r\n Curr Meas : %d Shutdown UL %d \r\n Alarm ON Count : %d\r\n",LimitData_UL_Shutdown,Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6548
+            }
6549
+            else if(LimitData_UL_Shutdown - 2 >= Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]){
6450 6550
                 ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6451
-//                printf("ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] =  %d \r\n ",ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index ]);
6452
-//            printf("2 Shutdown threas hold : %d | Curr Meas : %d Shutdown UL %d | Alarm OFF Count : %d\r\n",LimitData_UL_Shutdown,Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6453
-            if(UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){
6551
+                ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6552
+                printf("2 Shutdown threas hold : %d \r\n Curr Meas : %d Shutdown UL %d \r\n Alarm OFF Count : %d\r\n",LimitData_UL_Shutdown,Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6553
+            }
6554
+            else if(UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){
6454 6555
                 ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
6455 6556
                 if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6456 6557
                     if(UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] > 0){// Nomal Operate
6457
-//                        if(i != 0)
6458
-//                            continue;                
6459 6558
                         UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] = 0;
6460
-//                        printf("UL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i],bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
6559
+                        printf("UL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i],bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
6461 6560
                     }
6462 6561
                 }
6463 6562
             }else{
6464 6563
                 ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6465
-            }            
6564
+                printf("3_0  Shutdown threas hold : %d \r\n Curr Meas : %d Shutdown UL %d | Alarm OFF Count : %d\r\n",LimitData_UL_Shutdown,Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6565
+            }        
6566
+            printf("3_1  Shutdown threas hold : %d \r\n Curr Meas : %d Shutdown UL %d  Count : %d\r\n",LimitData_UL_Shutdown,Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6466 6567
         }
6568
+#endif // PYJ.2020.10.23_END -- 
6569
+//        HAL_Delay(500);
6467 6570
     }
6468 6571
     
6469 6572
     /*
@@ -6487,7 +6590,6 @@ void DET_LevelAlarmCheck(){
6487 6590
             DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index + i] = 0;
6488 6591
 //            printf("OFF _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_Down_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
6489 6592
         }
6490
-#if 1 // PYJ.2020.06.22_BEGIN -- 
6491 6593
 #if 0 // PYJ.2020.06.22_BEGIN --
6492 6594
                 printf("ADC : %f LimitData_UL_High: %d Res_UL_dBm [%d] : %d ,Value : %d\r\n",
6493 6595
                 (UL_ADC[i * 2] << 8 | UL_ADC[i * 2 + 1]) * 0.001,
@@ -6495,7 +6597,6 @@ void DET_LevelAlarmCheck(){
6495 6597
                 DET_Alarm_UL1_Index + i,
6496 6598
                 Res_UL_dBm[DET_Alarm_UL1_Index + i],
6497 6599
                 ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
6498
-#endif // PYJ.2020.06.22_END -- 
6499 6600
 #endif // PYJ.2020.06.22_END -- 
6500 6601
         
6501 6602
     }    
@@ -8234,7 +8335,7 @@ void ALC_Alarm_TimerSet(uint8_t num,int16_t threshold,double CurrDet,int16_t Att
8234 8335
         
8235 8336
         if(CurrAtten + M_Atten <= -20){
8236 8337
             if(AlarmStatus[num] == false){
8237
-                if(threshold + 0.1 <= CurrDet){
8338
+                if(threshold + 0.6 <= CurrDet){
8238 8339
                     ALC_AlarmSet[num] = true;
8239 8340
 //                    printf("Alarm 1 ON   \r\n");
8240 8341
                 }else{
@@ -8487,7 +8588,7 @@ void ALC_Function(){ //DL
8487 8588
                             &bluecell_Currdatastatus.ATT_UL1_H,
8488 8589
                             &bluecell_Currdatastatus.bluecell_User_UL1_H,
8489 8590
                             &bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1);
8490
-#if 1 // PYJ.2020.07.16_BEGIN -- 
8591
+#if 0 // PYJ.2020.07.16_BEGIN -- 
8491 8592
         ALC_Package_Operate(&bluecell_Currdatastatus.ULO_P2_Level2_H,
8492 8593
                             &bluecell_Currdatastatus.ULO_Level2_H,
8493 8594
                             &Det_UL2.Table_Det_15_dBm_H,
@@ -8633,20 +8734,15 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8633 8734
         int Round_ResdBm_Ret =0;
8634 8735
         int16_t ResdBm = 0;
8635 8736
         double Temp_ResdBm = 0;
8636
-        static double Prev_ResdBm = 0;
8637
-        static uint8_t Prev_Dcrease_Increase_Status = 0;        
8638
-        static uint8_t Dcrease_Increase_Status = 0;
8639 8737
         int16_t CurrAtten = 0;
8640 8738
         int16_t Levelret = 0;
8641 8739
         int i = 0;
8642 8740
         int16_t Limitdata = 0;
8643 8741
         int16_t IwillgiveAtten = 0;
8644
-        static int16_t PrevIwillgiveAtten = 0;        
8645 8742
         int16_t ResultData = 0;
8646 8743
         int8_t* AGC_Table;// = &DL_DET_Table_ref[MBIC_Table_DL1_INDEX][TABLE_MAX_VALUE];
8647 8744
         int16_t FRBT_Atten = 0;
8648
-        static int16_t RefValue = 0;
8649
-        static int8_t Gurantee = 0;
8745
+        static int16_t RefValue[AGC_Alarm_DL_Index_MAX] = {0,};
8650 8746
         FRBT_Atten =  FRBT[DLI_AGC_H] << 8 | FRBT[DLI_AGC_L];   
8651 8747
         FRBT_Atten *= 0.1;
8652 8748
         
@@ -8689,24 +8785,24 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8689 8785
             printf("222 WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8690 8786
 
8691 8787
             printf("Round_ResdBm_Ret : %d \r\n",Round_ResdBm_Ret);
8692
-            printf("RefValue : %d \r\n",RefValue);            
8788
+            printf("RefValue : %d \r\n",RefValue[Tableindex]);            
8693 8789
 #endif // PYJ.2020.10.23_END -- 
8694 8790
 
8695
-            if(Round_ResdBm_Ret < RefValue + 0.5 && RefValue != 0){
8791
+            if(Round_ResdBm_Ret < RefValue[Tableindex] + 0.5 && RefValue[Tableindex] != 0){
8696 8792
                 
8697 8793
                 
8698 8794
             }else{
8699 8795
 #if AGC_PRINT // PYJ.2020.10.23_BEGIN -- 
8700
-                        printf("1Curr ATTEN %d \r\n",CurrAtten );
8701
-                        printf("Current DL% ADC VALUE : %f \r\n",Tableindex+1,ret);
8702
-                        printf("Temp_ResdBm : DL%d : %f \r\n",Tableindex+1,Temp_ResdBm);
8703
-                        printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8704
-                        printf("AGC  : %d\r\n",Limitdata);
8796
+                printf("1Curr ATTEN %d \r\n",CurrAtten );
8797
+                printf("Current DL% ADC VALUE : %f \r\n",Tableindex+1,ret);
8798
+                printf("Temp_ResdBm : DL%d : %f \r\n",Tableindex+1,Temp_ResdBm);
8799
+                printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8800
+                printf("AGC  : %d\r\n",Limitdata);
8705 8801
 #endif // PYJ.2020.10.23_END -- 
8706
-                RefValue = Round_ResdBm_Ret;
8802
+                RefValue[Tableindex] = Round_ResdBm_Ret;
8707 8803
                 return;
8708 8804
             }
8709
-            if(Round_ResdBm_Ret > RefValue - 1.5  && RefValue != 0){
8805
+            if(Round_ResdBm_Ret > RefValue[Tableindex] - 1.5  && RefValue[Tableindex] != 0){
8710 8806
                 if(CurrAtten < (IwillgiveAtten * -1)){
8711 8807
                     if(((Limitdata + (CurrAtten * -1)) - 1.5) <= Temp_ResdBm){
8712 8808
 #if AGC_PRINT // PYJ.2020.10.23_BEGIN -- 
@@ -8729,7 +8825,7 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8729 8825
         printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8730 8826
         printf("AGC  : %d\r\n",Limitdata);
8731 8827
 #endif // PYJ.2020.10.23_END --                 
8732
-                RefValue = Round_ResdBm_Ret;
8828
+                RefValue[Tableindex] = Round_ResdBm_Ret;
8733 8829
                 return;
8734 8830
 
8735 8831
             }
@@ -8923,13 +9019,16 @@ void AGC_Function(){//DL
8923 9019
         for(int k = 0; k < AGC_Alarm_DL_Index_MAX; k++){
8924 9020
 //            if(k != 0) continue;
8925 9021
             ResdBm = (int16_t)(DLI_Level[DLI_AGC_H + (k * 2)] << 8 |  DLI_Level[DLI_AGC_L + ((k * 2))]) * 10;
8926
-        
9022
+//            printf("============================================\r\n");
9023
+//            bluecell_Currdatastatus.DLI_FRBT_Status = FRBT_IDEL;
8927 9024
 //            printf("Limitdata : %d   ResdBm : %d \r\n",Limitdata * 100,ResdBm);
8928 9025
             if(DL_Curr_Atten[AGC_Alarm_DL1_Index+k] <= -150)
8929 9026
                 DL_Curr_Atten[AGC_Alarm_DL1_Index+k] = -150;
8930 9027
 //            printf("DL_Curr_Atten%d : %d \r\n",k+1,DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1);
8931
-            if(((DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1) <= -15) && ((Limitdata * 100) < ResdBm - 1500)   ){
8932
-//                printf("DL_Curr_Atten%d : %d Alarm TRue\r\n",k+1,DL_Curr_Atten[AGC_Alarm_DL1_Index+k]);
9028
+            if(((DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1) <= -15) && ((Limitdata * 100) + 50 < ResdBm - 1500)   ){
9029
+//                printf("DL_Curr_Atten%d : %d  Alarm True\r\n",k+1,DL_Curr_Atten[AGC_Alarm_DL1_Index+k]);
9030
+//                printf("Limitdata : %d \r\n",Limitdata * 100);
9031
+//                printf("ResdBm : %d \r\n",ResdBm);            
8933 9032
                 AGC_AlarmSet[AGC_Alarm_DL1_Index+k] = true;
8934 9033
             }else{
8935 9034
                 if(AGC_AlarmStatus[AGC_Alarm_DL1_Index+k] == true){
@@ -9343,7 +9442,7 @@ void UL_Shutdown_Operate(uint8_t Index,uint8_t* Path,uint8_t* PrevATT,uint8_t* R
9343 9442
     }
9344 9443
     else{
9345 9444
         if(DET_UL_Shutdown_Off_AlarmTimerCnt[Index] >= MBIC_OFF_MAINTAIN_SEC
9346
-            && (*RetryCnt) != RETRYCNT_MAX){
9445
+            && (*RetryCnt) != RETRYCNT_MAX){ 
9347 9446
             bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~AlarmFlag;
9348 9447
             *ShutdownAlarm       = false;            
9349 9448
         }

+ 1 - 1
Inc/main.h

@@ -184,7 +184,7 @@ extern I2C_HandleTypeDef hi2c2;
184 184
 /* USER CODE BEGIN Private defines */
185 185
 #define MBIC_ON_MAINTAIN_SEC 3000
186 186
 #define MBIC_ON_SHUTDOWN_MAINTAIN_SEC 5000//5
187
-#define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 25000//30
187
+#define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 20000//30
188 188
 #define MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC 52000 * 5 //5min
189 189
 #define MBIC_RECOVERY_SELFTEST_TIMER_SEC 1800000 //30min
190 190
 

+ 2 - 2
Src/main.c

@@ -273,8 +273,8 @@ uint8_t MBICTest_Firmdata[8]  = {1,2,3,4,5,6,7,8};
273 273
   * @retval int
274 274
   */
275 275
 int main(void)
276
-{
277
-  /* USER CODE BEGIN 1 */
276
+  {
277
+  /* USER CODE BE1GIN 1 */
278 278
 
279 279
 
280 280
   /* USER CODE END 1 */