1 / 26

Lecture # 11

Lecture # 11. Programmable Peripheral Interface (PPI). Programmable Peripheral Interface (PPI). Device Used as Parallel port Interface (I/O controller) is PPI. Programmable Peripheral Interface (PPI). Parallel I/O Device Printer. CPU. PPI.

durin
Download Presentation

Lecture # 11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture # 11

  2. Programmable Peripheral Interface (PPI)

  3. Programmable Peripheral Interface (PPI) • Device Used as Parallel port Interface (I/O controller) is PPI

  4. Programmable Peripheral Interface (PPI) Parallel I/O Device Printer CPU PPI

  5. Accessing the Parallel Port Through BIOS Functions

  6. Accessing the Parallel Port Through BIOS Functions

  7. Accessing the Parallel Port Through BIOS Functions All the function Return in AH the Current Printer Status Time out Printer Busy Receive Mode Selected Out of Paper Transfer Error Printer OffLine

  8. Accessing the Parallel Port Through BIOS Functions

  9. Accessing the Parallel Port Through BIOS Functions • Specify the number of Attempts BIOS perform before giving a time out Error • This byte Varies Depending upon the speed of the PC • Busy =0 Printer is Busy • Busy =1 Printer is not Busy

  10. Importance of the Status Byte

  11. Importance of the Status Byte If((pstate&0x29)!=0)or ((pstate&0x80)==0) or ((pstate&0x10)==0) {printerok=FALSE;} else {printerok=TRUE;}

  12. Importance of the Status Byte 17H/01H Initialize Printer on entry AH=01 DX=Interface# On exit AH=Status Byte 17H/00H Write a character on entry AH=00 AL=ASCII code DX=Interface# On exit AH=Status Byte 17H/02H Get Printer Status on entry AH=02, DX=Interface# On exit AH=Status Byte

  13. Printing Program

  14. REGS regs; FILE *fptr; void main(void) { fptr=fopen(“c:\\temp\\abc.text”,”rb”); regs.h.ah=1; regs.x.dx=0; int86(0x17,&regs,&regs); while(!feof(fptr)) {regs.h.ah=2; regs.x.dx=0; int86(0x17,&regs,&regs); if ((regs.h.ah & 0x80)==0x80) { regs.h.ah=0; regs.h.al=getc(fptr); int86(0x17,&regs,&regs); }}} Printing Program

  15. Printing Program 1 #include <dos.h> void interrupt (*old)( ); void interrupt newint ( ); main( ) { old = getvect(0x17); setvect(0x17,newint); keep(0,1000); } void interrupt new () { if (_AH==0) { if ((_AL>='A')&&(_AL<='Z')) return; } (*old)(); }

  16. Printing Program 2 #include <dos.h> void interrupt (*old)( ); void interrupt newfunc ( ); main( ) { old=getvect(0x17); setvect(0x17,newfunc); keep(0,1000); } void interrupt newfunc( ) { if (_AH==0) { if ( _AL != ‘ ‘ ) } (*old)(); }

  17. void interrupt (*old)( ); void interrupt newfunc ( ); main() { old=getvect(0x17); setvect(0x17,newfunc); keep(0,1000); } void interrupt newfunc ( ) { if ( _AH == 0 ) { (*old)(); _AH=0; (*old)(); _AH=0; (*old)(); } else (*old)(); } Printing Program 3

  18. Direct Parallel Port Programming

  19. Direct Parallel Port Programming • BIOS support up to three parallel ports • Address of these LPT ports is Stored in BIOS Data Area

  20. Direct Parallel Port Programming Dump File Text

  21. Direct Parallel Port Programming unsigned int far * lpt = (unsigned int far *) 0x00400008 ; unsigned int temp; temp=*(lpt); *lpt=*(lpt + 1); *(lpt + 1)=temp;

  22. Direct Parallel Port ProgrammingPort Registers • 40:08 store the base address for lpt1 • The parallel port interface has 3 ports internally • If the Base address is 0X378 then the three Ports will be 0x378,0x379 0x37A

  23. Printer Data Port Base +0 = Data Port

  24. Printer Status Register Base + 1 = Printer Status 7 6 5 4 3 2 1 0 Out of Paper Printer Online Printer is ready for Next Character Printer is Busy

  25. Printer Control Register Printer Control Register = Base + 2 initialize IRQ ENABLE Auto Line Field STROB Execute Interrupt When ACK=0; SELECT InLine Turn Computer on line

  26. Direct Parallel Port Programming file *fptr; unsigned far *base=(unsigned int far *)0x00400008 void main ( ) { fptr=fopen(“c:\\abc.txt”,”rb”); while( ! feof (fptr) ) { if(( inport (*base + 1 ) & 0x80) == 0x80) { outport(*base, getc(fptr)); outport((*base)+2, inport((*base+2) & 0xFE); outport((*base)+2, inport((*base+2) | 0x01); } }}

More Related