| ??? 01/05/01 13:42 Read: times |
#7822 - RE: Parallel printer interface |
I have found some code on the internet by accedent :)
Don't know if it works. Dennis. ---------------------- /* Program:Printer.c Printer test Program Author:Bhalchandra Date:06-07-2000 Modified:07-07-2000 Present hardware connections. data port1 init P3.2 strobe P3.3 busy P3.4 You can change this if you want,Simply assign different port pins. */ #include <stdio.h> SFR PORT 0x90 //define data port you are using,as new SFR BIT init P3.2 //the init,strobe and busy line connections BIT strobe P3.3 BIT busy P3.4 unsigned char temp[35]="Printer test program by SPJ Systems"; unsigned char temp1[25]="114,Chitrashala Building"; unsigned char i; void initialise(){ //initialise printer init=0; init=1; } unsigned char send_char(unsigned char dat){ unsigned int timeout; timeout=0xffff; //this is timeout counter while(busy){ //check busy timeout--; if (timeout==0) //this is timeout error,one character lost return(0); //you can display error. } PORT=dat; //out data at port strobe=0; //give low pulse to strobe asm nop; strobe=1; return(1); } void main() { init=1; //init=1 strobe=1; //strobe=1 initialise(); //initialise printer delay_ms(1000); //delay for(i=0;i<35;i++) //sends string1 send_char(temp[i]); send_char(0x0d); //carriage return send_char(0x0a); //line feed for(i=0;i<24;i++) //send string2 send_char(temp1[i]); send_char(0x0d); //carriage return send_char(0x0a); //line feed strcpy(temp1,"562,Sadashiv Peth Pune-30"); for(i=0;i<25;i++) send_char(temp1[i]); //send string3 send_char(0x0d); //carriage return send_char(0x0a); //line feed strcpy(temp,"Visit us at www.spjsystems.com"); for(i=0;i<30;i++) send_char(temp[i]); //send string4 send_char(0x0d); //carriage return send_char(0x0a); //line feed while(1){} //infinite loop } |
| Topic | Author | Date |
| Parallel printer interface | 01/01/70 00:00 | |
| RE: Parallel printer interface | 01/01/70 00:00 | |
| RE: Parallel printer interface | 01/01/70 00:00 | |
RE: Parallel printer interface | 01/01/70 00:00 |



