📄 autofunc.lst
字号:
void mstAutoTune(void)
{
#if (RS232DBG&MSG_AUTOTUNE)
sysWriteString(tChangeLine);
sysWriteString("-- AutoTune Start --");
#endif
mstWriteByte(REGBANKSCALER,REGBANKSCALER);
mstWriteByte(BK0_CB_ATOCTRL,0x01);
mstWriteByte(BK0_DB_ATPCTRL,0x19);
mstWriteByte(BK0_DA_ATPTTH,0x1C);
mstWriteByte(BK0_CC_AOVDV,0xC0);
mstAutoHtotal();
mstAutoPhase();
mstAutoPosition();
#if (RS232DBG&MSG_AUTOTUNE)
sysWriteString(tChangeLine);
sysWriteString("-- AutoTune End --");
C51 COMPILER V7.50 AUTOFUNC 03/18/2008 22:29:08 PAGE 6
#endif
}
void mstAutoPosition(void)
{
WORD uwHStart,uwVStart;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOPOSITION
sysWriteString(tChangeLine);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoPosition Start --");
#endif
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHStart=mstReadWord(BK0_D1_AOHST_H);
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwVStart=mstReadWord(BK0_CF_AOVST_H);
mstWriteWord(BK0_08_SPRHST_H,uwHStart-HOFFSET); //BK0_07_SPRHST_L,BK0_08_SPRHST_H
mstWriteWord(BK0_06_SPRVST_H,uwVStart-VOFFSET); //BK0_05_SPRVST_L, BK0_06_SPRVST_H
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOPOSITION
sysWriteString(tChangeLine);
sysWriteString("HStart=");sysWriteDec(uwHStart);
sysWriteString(", VStart=");sysWriteDec(uwVStart);
sysWriteString(", HOFFSET=");sysWriteDec(HOFFSET);
sysWriteString(", VOFFSET=");sysWriteDec(VOFFSET);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoPosition End --");
#endif
}
void mstAutoPhase(void)
{
DWORD ulValue,ulMaxValue;
BYTE ucPhase,ucGoodPhase;
BYTE ucVsyncTime;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOPHASE
sysWriteString(tChangeLine);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoPhase Start --");
#endif
ucVsyncTime=mstGetVSyncTime();
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOPHASE
sysWriteString(tChangeLine);
sysWriteString("VsyncTime=");sysWriteDec(ucVsyncTime);
#endif
ulMaxValue=0;
for (ucPhase=0;ucPhase<0x40;ucPhase++)
{
mstSetPhase(ucPhase);
miscDelay1ms(ucVsyncTime);
mstWaitAutoStatusReady(BK0_DB_ATPCTRL,ATPR_B);
C51 COMPILER V7.50 AUTOFUNC 03/18/2008 22:29:08 PAGE 7
ulValue=mstReadWord(BK0_DF_ATPV4);
ulValue=(ulValue<<16)|mstReadWord(BK0_DD_ATPV2);
if (ulValue>ulMaxValue)
{
ucGoodPhase=ucPhase;
ulMaxValue=ulValue;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOPHASE
sysWriteString(tChangeLine);
sysWriteString("phase=");sysWriteDec(ucPhase);
sysWriteString(" ,Value=");sysWriteUartDec6(ulValue);
sysWriteString(" ,MaxValue=");sysWriteUartDec6(ulMaxValue);
#endif
}
}
mstSetPhase(ucGoodPhase);
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOPHASE
sysWriteString(tChangeLine);
sysWriteString("GoodPhase=");sysWriteDec(ucGoodPhase);
sysWriteString(" ,MaxValue=");sysWriteUartDec6(ulMaxValue);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoPhase End --");
#endif
}
void mstAutoHtotal(void)
{
// tune HTotal
WORD uwWidth,uwWidthCom;
WORD uwHStart,uwHEnd;
WORD uwHTotal,uwEepHtotal;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoHtotal Start --");
#endif
uwEepHtotal=mstGetHtotal();
if(abs(uwEepHtotal-INPUT_HTOTAL)>HTOTAL_RANGE)
{
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString("Current HTotal Over Range");
sysWriteString(tChangeLine);
sysWriteString("CurrentHtotal=");sysWriteDec(uwEepHtotal);
sysWriteString(" ,InputHtotal=");sysWriteDec(INPUT_HTOTAL);
sysWriteString(" ,HtotalRange=");sysWriteDec(HTOTAL_RANGE);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoHtotal End --");
#endif
return;
}
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHStart=mstReadWord(BK0_D1_AOHST_H);
C51 COMPILER V7.50 AUTOFUNC 03/18/2008 22:29:08 PAGE 8
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHEnd=mstReadWord(BK0_D5_AOHEND_H);
uwWidth=uwHEnd-uwHStart+1;
uwHTotal=(DWORD)uwEepHtotal*IUPUT_WIDTH/uwWidth;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString("HTotal=");sysWriteDec(uwHTotal);
#endif
if(abs(uwHTotal-INPUT_HTOTAL)>HTOTAL_RANGE)
{
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString("Adjust HTotal Over Range");
sysWriteString(tChangeLine);
sysWriteString("Width=");sysWriteDec(uwWidth);
sysWriteString(" ,InputHtotal=");sysWriteDec(INPUT_HTOTAL);
sysWriteString(" ,HtotalRange=");sysWriteDec(HTOTAL_RANGE);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoHtotal End --");
#endif
return;
}
if(uwHTotal&0x01)
{
mstSetHtotal(uwHTotal+1);
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHStart=mstReadByte(BK0_D1_AOHST_H);
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHEnd=mstReadByte(BK0_D5_AOHEND_H);
uwWidth=uwHEnd-uwHStart+1;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString("HTotal+1");
sysWriteString(tChangeLine);
sysWriteString("Width=");sysWriteDec(uwWidth);
sysWriteString("HStart=");sysWriteDec(uwHStart);
sysWriteString("HEnd=");sysWriteDec(uwHEnd);
#endif
mstSetHtotal(uwHTotal-1);
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHStart=mstReadByte(BK0_D1_AOHST_H);
mstWaitAutoStatusReady(BK0_CB_ATOCTRL,ATOR_B);
uwHEnd=mstReadByte(BK0_D5_AOHEND_H);
uwWidthCom=uwHEnd-uwHStart+1;
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString("HTotal-1");
sysWriteString(tChangeLine);
sysWriteString("Width=");sysWriteDec(uwWidth);
sysWriteString("HStart=");sysWriteDec(uwHStart);
sysWriteString("HEnd=");sysWriteDec(uwHEnd);
#endif
if(uwWidth==IUPUT_WIDTH)
uwHTotal++;
else if(uwWidthCom==IUPUT_WIDTH)
C51 COMPILER V7.50 AUTOFUNC 03/18/2008 22:29:08 PAGE 9
uwHTotal--;
}
mstSetHtotal(uwHTotal);
#if (RS232DBG&MSG_AUTOTUNE)&&MSG_AUTOHTOTAL
sysWriteString(tChangeLine);
sysWriteString("HTotal=");sysWriteDec(uwHTotal);
sysWriteString(tChangeLine);
sysWriteString("-- autoCAutoHtotal End --");
#endif
}
BYTE mstGetVSyncTime(void)
{
WORD uwHsync,uwVtime;
WORD uwHsPriod;
WORD uwVTotal;
uwHsPriod=0x1fff&mstReadWord(BK0_EB_HSPRD_H);
uwVTotal=0x7ff&mstReadWord(BK0_ED_VTOTAL_H);
uwHsync=((DWORD)MCU_XTAL_CLK_KHZ*10+uwHsPriod/2)/uwHsPriod;
uwVtime=((WORD)uwVTotal*10+uwHsync/2)/uwHsync;
return (BYTE)uwVtime;
}
void mstWaitAutoStatusReady(BYTE regAddr, BYTE regFlag)
{
BYTE ucWaits=200;
while (ucWaits-- && !(mstReadByte(regAddr)®Flag));
}
void mstSetPhase(BYTE phase)
{
mstWriteByte(GEN_00_REGBK,REGBANKADC);
mstWriteByte(BK1_10_CLKCTRL1,phase+8);
mstWriteByte(BK1_11_CLKCTRL2,phase);
mstWriteByte(GEN_00_REGBK,REGBANKSCALER);
}
void mstSetHtotal(WORD hTotal)
{
hTotal -= 3;
mstWriteByte(GEN_00_REGBK,REGBANKADC);
mstWriteByte(BK1_02_PLLDIVM,hTotal>>4);
mstWriteByte(BK1_03_PLLDIVL,hTotal<<4);
mstWriteByte(GEN_00_REGBK,REGBANKSCALER);
}
WORD mstGetHtotal(void)
{
WORD uwHTotal;
mstWriteByte(GEN_00_REGBK,REGBANKADC);
uwHTotal = mstReadByte(BK1_02_PLLDIVM)<<4;
uwHTotal |= mstReadByte(BK1_03_PLLDIVL)>>4;
mstWriteByte(GEN_00_REGBK,REGBANKSCALER);
uwHTotal += 3;
return uwHTotal;
}
C51 COMPILER V7.50 AUTOFUNC 03/18/2008 22:29:08 PAGE 10
#endif //USE_VGA
552
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = ---- ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -