Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Terminal Program Revisited<br />
Port[ComPort[1] + FCR] := $07; {clearing the FIFOs}<br />
Disabling the FIFOs look like this:<br />
Port[ComPort[1] + FCR] := $00; {disabling FIFOs}<br />
We will be using the FIFOs in the next section, so this is more a brief introduction to this<br />
register so far.<br />
4.7.3 Working with the PIC<br />
Up until this point, we didn't have to worry about working with the Programmable Interrupt<br />
Controller (the PIC). Now we need to. There isn't the need to do all of the potential<br />
instructions for the PIC, but we do need to enable and disable the interrupts that are used<br />
by the UART. There are two PICs typically on each PC, but due to the typical UART IRQ<br />
vector, we really only have to deal with the master PIC.<br />
Pic Function<br />
PIC Commands<br />
Interrupt Flags<br />
I/O Port Address<br />
0x20<br />
0x21<br />
This adds the following two constants into the software:<br />
{PIC Constants}<br />
MasterPIC = $20;<br />
MasterOCW1 = $21;<br />
After consulting the PIC IRQ table 6 we need to add the following line to the software in<br />
order to enable IRQ4 (used for COM1 typically):<br />
Port[MasterOCW1] := Port[MasterOCW1] and $EF;<br />
When we do the "cleanup" when the program finishes, we also need to disable this IRQ as<br />
well with this line of software:<br />
Port[MasterOCW1] := Port[MasterOCW1] or $10;<br />
Remember that COM2 is on another IRQ vector, so you will have to use different constants<br />
for that IRQ. That will be demonstrated a little bit later. We are using a logical and/or<br />
with the existing value in this PIC register because we don't want to change the values for<br />
the other interrupt vectors that other software and drivers may be using on your PC.<br />
6<br />
http://en.wikibooks.org/wiki/<strong>Serial</strong>%20<strong>Programming</strong>%3A8250%20UART%20<strong>Programming</strong>%23PIC%<br />
20Device%20Masking<br />
69