Lecture # 12
PIC Printer Interface Printer IRQ7 INT ACK Printer Interface
Interrupt Driven Printer I/O char buf [1024]; int i = 0; void interrupt (*oldint)( ); void interrupt newint (); void main (void) { outport(( *lpt), inport( *lpt) | 4); outport(( *lpt), inport( *lpt) | 0x10); oldint =getvect (0x0F); setvect (0x0F, newint); outport(0x21, inport( 0x21) | 0x80); keep(0,1000); }
void interrupt newint ( ) { outport( *lpt, Buf[ i]); outport(( *lpt)+2, inport(( *lpt)+2) &0xFE); outport(( *lpt)+2, inport(( *lpt)+2) | 1); i++; if( i== 1024) { outport(0x21, inport(0x21)&0x7F); setvect(0x0F,oldint); freemem(_psp); }
#include #include #include #include #include void interrupt (*oldint)(); void interrupt newint(); unsigned int far * lpt = (unsigned int far *)0x ; char st[80]= "this is a test print string !!!!!!!!!!!"; int i ; void main () { oldint = getvect(0x08); setvect(0x08,newint); keep(0,1000); }
void interrupt newint() { if ((( inport((*lpt) +1)) & 0x80) == 0x80) { outport (*lpt,st[i++]); outport ((*lpt)+2, inport((*lpt)+2) & 0xfe); outport ((*lpt)+2, inport((*lpt)+2) | 1); } if (i==32) { setvect (0x08,oldint); freemem(_psp); } (*oldint) (); }
Printer Cable Connectivity 1STROB 2D0 3D1 4D2 5D3 6D4 7D5 8D6 9D7 10ACK 11BUSY 12PE 13SLCT 14AUTO FEED 15ERROR 16INIT 17SLCT IN 18-25GND
Computer to Computer Connectivity
P Q3 P Q4 P Q5 P Q6 P Q7 Q P0 Q P1 Q P2 Q P3 Q P4
0B3B2B1B0 Sender 1B3B2B1B0 Receiver BUSY ACK PE SLC ER D4 D3 D2 D1 D0 E7 E6 E5 E4 E3 Sender sends LOW Nibble and D4 = 0 received as BUSY = 1
1B3B2B1B0 Sender 0B3B2B1B0 Receiver BUSY ACK PE SLC ER D4 D3 D2 D1 D0 Receiver send back LOW Nibble and D4=0 received as BUSY = 1 by Sender
1B7B6B5B4 Sender 0B7B6B5B4 Receiver BUSY ACK PE SLC ER D4 D3 D2 D1 D0 Sender sends Hi Nibble and turns D4 = 1 received as BUSY = 0 by Receiver
0B7B6B5B4 Sender 1B7B6B5B4 Receiver BUSY ACK PE SLC ER D4 D3 D2 D1 D0 Receiver send back Hi Nibble and turns D4 = 1 received as BUSY = 0 by Sender
-d 40: : D 02 x : C gD t. 0040: D D 1C B 3A 27 x-t...d 94.0.:' 0040: B D 1C D E u.m2p : FF A P....p.P : :0060 0E 0D 00 D CC-FF B E2 0B )....k : :0080 1E 00 3E >....` -q
C:\>debug -o 378 0A -i 379 D0 -o i Sending byte 9A C:\>debug -i 379 D7 -o 378 0A -i 379 4F -o