📄 measure.lst
字号:
509 2 if( ivf>=55 ) {
510 3 _PcMode = EE_RGB_1080I;
511 3 }
512 2 else {
513 3 _PcMode = EE_RGB_1080I50A;
514 3 }
515 2 }
516 1 //====================== DTV 480i ==============================
517 1 else if(vpn>=264-40 && vpn<=264+35) {
518 2 #ifdef DEBUG_PC
519 2 dPrintf("\r\n=========== DTV 480i ===============: vpn:%4d, ivf:%4d", (WORD)vpn, (WORD)ivf);
520 2 #endif
521 2 _PcMode = EE_RGB_480I;
522 2 }
523 1 //====================== DTV 576i ==============================
524 1 else if(vpn>=314-14 && vpn<=314+50) {
525 2 #ifdef DEBUG_PC
526 2 dPrintf("\r\n============ DTV 576i ==============: vpn:%4d, ivf:%4d", (WORD)vpn, (WORD)ivf);
527 2 #endif
528 2 _PcMode = EE_RGB_576I;
529 2 }
530 1
531 1 //====================== PC XGA ================================
532 1 else if( vpn>=790 && vpn<=820 ) {
533 2 #ifdef DEBUG_PC
534 2 dPrintf("\r\n============ PC XGA ===============: vpn:%4d, ivf:%4d", (WORD)vpn, (WORD)ivf);
535 2 #endif
536 2 //InputSource = PC_XGA;
537 2 switch( ivf ) {
538 3 case 59: case 60: case 61: _PcMode = EE_XGA_60; break;
539 3 case 69: case 70: case 71: _PcMode = EE_XGA_70; break;
540 3 case 72: case 73: _PcMode = EE_XGA_72; break;
541 3 case 74: case 75: case 76: _PcMode = EE_XGA_75; break;
542 3 case 84: case 85: case 86: _PcMode = EE_XGA_85; break;
543 3 default: _PcMode = EE_PC_UNKNOWN; break;
544 3 }
545 2 }
546 1 //====================== PC 1152x864 ===========================
C51 COMPILER V7.50 MEASURE 04/01/2008 15:02:17 PAGE 10
547 1 else if( vpn>=850 && vpn<=1000 ) {
548 2 #ifdef DEBUG_PC
549 2 dPrintf("\r\n============ PC 1152x864 =========: vpn:%4d, ivf:%4d", (WORD)vpn, (WORD)ivf);
550 2 #endif
551 2 //InputSource = PC_SXGA;
552 2 switch( ivf ) {
553 3 case 59: case 60: case 61: _PcMode = EE_1152_60; break;
554 3 case 69: case 70: case 71: _PcMode = EE_1152_70; break;
555 3 case 74: case 75: case 76: _PcMode = EE_1152_75; break;
556 3 default: _PcMode = EE_PC_UNKNOWN; break;
557 3 }
558 2 }
559 1
560 1 //====================== PC SXGA ===============================
561 1 else if( vpn>=1024 && vpn<=1600 ) {
562 2 #ifdef DEBUG_PC
563 2 dPrintf("\r\n============ PC SXGA =========: vpn:%4d, ivf:%4d", (WORD)vpn, (WORD)ivf);
564 2 #endif
565 2 //InputSource = PC_SXGA;
566 2 switch( ivf ) {
567 3 case 59: case 60: case 61: _PcMode = EE_SXGA_60; break;
568 3 case 69: case 70: case 71: _PcMode = EE_SXGA_70; break;
569 3 case 74: case 75: case 76: _PcMode = EE_SXGA_75; break;
570 3 default: _PcMode = EE_PC_UNKNOWN; break;
571 3 }
572 2 }
573 1
574 1 #ifdef DEBUG_PC
575 1 if( _PcMode == EE_PC_UNKNOWN )
576 1 dPrintf("\r\nUnknown Input-- VPN:%d IVF:%d", vpn, ivf);
577 1 else
578 1 dPrintf("\r\nInput VPN(%d) IVF(%d) :%d(%s)", vpn, ivf, (WORD)_PcMode, PcModeStr[_PcMode] );
579 1 #endif
580 1
581 1 if( !PCMDATA[_PcMode].Support ) _PcMode = EE_PC_UNKNOWN;
582 1
583 1 return _PcMode;
584 1 }
585
586 WORD ConvertBasedOnInput(WORD dat)
587 {
588 1 DWORD dtmp;
589 1
590 1 if( IsBypassmode() ) return dat; // HHY 2.01
591 1
592 1 dtmp = PCMDATA[PcMode].PPF*100000L/dat; // from PPF-based to IPF-based
593 1 dtmp = PCMDATA[PcMode].IPF*100000L/dtmp; // NewHPN = OldHPN * (IPF/PPF)
594 1 return (WORD)dtmp;
595 1 }
596
597 //=============================================================================
598 // Search ADC Clock with measuring Phase
599 //=============================================================================
600 #ifdef AUTO_TUNE_CLOCK
WORD AutoTuneClock(void)
{
WORD low, high; // Test value range of plldiv
WORD i;
// BYTE phase, phasepeak, j;
WORD num, width;
#ifdef DEBUG_PC
C51 COMPILER V7.50 MEASURE 04/01/2008 15:02:17 PAGE 11
dPrintf("\r\n---Tune-Coarse Mode=%d", (WORD)PcMode);
#endif
//------ Set Test Range, Divide Range more detail
low = 10;
high = ConvertBasedOnInput( GetHPN() );
SetMeasureWindowH(low, high); //
low = 1;
high = GetVPN() - 1;
SetMeasureWindowV(low, high); //
low = PCMDATA[PcMode].low;
high = PCMDATA[PcMode].high;
#ifdef DEBUG_PC
dPrintf("\r\n===>>>>Get Divider Number=0x%4x to 0x%4x", (WORD)low, (WORD)high);
#endif
MeasureAndWait(3);
width = GetHend() - GetHstart() + 1;
SetCoarse( low );
MeasureAndWait(3);
low = GetHend() - GetHstart() + 1;
SetCoarse( high );
MeasureAndWait(3);
high = GetHend() - GetHstart() + 1;
if(( low > width ) || ( width > high ) ) return 0; // cannot adjustable in setting range...
for(i=PCMDATA[PcMode].low; i <= PCMDATA[PcMode].high; i+=4 ) { // increment by 4
SetCoarse(i);
MeasureAndWait(3);
width = GetHend() - GetHstart() + 1;
if ( width >= PCMDATA[PcMode].HAN ) return (i);
}
return num;
}
#endif
650
651 #ifdef AUTOTUNEPHASE
652 //-----------------------------------------------------------------------------
653 // Final Set ADC [PLL div], [Phase]
654 //-----------------------------------------------------------------------------
655 void AutoTunePhase(void)
656 {
657 1 BYTE i, j, peak_j;
658 1
659 1 dPuts("\r\n-------------Tune-Fine");
660 1
661 1 if( IsDTVInput() ) return;
662 1
663 1 j = GetPhaseCurrent() - 8; //- 0x20;
664 1
665 1 RGBPeak=0;
666 1 for(i=0; i<9; i++, j+=0x02) {
667 2
668 2 j=j%0x1f;
669 2 SetPhase(j); // if NO_INPUT stop
670 2 if( !GetPhaseRGB() ) return; //
C51 COMPILER V7.50 MEASURE 04/01/2008 15:02:17 PAGE 12
671 2
672 2 if(RGBPeak < PhaseRGB) {
673 3 RGBPeak = PhaseRGB;
674 3 peak_j = j;
675 3 dPuts("--peak");
676 3 }
677 2 else {
678 3 dPuts(" ");
679 3 }
680 2 }
681 1 SetPhase(peak_j);
682 1 }
683 #endif
684
685 //-----------------------------------------------------------------------------
686 // Measure VPN, HPN
687 // Calculate IVF, IHF
688 //-----------------------------------------------------------------------------
689 WORD GetHpnVpn(BYTE en)
690 {
691 1 WORD vpn, hpn, sync; //hsync, vsync;
692 1 BYTE SyncPol;
693 1
694 1 en = DebugLevel;
695 1 if( !en && DebugLevel ) DebugLevel = 0;
696 1
697 1 #ifdef DEBUG_PC
698 1 dPuts("\r\n------ GetHpnVpn()");
699 1 #endif
700 1 //----- Measurement Command -------------
701 1
702 1 if( !MeasureAndWait(3) ) { // field any...
703 2 #ifdef DEBUG_PC
704 2 dPrintf(" Error at GetHpnVpn ");
705 2 #endif
706 2 DebugLevel = en;
707 2 return 0;
708 2 }
709 1
710 1 //----- Get VPN -------------------------
711 1 vpn = GetVPN(); // VPN = V Period Num
712 1 sync = GetVSYNCPulse();
713 1 // in case of 8816 sync is same to vpn so I cannot use below....
714 1 // Polarity check
715 1 if( sync > (vpn/3) ) {
716 2 InvertVSYNCPolarity();
717 2 MeasureAndWait(3);
718 2 sync = GetVSYNCPulse();
719 2 #ifdef DEBUG_PC
720 2 dPrintf(" --->New VSYNC:%04x(%d)", sync, sync);
721 2 #endif
722 2 }
723 1 #ifdef DEBUG_PC
724 1 dPrintf("\r\n VPN:%04x(%d) VSYNC:%04x(%d)", vpn, vpn, sync, sync);
725 1 dPrintf("\r\n IHF:%08lx(%ld)", IHF, IHF);
726 1 #endif
727 1
728 1 //----- Get HPN ---------------------
729 1 hpn = GetHPN(); // HPN = H Period Num
730 1 sync = GetHSYNCPulse(); // H sync Pulse Width = HSYNC interval
731 1
732 1 #ifdef DEBUG_PC
C51 COMPILER V7.50 MEASURE 04/01/2008 15:02:17 PAGE 13
733 1 dPrintf("\r\n HPN:%04x(%d) HSYNC:%04x(%d)", hpn, hpn, sync, sync);
734 1 dPrintf("\r\n PPF:%08lx(%ld)", GetPPF(), GetPPF() );
735 1 #endif
736 1
737 1 if( sync >= (hpn/3) ) {
738 2 SyncPol = ReadDecoder(0x40); // INVERT SYNC POLARITY
739 2 if ( SyncPol & 0x04 ) // b'2 is HSYNC POL
740 2 SyncPol &= 0xfb;
741 2 else SyncPol |= 0x04;
742 2 WriteDecoder(0x40, SyncPol);
743 2
744 2 MeasureAndWait(3);
745 2 sync = GetHSYNCPulse(); // H sync Pulse Width = HSYNC interval
746 2 hpn = GetHPN(); // HPN = H Period Num
747 2 }
748 1
749 1 //----- Get New HPN -------------
750 1 IHF = (GetPPF()+hpn/2) / hpn; // IHF = PPF / HPN
751 1
752 1 //----- Get New VPN -------------
753 1 vpn = GetVPN();
754 1 IVF = (WORD)((IHF+vpn/2)/vpn); // IVF = IHF / VPN
755 1
756 1 #ifdef DEBUG_PC
757 1 dPrintf("\r\nIHF(New):%08lx(%ld)", IHF, IHF);
758 1 dPrintf("\r\nHPN(New):%04x(%d) HSYNC(New):%04x(%d)", hpn, hpn, sync, sync);
759 1 dPrintf("\r\nVPN(New):%04x(%d)", vpn, vpn);
760 1 dPrintf("\r\nIVF(New):%04x(%d)", IVF, IVF);
761 1 dPuts("\r\n-------");
762 1 #endif
763 1
764 1 DebugLevel = en;
765 1 return vpn;
766 1 }
767
768 //=============================================================================
769 // Return V active Start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -