RS232接口與單片機(jī)通訊,帶觸摸屏帶字庫(kù),可顯示漢字和圖片,適合做智能儀表,電力設(shè)備,模擬表盤等顯示終端
//----------------------------------------------------
//STC12C2052 22.1184MHZ
//EKTC52A
//需要代碼請(qǐng)Mail到
caoyi_027@163.com //----------------------------------------------------
//Includes
//----------------------------------------------------
#include<reg52.h>
//----------------------------------------------------
//sbit Definitions
//----------------------------------------------------
sbit LED=P0^0;
//----------------------------------------------------
//Glpbal CONSTANTS
//----------------------------------------------------
#define SYSCLK 22118400 //SYSCLK frequency in hz
#define BAUD_RATE 115200 //波特率
#define uchar unsigned char
#define unit unsigned int
//----------------------------------------------------
//Function PROTOTYPES
//----------------------------------------------------
Void Uart0_transmit(unsigned char i); //聲明串口子函數(shù)
Void send_str(unsigned char*p,unsigned char s) ; //聲明發(fā)送字符串子函數(shù)
Void delay_ms(unsigned char n); //聲明延時(shí)子函數(shù)
Void Sysinit(Void); //聲明系統(tǒng)初始化子函數(shù)
Void Wenbenchange1(void); //聲明發(fā)送文本子函數(shù)
//----------------------------------------------------
//Uart0_transmit
//----------------------------------------------------
void uart0_transmit(unsigned char i) //想串口發(fā)送一個(gè)字節(jié)
{
ES=0;
TI=0
SBUF=i; //發(fā)送數(shù)據(jù)到uart0
whlie(!TI); //等待發(fā)送1字節(jié)數(shù)據(jù)完成
TI=0; //消除中斷標(biāo)志
ES=1;
}
void send_str(unsigned char *p,unsigned char s) //向串口發(fā)送一個(gè)數(shù)據(jù)串
{
unsigned char m;
for(m=0;m<s;m++)
{
Uart0_transmit(*p);
p++;
}
}
//--------------------------------------------------
//delay
//--------------------------------------------------
void delay_ms(unsigned char n)
{
int i,j;
for(i=1000;i>0;i--);
{
for(j=25*n;j>0;j--);
}
}
//--------------------------------------------------
//sysinit
//--------------------------------------------------
void sysinit(void)
{
PCON I=0x80;
SCON=0x50;
TMOD=0x21;
TH1=255;
TL1=255;
TR1=1;
ES=0;
TH0=0xB8;
TL0=0x00;
TR0=1;
ET0=1;
}
//--------------------------------------------------
//WenbenChange
//--------------------------------------------------
void WenbenChange1(void)
{
uchar wenben1[30]={0xAA 0x53 0x00 0x00 0x00 0x00 0xCE 0xE4 0xBA 0xBA 0xB9 0xC8 0xF6 0xCE
0xBF 0xC6 0xBC 0xBC 0xD3 0xD0 0xCF
0xDE 0xB9 0xAB 0xCB 0xBE 0xCC 0x33 0xC3 //顯示的漢字為“
武漢谷鑫科技有限公司”
send_str(wenben1,30);
delay_ms(100);
}
//---------------------------------------------
//main()Routine
//---------------------------------------------
int main(void)
{
EA=0;//關(guān)中斷
Sysinit();
EA=1;//開中斷
delay_ms(40);
while(1)
{
delay_ms(100);
wenbenchange1();
}
return 0;
}
//---------------------------------------------
//End Of File
//---------------------------------------------