欢迎来到天天文库
浏览记录
ID:59221756
大小:39.50 KB
页数:8页
时间:2020-09-09
《单片机控制打印机例程(北京荣达-并口).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/*********************************************************//新荣达电子打印机测试程序//51单片机,晶振11.0592//时间:2009-7-10//用与测试并行接口打印机//常用打印机指令以函数行式体现//可根据需要自行调用单一函数**********************************************************/#include//51头文件#include//字串处理函数头文件#include#defineu
2、charunsignedcharsbitBUSY=P3^4;//并口打印机的BUSY,串口打印机的CTSsbitSTB=P3^5;//打印机STB接P3.5unsignedchardat[]="新荣达电子测试程序,ABCDEFG";//测试数据//---------------------单字节打印函数-------------------------voidprint(unsignedcharch){while(BUSY==1)//busy为1时,等待{;}P1=ch;//busy=0,将数据送到P1口STB=0;//STB置0;;//空语句,延时使STB>
3、1umSTB=1;//STB置1}/***************************打印字串函数**********************************/voidprint_chs(ucharch[]){uchari;for(i=0;i4、始化打印机print(0x1b);print(0x38);print(0x00);//调用16*16点阵汉字,24点阵为24*24print_chs("汉字命令测试:");for(i=0;i<5;i++)//搋环打印5次{print(0x1b);print(0x38);print(0x00);//调用16*16点阵汉字,24点阵为24*24print(0xd0);print(0xc2);//打印数据"新"print(0x1b);print(0x38);print(0x04);//调用12*12点阵汉字,24点阵为24*24print(0xc8);print5、(0xd9);print(0xb4);print(0xef);//打印数据“荣达”print(0x0d);//回车}}/*************************行间距例程************************************/voidhangjianju(void){uchari;print(0x1b);print(0x40);//初始化打印机print(0x1b);print(0x38);print(0x00);//调用16*16点阵汉字,24点阵为24*24print_chs("行间距测试:");for(i=0;i<11;i6、=i+2)//循环打印{print(0x1b);print(0x31);print(i);//ESC1,设置行间距print_chs("LINESPACING");print(0x0a);//打印字符串和换行}}/*************************水平造表例程***************************************/voidshuipingzhaobiao(void){print(0x1b);print(0x40);//初始化打印机print(0x1b);print(0x38);print(0x00);//调用16*16点7、阵汉字,24点阵为24*24print_chs("水平造表测试:");print_chs("23456");//'标尺print(0x0d);print(0x1b);print(0x44);print(2);print(9);print(14);print(0);//ESCDprint(9);//HT命令print_chs("HT1");//打印字符串print(9);//HT命令print_chs("HT2");//打印字符串print(9);//HT命令print_chs("HT3");//打印字符串print(0x0d);}/************8、*************打印空格或换
4、始化打印机print(0x1b);print(0x38);print(0x00);//调用16*16点阵汉字,24点阵为24*24print_chs("汉字命令测试:");for(i=0;i<5;i++)//搋环打印5次{print(0x1b);print(0x38);print(0x00);//调用16*16点阵汉字,24点阵为24*24print(0xd0);print(0xc2);//打印数据"新"print(0x1b);print(0x38);print(0x04);//调用12*12点阵汉字,24点阵为24*24print(0xc8);print
5、(0xd9);print(0xb4);print(0xef);//打印数据“荣达”print(0x0d);//回车}}/*************************行间距例程************************************/voidhangjianju(void){uchari;print(0x1b);print(0x40);//初始化打印机print(0x1b);print(0x38);print(0x00);//调用16*16点阵汉字,24点阵为24*24print_chs("行间距测试:");for(i=0;i<11;i
6、=i+2)//循环打印{print(0x1b);print(0x31);print(i);//ESC1,设置行间距print_chs("LINESPACING");print(0x0a);//打印字符串和换行}}/*************************水平造表例程***************************************/voidshuipingzhaobiao(void){print(0x1b);print(0x40);//初始化打印机print(0x1b);print(0x38);print(0x00);//调用16*16点
7、阵汉字,24点阵为24*24print_chs("水平造表测试:");print_chs("23456");//'标尺print(0x0d);print(0x1b);print(0x44);print(2);print(9);print(14);print(0);//ESCDprint(9);//HT命令print_chs("HT1");//打印字符串print(9);//HT命令print_chs("HT2");//打印字符串print(9);//HT命令print_chs("HT3");//打印字符串print(0x0d);}/************
8、*************打印空格或换
此文档下载收益归作者所有