Lecture 12 Printer Interface INT PIC Printer Interface

  • Slides: 15
Download presentation
Lecture # 12

Lecture # 12

Printer Interface INT PIC Printer Interface ACK IRQ 7 Printer

Printer Interface INT PIC Printer Interface ACK IRQ 7 Printer

Interrupt Driven Printer I/O char buf [1024]; int i = 0; void interrupt (*oldint)(

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) | 0 x 10); oldint =getvect (0 x 0 F); setvect (0 x 0 F, newint); outport(0 x 21, inport( 0 x 21) | 0 x 80); keep(0, 1000); }

void interrupt newint ( ) { outport( *lpt, Buf[ i]); outport(( *lpt)+2, inport(( *lpt)+2)

void interrupt newint ( ) { outport( *lpt, Buf[ i]); outport(( *lpt)+2, inport(( *lpt)+2) &0 x. FE); outport(( *lpt)+2, inport(( *lpt)+2) | 1); i++; if( i== 1024) { outport(0 x 21, inport(0 x 21)&0 x 7 F); setvect(0 x 0 F, oldint); freemem(_psp); } }

#include <stdio. h> #include <dos. h> #include <bios. h> #include <conio. h> #include <stdlib.

#include <stdio. h> #include <dos. h> #include <bios. h> #include <conio. h> #include <stdlib. h> void interrupt (*oldint)(); void interrupt newint(); unsigned int far * lpt = (unsigned int far *)0 x 00400008; char st[80]= "this is a test print string !!!!!!"; int i ; void main () { oldint = getvect(0 x 08); setvect(0 x 08, newint); keep(0, 1000); }

void interrupt newint() { if ((( inport((*lpt) +1)) & 0 x 80) == 0

void interrupt newint() { if ((( inport((*lpt) +1)) & 0 x 80) == 0 x 80) { outport (*lpt, st[i++]); outport ((*lpt)+2, inport((*lpt)+2) & 0 xfe); outport ((*lpt)+2, inport((*lpt)+2) | 1); } if (i==32) { setvect (0 x 08, oldint); freemem(_psp); } (*oldint) (); }

Printer Cable Connectivity 1 STROB 2 D 0 3 D 1 4 D 2

Printer Cable Connectivity 1 STROB 2 D 0 3 D 1 4 D 2 5 D 3 6 D 4 7 D 5 8 D 6 9 D 7 10 ACK 11 BUSY 12 PE 13 SLCT 14 AUTO FEED 15 ERROR 16 INIT 17 SLCT IN 18 -25 GND

Computer to Computer Connectivity

Computer to Computer Connectivity

P 0 P 1 P 2 P 3 P 4 2 3 4 5

P 0 P 1 P 2 P 3 P 4 2 3 4 5 6 Q 3 Q 4 Q 5 Q 6 Q 7 15 13 12 10 11 Q 3 Q 4 Q 5 Q 6 Q 7 2 3 4 5 6 P 0 P 1 P 2 P 3 P 4

D 4 D 3 D 2 D 1 D 0 0 B 3 B

D 4 D 3 D 2 D 1 D 0 0 B 3 B 2 B 1 B 0 Sender 1 B 3 B 2 B 1 B 0 Receiver Sender sends LOW Nibble and D 4 = 0 received as BUSY = 1 BUSY ACK E 7 E 6 PE SLC E 5 E 4 ER E 3

BUSY ACK PE SLC ER 1 B 3 B 2 B 1 B 0

BUSY ACK PE SLC ER 1 B 3 B 2 B 1 B 0 Sender 0 B 3 B 2 B 1 B 0 Receiver send back LOW Nibble and D 4=0 received as BUSY = 1 by Sender D 4 D 3 D 2 D 1 D 0

D 4 D 3 D 2 D 1 D 0 1 B 7 B

D 4 D 3 D 2 D 1 D 0 1 B 7 B 6 B 5 B 4 Sender 0 B 7 B 6 B 5 B 4 Receiver Sender sends Hi Nibble and turns D 4 = 1 received as BUSY = 0 by Receiver BUSY ACK PE SLC ER

BUSY ACK PE SLC ER 0 B 7 B 6 B 5 B 4

BUSY ACK PE SLC ER 0 B 7 B 6 B 5 B 4 Sender 1 B 7 B 6 B 5 B 4 Receiver send back Hi Nibble and turns D 4 = 1 received as BUSY = 0 by Sender D 4 D 3 D 2 D 1 D 0

-d 40: 08 0040: 0000 0040: 0010 0040: 0020 0040: 0030 0040: 0050 0040:

-d 40: 08 0040: 0000 0040: 0010 0040: 0020 0040: 0030 0040: 0050 0040: 0060 0040: 0070 0040: 0080 -q 78 03 00 00 0 D 02 67 44 01 80 02 1 C 00 00 -00 00 36 00 74 14 78 2 D 74 14 0 D 1 C 64 20 -20 39 34 05 30 0 B 3 A 27 30 0 B 38 09 0 D 1 C 75 16 -6 D 32 70 19 2 E 34 00 00 FF 50 01 00 00 A 0 -70 03 50 00 00 10 00 00 00 18 00 00 00 -00 00 0 E 0 D 00 D 4 03 29 20 CC-FF 00 20 04 6 B E 2 0 B 00 00 00 34 12 00 01 08 03 -14 14 01 01 1 E 00 3 E 00 18 10 00 60 x. . . . g. D. . . . 6. 6. t. x-t. . . d 94. 0. : ' 0. 8. . . u. m 2 p. . 4. . . P. . p. P. . . ). . k. . . 4. . . . >. . `

Sending byte 9 A C: >debug -o 378 0 A -i 379 D 0

Sending byte 9 A C: >debug -o 378 0 A -i 379 D 0 -o 378 19 -i 379 48 C: >debug -i 379 D 7 -o 378 0 A -i 379 4 F -o 378 19