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

📄 mcu.c

📁 车载 液晶显示器的主控程序(主要使用芯片为 MYSON MTV512 单片机、RealTek 2323 Scare 芯片、TVP5147(视频解码)。配Sharp 8寸液晶显示器 )。
💻 C
字号:
//----------------------------------------------------------------------------------------------------
// ID Code      : Mcu.c No.0001
// Update Note  : 
//
//----------------------------------------------------------------------------------------------------

#define __MCU__

#include  "..\Header\Include.h"

//--------------------------------------------------
// Myson MTV512 MCU Initial
//--------------------------------------------------
#if(_MCU_TYPE == _MYSON_MTV512)				// EVAN 050511

#if(_PCB_TYPE == _PCB_JIALUHUA)

void CMcuInitial(void)
{
    	IE      = 0x00;                         // Disable all interrupts
    	TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    	TR0     = 0;                            // Stop Timer0
    	TF0     = 0;                            // Clear Timer0 Overflow Bit
    	TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    	TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    	TR1     = 0;                            // Stop Timer1
    	TF1     = 0;                            // Clear Timer1 Overflow Bit
    	IE      = 0x8a;                         // Enable interrupts of Timer0

    	MCU_PADMODE_F50 = 0x00;		// No A/D is used
    	MCU_PADMODE_F51 = 0xFC;		// sel: Port5 <<5/4/3/2 / / />> as I/O pin
    	MCU_PADMODE_F52 = 0x90;		//0xB0;		
    	MCU_PADMODE_F53 = 0x07;		// sel P5 dir <</ / / / / /2 /1/0/>> as output in, 
    	MCU_PADMODE_F54 = 0xFE;		// sel P6 dir <<7-0 out>>
    	MCU_PADMODE_F55 = 0x00;		// standard 8051 pin for P1
    	MCU_OPTION_F56  = 0x88;		//
    	MCU_PADMODE_F5E = 0x00;//0x00;
    	MCU_PADMODE_F5F = 0xC0;		// P77/P76 output

    	MCU_IICCTR_F00  = 0x00;//x.hu, for P5.7 read only zero.  0xC0;		// Enable IIC Interface and define ddc2 active at HSDA/HSCL
    	MCU_INTFLG_F03  = 0x00;		// Clear IIC Interrupt register
    	MCU_INTEN_F04   = 0x00;		// Detect WslvA1 IIC Stop Condition

    	MCU_DDCCTRA1_F06 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA1ADR_F07 = (0x80 | (0xA0 >> 1));    // DDC Slave A1 address
		MCU_SLVBADR_F09	 = (0x80 | (0x74 >> 1));	// DEBUG Slave address
		MCU_CTRSLVB_F0A  = 0x02;
		MCU_DDCCTRA2_F86 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA2ADR_F87 = (0x80 | (0xA0 >> 1));    //DDC Slave A2 address

    	//bLEDGREEN = _LED_OFF;
    	//bLEDRED   = _LED_OFF;
#if (_PCB_TYPE == _PCB_PV013BA1)
	#if (_PCB_RIGHTECH_A_USE_PV013BA1 == _FALSE)
	    	bLEDGREEN = _LED_OFF;
	    	bLEDRED   = _LED_OFF;
	#endif
#else
    	bLEDGREEN = _LED_OFF;
    	bLEDRED   = _LED_OFF;
#endif
}




#elif(_PCB_TYPE == _PCB_PV023BC1)

void CMcuInitial(void)
{
    	IE      = 0x00;                         // Disable all interrupts
    	TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    	TR0     = 0;                            // Stop Timer0
    	TF0     = 0;                            // Clear Timer0 Overflow Bit
    	TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    	TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    	TR1     = 0;                            // Stop Timer1
    	TF1     = 0;                            // Clear Timer1 Overflow Bit
    	IE      = 0x8a;                         // Enable interrupts of Timer0

    	MCU_PADMODE_F50 = 0x00;		// No A/D is used
    	MCU_PADMODE_F51 = 0x3C;		// sel: Port5 <<5/4/3/2 / / />> as I/O pin
    	MCU_PADMODE_F52 = 0x90;		//0xB0;		
    	MCU_PADMODE_F53 = 0x07;		// sel P5 dir <</ / / / / /2 /1/0/>> as output in, 
    	MCU_PADMODE_F54 = 0xFF;		// sel P6 dir <<7-0 out>>
    	MCU_PADMODE_F55 = 0x00;		// standard 8051 pin for P1
    	MCU_OPTION_F56  = 0x88;		//
    	MCU_PADMODE_F5E = 0x00;//0x00;
    	MCU_PADMODE_F5F = 0xC0;		// P77/P76 output

    	MCU_IICCTR_F00  = 0x00;//x.hu, for P5.7 read only zero.  0xC0;		// Enable IIC Interface and define ddc2 active at HSDA/HSCL
    	MCU_INTFLG_F03  = 0x00;		// Clear IIC Interrupt register
    	MCU_INTEN_F04   = 0x00;		// Detect WslvA1 IIC Stop Condition

    	MCU_DDCCTRA1_F06 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA1ADR_F07 = (0x80 | (0xA0 >> 1));    // DDC Slave A1 address
		MCU_SLVBADR_F09	 = (0x80 | (0x74 >> 1));	// DEBUG Slave address
		MCU_CTRSLVB_F0A  = 0x02;
		MCU_DDCCTRA2_F86 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA2ADR_F87 = (0x80 | (0xA0 >> 1));    //DDC Slave A2 address

    	//bLEDGREEN = _LED_OFF;
    	//bLEDRED   = _LED_OFF;
#if (_PCB_TYPE == _PCB_PV013BA1)
	#if (_PCB_RIGHTECH_A_USE_PV013BA1 == _FALSE)
	    	bLEDGREEN = _LED_OFF;
	    	bLEDRED   = _LED_OFF;
	#endif
#else
    	bLEDGREEN = _LED_OFF;
    	bLEDRED   = _LED_OFF;
#endif
}

#elif(_PCB_TYPE == _PCB_PV013BA1)
void CMcuInitial(void)
{
    	IE      = 0x00;                         // Disable all interrupts
    	TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    	TR0     = 0;                            // Stop Timer0
    	TF0     = 0;                            // Clear Timer0 Overflow Bit
    	TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    	TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    	TR1     = 0;                            // Stop Timer1
    	TF1     = 0;                            // Clear Timer1 Overflow Bit
    	IE      = 0x8a;                         // Enable interrupts of Timer0

    	MCU_PADMODE_F50 = 0x00;		// No A/D is used
    	MCU_PADMODE_F51 = 0x3A;		// sel: Port5 <<5/4/3/ /1/ />> as I/O pin
    	MCU_PADMODE_F52 = 0x90;		//0xB0;		
    	MCU_PADMODE_F53 = 0x1A;		// sel P5 dir <</ / / /4/3/ /1/ /  >> as output in, 7/6/5 as input pin
    	MCU_PADMODE_F54 = 0xF0;		// sel P6 dir <<3-0 in, 7-4 out>>
    	MCU_PADMODE_F55 = 0x00;		// standard 8051 pin for P1
    	MCU_OPTION_F56  = 0x88;		//
    	MCU_PADMODE_F5E = 0x00;
    	MCU_PADMODE_F5F = 0xC0;		// P77/P76 output

    	MCU_IICCTR_F00  = 0x00;//x.hu, for P5.7 read only zero.  0xC0;		// Enable IIC Interface and define ddc2 active at HSDA/HSCL
    	MCU_INTFLG_F03  = 0x00;		// Clear IIC Interrupt register
    	MCU_INTEN_F04   = 0x00;		// Detect WslvA1 IIC Stop Condition

    	MCU_DDCCTRA1_F06 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA1ADR_F07 = (0x80 | (0xA0 >> 1));    // DDC Slave A1 address
		MCU_SLVBADR_F09	 = (0x80 | (0x74 >> 1));	// DEBUG Slave address
		MCU_CTRSLVB_F0A  = 0x02;
		MCU_DDCCTRA2_F86 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA2ADR_F87 = (0x80 | (0xA0 >> 1));    //DDC Slave A2 address

    	//bLEDGREEN = _LED_OFF;
    	//bLEDRED   = _LED_OFF;
#if (_PCB_TYPE == _PCB_PV013BA1)
	#if (_PCB_RIGHTECH_A_USE_PV013BA1 == _FALSE)
	    	bLEDGREEN = _LED_OFF;
	    	bLEDRED   = _LED_OFF;
	#endif
#else
    	bLEDGREEN = _LED_OFF;
    	bLEDRED   = _LED_OFF;
#endif
}

#elif(_PCB_TYPE == _PCB_RIGHTECH_A)
void CMcuInitial(void)
{
    	IE      = 0x00;                         // Disable all interrupts
    	TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    	TR0     = 0;                            // Stop Timer0
    	TF0     = 0;                            // Clear Timer0 Overflow Bit
    	TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    	TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    	TR1     = 0;                            // Stop Timer1
    	TF1     = 0;                            // Clear Timer1 Overflow Bit
    	IE      = 0x8a;                         // Enable interrupts of Timer0

    	MCU_PADMODE_F50 = 0x00;		// No A/D is used
    	MCU_PADMODE_F51 = 0x3A;		// sel: Port5 <<5/4/3/ /1/ />> as I/O pin
    	MCU_PADMODE_F52 = 0x90;		//0xB0;		
    	MCU_PADMODE_F53 = 0x1A;		// sel P5 dir <</ / / /4/3/ /1/ /  >> as output in, 7/6/5 as input pin
    	MCU_PADMODE_F54 = 0xF0;		// sel P6 dir <<3-0 in, 7-4 out>>
    	MCU_PADMODE_F55 = 0x00;		// standard 8051 pin for P1
    	MCU_OPTION_F56  = 0x88;		//
    	MCU_PADMODE_F5E = 0x00;
    	MCU_PADMODE_F5F = 0xC0;		// P77/P76 output

    	MCU_IICCTR_F00  = 0x00;		//x.hu, for P5.7 read only zero.  0xC0;		// Enable IIC Interface and define ddc2 active at HSDA/HSCL
    	MCU_INTFLG_F03  = 0x00;		// Clear IIC Interrupt register
    	MCU_INTEN_F04   = 0x00;		// Detect WslvA1 IIC Stop Condition

    	MCU_DDCCTRA1_F06 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA1ADR_F07 = (0x80 | (0xA0 >> 1));    // DDC Slave A1 address
		MCU_SLVBADR_F09	 = (0x80 | (0x74 >> 1));	// DEBUG Slave address
		MCU_CTRSLVB_F0A  = 0x02;
		MCU_DDCCTRA2_F86 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA2ADR_F87 = (0x80 | (0xA0 >> 1));    //DDC Slave A2 address

    	bLEDGREEN = _LED_OFF;
    	bLEDRED   = _LED_OFF;

}


#elif (_PCB_TYPE == _PCB_PTX23A21)
void CMcuInitial(void)
{
    	IE      = 0x00;                         // Disable all interrupts
    	TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    	TR0     = 0;                            // Stop Timer0
    	TF0     = 0;                            // Clear Timer0 Overflow Bit
    	TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    	TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    	TR1     = 0;                            // Stop Timer1
    	TF1     = 0;                            // Clear Timer1 Overflow Bit
    	IE      = 0x8a;                         // Enable interrupts of Timer0

    	MCU_PADMODE_F50 = 0x07;
    	MCU_PADMODE_F51 = 0xF9;
    	MCU_PADMODE_F52 = 0xB0;	
    	MCU_PADMODE_F53 = 0x3F;
    	MCU_PADMODE_F54 = 0xF0;
    	MCU_PADMODE_F55 = 0x00;
    	MCU_OPTION_F56  = 0x88;
    	MCU_PADMODE_F5E = 0x00;
    	MCU_PADMODE_F5F = 0xC0;

    	MCU_IICCTR_F00  = 0xC0;                     // Enable IIC Interface and define ddc2 active at HSDA/HSCL
    	MCU_INTFLG_F03  = 0x00;                     // Clear IIC Interrupt register
    	MCU_INTEN_F04   = 0x00;                     // Detect WslvA1 IIC Stop Condition

    	MCU_DDCCTRA1_F06 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA1ADR_F07 = (0x80 | (0xA0 >> 1));    // DDC Slave A1 address
		MCU_SLVBADR_F09	 = (0x80 | (0x74 >> 1));	// DEBUG Slave address
		MCU_CTRSLVB_F0A  = 0x02;
		MCU_DDCCTRA2_F86 = 0x52;                    // Enable DDC1 and DDCRAM 128 Access
    	MCU_SLVA2ADR_F87 = (0x80 | (0xA0 >> 1));    //DDC Slave A2 address

		MCU_ADC_F10 = ADCHANNEL1;			//for key detect

    	bLEDGREEN = _LED_OFF;
    	bLEDRED   = _LED_OFF;
}
#else
void CMcuInitial(void)
{
    	IE      = 0x00;                         // Disable all interrupts
    	TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    	TR0     = 0;                            // Stop Timer0
    	TF0     = 0;                            // Clear Timer0 Overflow Bit
    	TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    	TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    	TR1     = 0;                            // Stop Timer1
    	TF1     = 0;                            // Clear Timer1 Overflow Bit
    	IE      = 0x8a;                         // Enable interrupts of Timer0
}
#endif
#endif


//--------------------------------------------------
// Myson MTV312 MCU Initial
//--------------------------------------------------
#if(_MCU_TYPE == _MYSON_MTV312)

void CMcuInitial(void)
{
    IE      = 0x00;                         // Disable all interrupts
    TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    TR0     = 0;                            // Stop Timer0
    TF0     = 0;                            // Clear Timer0 Overflow Bit
    TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    TR1     = 0;                            // Stop Timer1
    TF1     = 0;                            // Clear Timer1 Overflow Bit
    IE      = 0x8e;                         // Enable interrupts of Timer0

}

#endif

⌨️ 快捷键说明

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