tailieunhanh - Parallel Port Complete- P4

Parallel Port Complete- P4: From its origin as a simple printer interface, the personal computer's parallel port has evolved into a place to plug in just about anything you might want to hook to a computer. The parallel port is popular because it's versatile-you can use it for output, input, or bidirectional links-and because it's available-every PC has one. | Chapter 3 cations a user decides to run. When a hardware intcrruptoccurs. aDOS program can jump quickly to an interrupt-service routine. Under Windows the operating system has to decide which driver or virtual machine should service the interrupt and pass control to it all the while handling the demands of whatever otherappli-cations are running. All of that takes time so under Windows the interrupt latency or the time before an interrupt is serviced is much longerthanunder DOS and isn t as predictable. Code Efficiency In addition to the programming language you use how you write your programs can affect execution speed. A complete discussion on how to write efficientprogram code is well beyond the scope of this book but a simple example illustrates the issues involved You can generate a sine wave or other waveform by connecting ap rr .llclp c ra Ss outputs to the inputs of a digital-to-analog converter DAC. andwritingarepeat-ing series of bytes to the port. One way to generate t he seriesofbyteswouldbeto use a Sine function to calculate the value for eachpointin the waveformbefore writing it. Another usually faster way is to calculate the values them and write the stored values in sequence to the port. Data Compression For the fastest data transfers compressingthedatainsoftwarecanreduce the number of bytes to write. Even though the number of port writes persecond doesn t change the effective transmission rate the amountofuncompresseddata sent per second is greater. To use this method you ofcourse have to havesoft-ware on the receiving end that knows how to decompress what itreceives. Parallel ports in ECP mode can automatically decompress incoming data thatuses ECP mode s protocol for data compression. Application-related Limits The simplest I O operations just write data from a register to the port orreadthe port into a register. But all programs have to do more than just this and the extra time required for processing and moving data will also .