RS232接口与单片机通讯,带触摸屏带字库,可显示汉字和图片,适合做智能仪表,电力设备,模拟表盘等显示终端
//----------------------------------------------------
//STC12C2052 22.1184MHZ
//EKTC52A
//需要代码请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); //声明串口子函数
Void send_str(unsigned char*p,unsigned char s) ; //声明发送字符串子函数
Void delay_ms(unsigned char n); //声明延时子函数
Void Sysinit(Void); //声明系统初始化子函数
Void Wenbenchange1(void); //声明发送文本子函数
//----------------------------------------------------
//Uart0_transmit
//----------------------------------------------------
void uart0_transmit(unsigned char i) //想串口发送一个字节
{
ES=0;
TI=0
SBUF=i; //发送数据到uart0
whlie(!TI); //等待发送1字节数据完成
TI=0; //消除中断标志
ES=1;
}
void send_str(unsigned char *p,unsigned char s) //向串口发送一个数据串
{
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;//关中断
Sysinit();
EA=1;//开中断
delay_ms(40);
while(1)
{
delay_ms(100);
wenbenchange1();
}
return 0;
}
//---------------------------------------------
//End Of File
//---------------------------------------------