Printer Interface And IRQ7-System Programming-Lecture Notes, Study notes of System Programming

This lecture handout is for System Programming course. It was provided by Prof. Indubhushan Vijayabhas at Ambedkar University, Delhi. It includes: Printer, Interface, Interrupt, Void, Hardware, Function, Work, Memory, Modification, Designed

Typology: Study notes

2011/2012

Uploaded on 08/07/2012

anishay
anishay 🇮🇳

4.2

(25)

118 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture # 12
Printer Interface and IRQ7
PIC
Printer
Interface
Printer
IRQ7
INT
ACK
Printer
Interface
The printer interface uses the IRQ 7 as shown in the slide above. Therefore if interrupt
driven I/O is to be performed int 0x0f need to be programmed as an hardware interrupt.
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) & 0x7F);//corrected
keep(0,1000);
}
docsity.com
pf3
pf4
pf5
pf8

Partial preview of the text

Download Printer Interface And IRQ7-System Programming-Lecture Notes and more Study notes System Programming in PDF only on Docsity!

Lecture # 12

Printer Interface and IRQ

PIC

Printer Interface

Printer

IRQ

INT

ACK

Printer

Interface

The printer interface uses the IRQ 7 as shown in the slide above. Therefore if interrupt driven I/O is to be performed int 0x0f need to be programmed as an hardware interrupt.

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) & 0x7F);//corrected 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)|0x80);//corrected setvect(0x0F,oldint); freemem(_psp); } }

Above is a listing of a program that uses int 0x0f to perform interrupt driven I/O. To enable the interrupt 0x0f three things are required to be done. The interrupt should be enabled in the printer control register, secondly it should also be unmasked in the IMR in PIC. The program can then intercept or set the vector of interrupt 0x0f by placing the address of its function newint(); The newint() will now be called whenever the printer can perform output. This newint() function writes the next byte in buffer to the data registers and then send a pulse on the strobe signal to tell the printer that data has been sent to it. When whole of the buffer has been sent the int 0x0f vector is restored, interrupt is masked and the memory for the program is de-allocated. The above listing might not work. Not all of the printer interfaces are designed as described above. Some modifications in the printer interface will not allow the interrupt driven I/O to work in this manner. If this does not work the following strategy can be adopted to send printing to the printer in background.

full the program restores the int 8 vector and the relinquishes the memory occupied by the program. Printer Cable Connectivity

Printer Cable Connectivity

18-25 GND

17 SLCT IN

16 INIT

15 ERROR

14 AUTO FEED

13 SLCT

12 PE

11 BUSY

10 ACK

9 D

8 D

7 D

6 D

5 D

4 D

3 D

2 D

1 STROB

Not all the bits of the internal registers of the PPI are available in standard PCs. In standard PCs the PPI is connected to a DB25 connector. And some of the bits of its internal registers are available as pin outs as describes in the slide above.

Computer to Computer communication

Computer to Computer

Connectivity

It might be desirable to connect one computer to another via PPIs to transfer data. One might desire to connect them such that one port of PPI at one end is connected to another port of the other PPI at the other end. But interconnecting the whole 8 bits of PPI cannot be made possible as all the bits of the internal ports are not available as pinouts. So the answer is to connect a nibble (4-bits) at one end to the nibble at the other. In this way two way communication can be performed. The nibbles are connected as shown in the slide above.

0 B3 B2 B1 B0 Sender

1 B3 B2 B1 B0 Receiver BUSY ACK PE SLC ER

D4 D3 D2 D1 D

E7 E6 E5 E4 E

Sender sends LOW Nibble and D4 = 0 received as BUSY = 1

First the low nibble of the byte is sent from the sender in bit D0 to D3 of the data port. D bit is cleared to indicate the low nibble is being sent. The receiver will know the arrival of the low nibble when its checks BUSY bit which should be set (by the interface) on arrival.

1 B3 B2 B1 B0 Sender

0 B3 B2 B1 B0 Receiver

BUSY ACK PE SLC ER

D4 D3 D2 D1 D

Receiver send back LOWNibble and D4= received asBUSY = 1 by Sender

The receiver then sends back the nibble turning its D4 bit to 0 as an acknowledgement of the receipt of the low nibble. This will turn the BUSY bit to 1 at the sender side.

1 B7 B6 B5 B4 Sender

0 B7 B6 B5 B4 Receiver BUSY ACK PE SLC ER

D4 D3 D2 D1 D

Sender sends HiNibble and turns D4 = 1 received as BUSY = 0 by Receiver

The sender then send the high nibble and turns its D4 bit to 1 indicating the transmission of high nibble. On the receiver side the BUSY bit will turn to 0 indicating the receipt of high nibble.

The receiver then sends back the high nibble to the sender as an acknowledgment.

0 B7 B6 B5 B4 Sender

1 B7 B6 B5 B4 Receiver

BUSY ACK PE SLC ER

D4 D3 D2 D1 D

Receiver send back Hi Nibble and turns D4 = 1 received as BUSY = 0 by Sender