⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcu.c.bak

📁 车载SCALER模块源程序
💻 BAK
字号:
/*==========================================
==========================================*/
#include "include.h"
/*==========================================
==========================================*/
extern WarmUp();
void InitMCU(void)
{
	Byte xdata *Addr;
	Byte i;
	Addr = 0xf000;
	for(i=0; i<0x23; i++){
		*Addr++ = McuRegTab[i];
	}
// set timer 0
 	SCON = 0x52;
 	TMOD = 0x22;	//timer0 /timer1 8 bits auto reload
// 	TMOD = 0x21;	//timer0 16 bits/timer1 8 bits auto reload
 	PCON = 0x80;
// timer0 8 bits auto reload
	TL0 = -200;
	TH0 =-200;
//	TL0 = 256-(CPU_CLK/1000*100/12000); //time base 100us
//	TH0 = 256-(CPU_CLK/1000*100/12000);

// timer0 16 bits
//	TL0 = (65536-CPU_CLK/1200)%256;	//time base 10ms
//	TH0 = (65536-CPU_CLK/1200)/256;

// For 12.000 MHz 
 	TL1 = 256-(2*CPU_CLK/384/9600);
 	TH1 = 256-(2*CPU_CLK/384/9600);
// For 14.318 MHz 
 	//TL1 = 256-(2*CPU_CLK/384/4800);
 	//TH1 = 256-(2*CPU_CLK/384/4800);
	TR0 = 1;		//start timer0
 	TR1 = 1;		//start timer1
// set interrupt
	EX1 = 1;		//enable External interrupt1
	ET0 = 1;		//enable timer0 interrupt
	EA = 1;			//enable all interrupt
	T0_INT_CNT = 0;
	T0_10ms_Cnt = 0;
	Sleep(50);	
}
/*==========================================
==========================================*/
void Timer0(void) interrupt 1 using 2
{
	if(++T0_INT_CNT >= 10){
		T0_INT_CNT = 0;
//		if(Timer1 != 0)			// 1ms
//			Timer1--;
		if(++T0_1ms_Cnt >= 10){	// 10ms
			CLRWDT = 0x55;
			T0_1ms_Cnt = 0;
			if(++T0_10ms_Cnt >= 100){//--1s
				T0_10ms_Cnt = 0;
			}
			if(OsdTimer > 0)
				OsdTimer--;
			if(LocalTimer > 0)
				LocalTimer--;
			if(PowerTimer > 0)
				PowerTimer--;
			if(LedTimer > 0)
				LedTimer--;
			if(RepeatTimer > 0)
				RepeatTimer--;
			if(DDCTimer > 0)
				DDCTimer--;
			if(SaveTimer > 0)
				SaveTimer--;
			if(VideoTimer > 0)
				VideoTimer--;
			if(BurnInTimer > 0)
				BurnInTimer--;
			if(MuteTimer > 0)
				MuteTimer--;		
		}
	}	
}
/*==========================================
==========================================*/
void Sleep(Word T)
{
	Word i,j;
	for(j=0;j<T;j++)
		for(i=0;i<53*(CPU_CLK/20000000);i++)
			CLRWDT=0x55;
}
/*==========================================
==========================================*/
void WaitSetup(unsigned short time)
{
	LocalTimer = time;			/* timeout n ms */
	while(LocalTimer != 0){
		CheckModeChange();
	}	
}
/*==========================================
==========================================*/
void BackLightOn(void)
{
//	if(!FLG_Change_SyncMode){		//for skip turn on screen while sync change during timing process
//		I_OBackLightHigh;
//	}
}
/*==========================================
==========================================*/
void BackLightOff(void)
{
//	unsigned char temp;
//	I_OBackLightLow;
//	temp = ReadIIC563(0x16e);
//	WriteIIC563(0x16e,temp&(~BIT_0));	//lo_cs
}
/*==========================================
==========================================*/
bit DetectBacklight()
{
	//return I_OBackLightStatus;
	return 1;
}
/*==========================================
==========================================*/
void PanelPowerOn(void)
{
	//I_OXRSTLow;
	I_OLCDSTBLow;
	Sleep(10);
	//I_OXRSTHigh;
	I_OLCDSTBHigh;
	//I_OPanelPowerHigh;
}
/*==========================================
==========================================*/
void ResetScaler(void)
{
	I_OResetOn;
	Sleep(12);
	I_OResetOff;
	Sleep(50);
	WriteIIC563(0x101, 0x20);  
	Sleep(12);
	WriteIIC563(0x101, 0x0f);
}
/*==========================================
==========================================*/
bit DetectIRQ()
{
	return !(PTB_REG & PB2);
//	return 0;
}
/*==========================================
==========================================*/
void IntGroup1(void) interrupt 2 using 1
{
	if(INT_SRC & INT_EXT){
		if(INTEXT_FLG & INTE0){
			if(FastMuteEnable){
 				I_OBackLightLow;
				if(SyncMode <3){			//add by kevin 92/10/21 if ysnc mode in sep/com/SOG -->COM
		//			INTEXT_EN = INTE1;		// Disable interrupt INT0 enable INT1
					FLG_Change_SyncMode=1;
				}
			}
			Abort = 1;	//abort autotune
			if(ChangeMode<10)
				ChangeMode++;
			INTEXT_FLG = INTE0;
		}
/*		
		if(INTEXT_FLG & INTE1){
			INTEXT_FLG = INTE1;
			I_OBackLightLow;
			WarmUp();			//reset system
			
		}
*/		
		
	}
}
void LED_RedOff(void)
{
unsigned char port;
	port = PTC_REG;
	port |= RDPC_REG;
	port |= PC1;
	PTC_REG = port;
}

void LED_RedOn(void)
{
unsigned char port;
	port = PTC_REG;
	port |= RDPC_REG;
	port &= ~PC1;
	PTC_REG = port;
}

void LED_GrnOff(void)
{
unsigned char port;
	port = PTC_REG;
	port |= RDPC_REG;
	port |= PC0;
	PTC_REG = port;
}

void LED_GrnOn(void)
{
unsigned char port;
	port = PTC_REG;
	port |= RDPC_REG;
	port &= ~PC0;
	PTC_REG = port;
}
void PowNavOn()
{
   	Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port |= PC7;
	PTC_REG = Port; 
}
void PowNavOff()
{
   	Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC7;
	PTC_REG = Port; 
}
void Pow3On()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC5;
	PTC_REG = Port;
}
void Pow3Off()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port |= PC5;
	PTC_REG = Port;
}
void Pow5On()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC6;
	PTC_REG = Port;
}
void Pow5Off()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC6;
	PTC_REG = Port;
}
void Pow9On()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC3;
	PTC_REG = Port;
}
void Pow9Off()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port |= PC3;
	PTC_REG = Port;
}
void Pow5150On()
{
    Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port |= PC2;
	PTC_REG = Port;   
}
void Pow5150Off()
{
   Byte Port;
	Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC2;
	PTC_REG = Port;
}
void ResetVideoOn()
{
    Byte Port;
	Port = PTB_REG;		
	Port |= RDPB_REG;
	Port &= ~PB1;
	PTB_REG = Port;
}
void ResetVideoOff()
{
    Byte Port;
	Port = PTB_REG;		
	Port |= RDPB_REG;
	Port |= PB1;
	PTB_REG = Port;
}
void DrivePowOn()
{
    Byte Port;
	Port = PTA_REG;		
	Port |= RDPA_REG;
	Port |= PA5;
	PTA_REG = Port;
}
void DrivePowOff()
{
    Byte Port;
	Port = PTA_REG;		
	Port |= RDPA_REG;
	Port &= ~PA5;
	PTA_REG = Port;
}
void RestScalOn()
{
    Byte Port;
    Port = PTC_REG;		
	Port |= RDPC_REG;
	Port &= ~PC4;
	PTC_REG = Port;
}
void RestScalOff()
{
    Byte Port;
    Port = PTC_REG;		
	Port |= RDPC_REG;
	Port |= PC4;
	PTC_REG = Port;
}

⌨️ 快捷键说明

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