资 源 简 介
C51控制并口打印机实例:/* 沈阳新荣达电子 *//* 2004-12-7 */#include #define uchar unsigned char#define uint unsigned int#define data_8 P0sbit BUSY = P1^2; //打印机 BUSY 接P1.2sbit STB = P1^0; //打印机 STB 接P1.0void print(uchar j) //打印子程序{ uchar i;while(BUSY){}; //BUSY=1,打印机忙,等待BUSY 为0 再发数data_8=j;STB=0;i++;i--;STB=1; //给出数据锁存时钟BUSY=1;}void main(void){BUSY = 1; //忙信号置高STB = 1; //选通信号置高print(0x1b); //打印机初始化命令print(0x38);print(0x04);for(;;){print(0xd0); //发送汉字内码“新荣达”print(0xc2);print(0xc8);print(0xd9);print(0xb4);print(0xef);print(0x0d); //换行}}