www.pudn.com > stcMCU.rar > MAIN.C


/******************************************************************** 
STC 单片机开发程序。V0_1_1 
//在KEIL uVision3中,如有不清楚的函数封装,选中后点右键,选择“GO TO Ddfinition Of 'XXXXXX'“ 
//可以看到该函数的原形。 
 
//create by changshengwuji  
//email: netspider@163.com 
//qq:    450353168 
//2006.05.03 
********************************************************************/ 
 
 
 
#include "../inc/MCS_X51.H" 
#include "../inc/hardmap.h" 
#include "../inc/MCS_X51LIB.H" 
  //#define EXT_11M      1			//外部11.0592MHz晶体 
 #define EXT_1M		1				//外部输入时钟1Mhz 
//******************************************************************* 
 
//******************************************************************** 
void cpu_init() 
{ 
	INT_GLOBAL(0); 
	INT_T1(0); 
    
	 
	P1 = 0xff; 
	P3 = 0xff; 
	setup_timer(T1_START_BY_TR | T1_TIMER | T1_MODE_2); 
    #ifdef STC_12X2052X		 //定义使用STC12C2052单片机。 
	#ifdef EXT_1M			 //外部1MHz时钟 
	SET_T0_DIV_BY_1;	    //timer0/timer1 定时器的时钟直接使用外部时钟。不做分频 
	SET_T1_DIV_BY_1; 
	set_timer1(0xF3F3);		//设置波特率4800 
	UART_RATE_MUL;			//波特率翻倍 
	#endif 
    #endif 
 
	#ifdef EXT_11M			//使用STC89C51单片机。11059200晶振 
	set_timer1(0xFDFD);		//9600 
	#endif 
 	T1_START; 
   	setup_uart(UART_MODE_1);	//UART工作于模式1 
	ENABLE_UART_RCV; 
} 
 
/********************************************************************* 
 
**********************************************************************/ 
void main(void) 
{ 
	delay_10clk(1000); 
	cpu_init(); 
	uart_putc(0x60); 
	uart_putc(0x61); 
	uart_putc(0x62); 
	//--------test-------------------- 
 
	uart_putc(0x81); 
	uart_putc(0x82); 
	uart_putc(0x83); 
 
	//---------------------------- 
	while(1) 
	{  
 
	} 
}