autoadj.lst

来自「台湾联咏NT68663 LCD MONITOR 控制程序(完整版)」· LST 代码 · 共 1,606 行 · 第 1/5 页

LST
1,606
字号
C51 COMPILER V6.12  AUTOADJ                                                                03/05/2008 14:11:12 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE AUTOADJ
OBJECT MODULE PLACED IN .\BIN\AutoAdj.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE .\SRC\AutoAdj.C OPTIMIZE(9,SIZE) DEFINE(X17,TW2600XW02) DEBUG OBJECTEXTEND 
                    -PRINT(.\LST\AutoAdj.lst) OBJECT(.\BIN\AutoAdj.obj) 

stmt level    source

   1          #include "8051.H"
   2          #include "MATH.H"
   3          #include "Scaler.H"
   4          #include "AutoAdj.H"
   5          #include "MyDef.H"
   6          #include "IIC.H"
   7          #include "RAM.H"
   8          #include "stdio.h"
   9          #include "F63XREG.H"
  10          #include "F63XDEF.H"
  11          #include "MCU.H"
  12          #include "UserAdj.H"
  13          #include "ModeHandle.H"
  14          #include "ROM_MAP.H"
  15          #include "OSD.H"
  16          
  17          void TunePositionOnly()
  18          {
  19   1      	Abort = 0;
  20   1      	WriteIIC563(0x001,FuncBuf[pRADC]);
  21   1      	WriteIIC563(0x004,FuncBuf[pGADC]);
  22   1      	WriteIIC563(0x007,FuncBuf[pBADC]);
  23   1      	AutoPosition();
  24   1      	if(Abort)
  25   1      		{	//fail
  26   2      		LoadModeDependentSettings();
  27   2      		SetHP();
  28   2      		SetVP();
  29   2      		#if PRINT_MESSAGE
              			printf("Auto Position fail\n");
              		#endif
  32   2      		}
  33   1      	else{		//ok
  34   2      		SaveModeDependentSettings();
  35   2      		#if PRINT_MESSAGE
              			printf("Auto Position OK\n");
              		#endif
  38   2      		}
  39   1      	SetContrast();
  40   1      }
  41          
  42          void AutoTune(void)
  43          {
  44   1      	Word addr;
  45   1      //	Byte PixelRate;
  46   1      	Abort = 0;
  47   1      	NonFullScreen = 0;
  48   1      	WriteIIC563(0x001,FuncBuf[pRADC]);
  49   1      	WriteIIC563(0x004,FuncBuf[pGADC]);
  50   1      	WriteIIC563(0x007,FuncBuf[pBADC]);
  51   1      //	if(ModePoint < UserModeSt)
  52   1      //		Recall();
  53   1      	WriteIIC563(0x06a,0x00);	//jacky 20050426 disable de-jitter
  54   1      	//WriteIIC563(0x069,0x00);	//jacky 20050426 disable NR
C51 COMPILER V6.12  AUTOADJ                                                                03/05/2008 14:11:12 PAGE 2   

  55   1      	//WriteIIC563(0x06b,0x00);	//jacky 20050426 disable NR
  56   1      	AutoPosition();
  57   1      	if(!Abort)
  58   1      		AutoClock();
  59   1      //	PixelRate = ((unsigned long)FuncBuf[pCLOCK] * H_SYNC)/10000;
  60   1      //	if(PixelRate >= PanelMaxPClk/1000)
  61   1      //		Abort = 1;
  62   1      	if(NonFullScreen && !Abort)	//non fullscreen recall
  63   1      		{
  64   2      		//addr = ep_Sync_Data + (ModePoint * 8);
  65   2      		//FuncBuf[pCLOCK] = Read24C16(addr+4) << 8;
  66   2      		//FuncBuf[pCLOCK] |= Read24C16(addr+5);
  67   2      		LoadPresetModeSettings(2);
  68   2      		SetADC_PLL();
  69   2      		}
  70   1      	CheckAnyKey();
  71   1      #if 0
              	if(Abort){
              		if(NonFullScreen == 0){
              			//goto Error;
              		}
              		else{
              			Abort = 0;
              			AutoClockByPhase(1);
              		}
              	}
              	else{
              		AutoClockByPhase(0);
              	}
              #else
  85   1      	if(!Abort)
  86   1      		AutoClockByPhase(0);
  87   1      #endif
  88   1      	CheckAnyKey();
  89   1      	if(!Abort)
  90   1      		AutoPhaseFineTune(16);
  91   1      	CheckAnyKey();
  92   1      	if(!Abort)
  93   1      		AutoPosition();
  94   1      	CheckAnyKey();
  95   1      	WriteIIC563(0x06a,0xd2);	//jacky 20050426 enable de-jitter
  96   1      	//WriteIIC563(0x069,0x43);	//jacky 20050426 enable NR
  97   1      	//WriteIIC563(0x06b,0x03);	//jacky 20050426 enable NR
  98   1      	if(Abort)
  99   1      		{	//fail
 100   2      		Osd_Off();
 101   2      		//if(ModePoint < UserModeSt)
 102   2      		//	addr = ModePoint * 8;
 103   2      		//else
 104   2      		//	addr = UserModeRefReso * 8;
 105   2      		LoadPresetModeSettings(0);
 106   2      		//LoadModeDependentSettings();
 107   2      		SetADC_PLL();
 108   2      		SetADC_Phase();
 109   2      //-------------------------------------------------------
 110   2      		if(SyncMode != 3)
 111   2      			{
 112   3      			SetHP();
 113   3      			SetVP();
 114   3      			}
 115   2      		if(Interlance){
 116   3      			WriteWordIIC563(0x032,Vresolution);		// Capture V_Active
C51 COMPILER V6.12  AUTOADJ                                                                03/05/2008 14:11:12 PAGE 3   

 117   3      		}
 118   2      		else{
 119   3      			WriteWordIIC563(0x032,Vresolution); 	// Capture V_Active
 120   3      		}
 121   2      		WriteWordIIC563(0x036,Hresolution); 	// Capture H_Active
 122   2      		//WriteWordIIC563(0x036,Hresolution + H_ActErrTab[ResolutionPtr]); 	// Capture H_Active
 123   2      		//SetScaler();
 124   2      		//--------------------------------------------------
 125   2      		addr = ep_Reso_Offset + (ModePoint * 8);
 126   2      		Write24C16(addr,Read24C16(addr));
 127   2      		//Write24C16(addr,(Read24C16(addr) & 0x7f));
 128   2      		#if PRINT_MESSAGE
              			printf("AutoTune fail\n");
              		#endif
 131   2      		}
 132   1      	else{		//ok
 133   2      		Osd_Off();
 134   2      		SaveModeDependentSettings();
 135   2      		//Range.Hpos_Ref = FuncBuf[pHPOSITION];
 136   2      		//Range.Vpos_Ref = (Byte)FuncBuf[pVPOSITION];
 137   2      		//Range.Clock_Ref = FuncBuf[pCLOCK];
 138   2      		//SaveRangeRef();
 139   2      		Write24C16(ep_Reso_Offset + (ModePoint * 8), ResolutionPtr|0x80);
 140   2      		#if PRINT_MESSAGE
              			printf("AutoTune OK\n");
              		#endif
 143   2      		}
 144   1      	LoadADC_Gain();
 145   1      }
 146          #if 0
              void AutoPosition(void)
              {
              	Byte temp;
              	#if PRINT_MESSAGE
              		printf("AutoPosition\n");
              	#endif
              	WriteIIC563(0x02A,0);  // AutoPosition Pixel mask -> H
              	WriteIIC563(0x02B,24);  // AutoPosition Pixel mask -> H
              	WriteIIC563(0x02C,0x00);  // AutoPosition Pixel mask -> H
              	WriteIIC563(0x02D,0x00);  // AutoPosition Pixel mask -> H
              	WriteIIC563(0x107,0x30);  // Red Noise Margin
              	WriteIIC563(0x106,0x00);
              	if(SyncMode == 3)
               	 	WriteIIC563(0x106,0x11);
              	else
                	 	WriteIIC563(0x106,0x01);
              	#if DVImode == HVmode
              	if(SyncMode == 3)
              		WaitSetup(5);
              		//Sleep(50);
              	#endif
                 	LocalTimer = 10;
                 	while((ReadIIC563(0x106) & BIT_0) && LocalTimer != 0)
              		{
              		CheckModeChange();
              		if(Abort)
              			return;
              		}
                 	if(LocalTimer != 0)
              		{				// Auto-Position OK
                  	FuncBuf[pVPOSITION] = ReadIIC563(0x109) & 0x07;
              		FuncBuf[pVPOSITION] <<= 8;
C51 COMPILER V6.12  AUTOADJ                                                                03/05/2008 14:11:12 PAGE 4   

                  	FuncBuf[pVPOSITION] |= ReadIIC563(0x108);
                  	FuncBuf[pHPOSITION] = ReadIIC563(0x10F) & 0x07;
              		FuncBuf[pHPOSITION] <<= 8;
                  	FuncBuf[pHPOSITION] |= ReadIIC563(0x10E);
              		#if PRINT_MESSAGE
              			printf("VP_Start = %d\n",FuncBuf[pVPOSITION]);
              			printf("HP_Start = %d\n",FuncBuf[pHPOSITION]);
              		#endif
              		if(((FuncBuf[pVPOSITION] > 0xff) || (FuncBuf[pHPOSITION] > (FuncBuf[pCLOCK]-H_Act)))&&(SyncMode != 3))
              			{
              			Abort = 1;			// abort
              			#if PRINT_MESSAGE
              				printf("AutoPosition fail\n");
              			#endif
              			}
              		else{
              			if(ResolutionPtr < 4)
              				{
              				if(FuncBuf[pVPOSITION] > (VTotal - Vresolution-1))
              					FuncBuf[pVPOSITION] = VTotal - Vresolution-14;
              				}
              			SetHP();
              			SetVP();
              			}
              		}
              	else
              		{
              		Abort = 1;			// abort
              		#if PRINT_MESSAGE
              			printf("AutoPosition fail\n");
              		#endif
              		}
                 	// wait for next V pulse coming to latch data
              	WriteIIC563(0x1ab,BIT_1);
              	LocalTimer = 100;
              	while(LocalTimer != 0)
              		{
              		Sleep(1);
              		temp = ReadIIC563(0x1ab);
              		if(temp & BIT_1)
              			break;
              		}
              }
              #endif
 223          
 224          void AutoPosition(void)
 225          {
 226   1      	Word OldVp,NewVp,Vact,Hact;
 227   1      	#if PRINT_MESSAGE
              		printf("AutoPosition\n");
              	#endif
 230   1      	WriteIIC563(0x02A,0);  // AutoPosition Pixel mask -> H
 231   1      	WriteIIC563(0x02B,24);  // AutoPosition Pixel mask -> H
 232   1      	WriteIIC563(0x02C,0x00);  // AutoPosition Pixel mask -> H
 233   1      	WriteIIC563(0x02D,0x00);  // AutoPosition Pixel mask -> H
 234   1      	WriteIIC563(0x107,0x30);  // Red Noise Margin
 235   1      	WriteIIC563(0x106,0x00);
 236   1      	if(SyncMode == 3)
 237   1       	 	WriteIIC563(0x106,0x11);
 238   1      	else
 239   1        	 	WriteIIC563(0x106,0x01);
 240   1      	#if DVImode == HVmode
C51 COMPILER V6.12  AUTOADJ                                                                03/05/2008 14:11:12 PAGE 5   

              	if(SyncMode == 3)
              		WaitSetup(5);
              	#endif
 244   1      	OldVp = FuncBuf[pVPOSITION];
 245   1         	LocalTimer = 100;
 246   1         	while((ReadIIC563(0x106) & BIT_0) && LocalTimer != 0)
 247   1      		{
 248   2      		CheckModeChange();
 249   2      		if(Abort)
 250   2      			return;
 251   2      		}
 252   1         	if(LocalTimer != 0)
 253   1      		{				// Auto-Position OK
 254   2      		Hact = ReadWordIIC563(0x110) & 0x0fff;
 255   2          	//Hact = ReadIIC563(0x111) & 0x3f;
 256   2      		//Hact <<= 8;
 257   2          	//Hact |= ReadIIC563(0x110);
 258   2      //		if(Hact < 300)
 259   2      		if(Hact < Hresolution - 100)
 260   2      		{
 261   3      			Abort = 1;
 262   3      			return;
 263   3      		}
 264   2      		FuncBuf[pVPOSITION] = ReadWordIIC563(0x108) & 0x07ff;
 265   2          	//FuncBuf[pVPOSITION] = ReadIIC563(0x109) & 0x07;
 266   2      		//FuncBuf[pVPOSITION] <<= 8;
 267   2          	//FuncBuf[pVPOSITION] |= ReadIIC563(0x108);
 268   2      		GetFuncRange(pVPOSITION);
 269   2      		if(FuncBuf[pVPOSITION] > FuncMax)//over VPosition Max
 270   2      		{
 271   3      			FuncBuf[pVPOSITION] = FuncMax;
 272   3      			#if PRINT_MESSAGE
              				printf("VPositon over Max");
              			#endif
 275   3      		}
 276   2      		FuncBuf[pHPOSITION] = ReadWordIIC563(0x10e) & 0x07ff;
 277   2          	//FuncBuf[pHPOSITION] = ReadIIC563(0x10F) & 0x07;
 278   2      		//FuncBuf[pHPOSITION] <<= 8;
 279   2          	//FuncBuf[pHPOSITION] |= ReadIIC563(0x10E);
 280   2      		GetFuncRange(pHPOSITION);
 281   2      		if(FuncBuf[pHPOSITION] > FuncMax)//over VPosition Max
 282   2      		{
 283   3      			FuncBuf[pHPOSITION] = FuncMax;
 284   3      			#if PRINT_MESSAGE
              				printf("HPositon over Max");
              			#endif
 287   3      		}
 288   2      
 289   2      		Vact = ReadWordIIC563(0x10c) & 0x07ff;
 290   2          	//Vact = ReadIIC563(0x10d) & 0x07;
 291   2      		//Vact <<= 8;
 292   2          	//Vact |= ReadIIC563(0x10c);
 293   2      		NewVp = FuncBuf[pVPOSITION];
 294   2      		#if PRINT_MESSAGE
              			printf("VP_Start = %d\n",FuncBuf[pVPOSITION]);
              			printf("HP_Start = %d\n",FuncBuf[pHPOSITION]);
              		#endif
 298   2      			
 299   2      		if(((FuncBuf[pVPOSITION] > 0x40) || ((FuncBuf[pHPOSITION]>>1)  > (FuncBuf[pCLOCK]-Hresolution))||(Vact <
             - 340))&&(SyncMode != 3))
 300   2      		//if((FuncBuf[pVPOSITION] > 0xff) || ((FuncBuf[pHPOSITION]>>1) > (FuncBuf[pCLOCK]-Hresolution)))
 301   2      		{
C51 COMPILER V6.12  AUTOADJ                                                                03/05/2008 14:11:12 PAGE 6   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?