Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture # 12. PIC Printer Interface Printer IRQ7 INT ACK Printer Interface.

Similar presentations


Presentation on theme: "Lecture # 12. PIC Printer Interface Printer IRQ7 INT ACK Printer Interface."— Presentation transcript:

1 Lecture # 12

2 PIC Printer Interface Printer IRQ7 INT ACK Printer Interface

3 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); }

4 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); }

5 #include #include #include #include #include void interrupt (*oldint)(); void interrupt newint(); unsigned int far * lpt = (unsigned int far *)0x00400008; char st[80]= "this is a test print string !!!!!!!!!!!"; int i ; void main () { oldint = getvect(0x08); setvect(0x08,newint); keep(0,1000); }

6 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) (); }

7 Printer Cable Connectivity 1STROB 2D0 3D1 4D2 5D3 6D4 7D5 8D6 9D7 10ACK 11BUSY 12PE 13SLCT 14AUTO FEED 15ERROR 16INIT 17SLCT IN 18-25GND

8 Computer to Computer Connectivity

9 P0 2 15 Q3 P1 3 13 Q4 P2 4 12 Q5 P3 5 10 Q6 P4 6 11 Q7 Q3 15 2 P0 Q4 13 3 P1 Q5 12 4 P2 Q6 10 5 P3 Q7 11 6 P4

10 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

11 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

12 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

13 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

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

15 C:\>debug -o 378 0A -i 379 D0 -o 378 19 -i 379 48 Sending byte 9A C:\>debug -i 379 D7 -o 378 0A -i 379 4F -o 378 19


Download ppt "Lecture # 12. PIC Printer Interface Printer IRQ7 INT ACK Printer Interface."

Similar presentations


Ads by Google