14.01.2015 Views

Interfacing the Serial/RS-232 Port

Interfacing the Serial/RS-232 Port

Interfacing the Serial/RS-232 Port

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Interfacing</strong> <strong>the</strong> <strong>Serial</strong> / <strong>RS</strong><strong>232</strong> <strong>Port</strong> V5.0<br />

Note: The source code on <strong>the</strong> earier pages is not a really good example on how to<br />

program but is ra<strong>the</strong>r cut down to size giving quick results, and making it easier<br />

to understand. Upon executing your communications program, it would be wise<br />

to store <strong>the</strong> status of <strong>the</strong> UART registers, so that <strong>the</strong>y all can be restored before<br />

you quit <strong>the</strong> program. This is to cause <strong>the</strong> least upset to o<strong>the</strong>r programs which<br />

may also be trying to use <strong>the</strong> communications ports.<br />

The first step to using interrupts is to work out which interrupt services your serial card. Table 13 shows<br />

<strong>the</strong> base addresses and IRQ's of some standard ports. IRQ's 3 and 4 are <strong>the</strong> two most commonly used.<br />

IRQ 5 and 7 are sometimes used.<br />

Interrupt Vectors<br />

Once we know <strong>the</strong> IRQ <strong>the</strong> next step is to find it's interrupt vector or software interrupt as some<br />

people may call it. Basically any 8086 processor has a set of 256 interrupt vectors numbered 0 to 255.<br />

Each of <strong>the</strong>se vectors contains a 4 byte code which is an address of <strong>the</strong> Interrupt Service Routine (ISR).<br />

Fortunately C being a high level language, takes care of <strong>the</strong> addresses for us. All we have to know is <strong>the</strong><br />

actual interrupt vector.<br />

INT (Hex) IRQ Common Uses<br />

08 0 System Timer<br />

09 1 Keyboard<br />

0A 2 Redirected<br />

0B 3 <strong>Serial</strong> Comms. COM2/COM4<br />

0C 4 <strong>Serial</strong> Comms. COM1/COM3<br />

0D 5 Reserved/Sound Card<br />

0E 6 Floppy Disk Controller<br />

0F 7 Parallel Comms.<br />

70 8 Real Time Clock<br />

71 9 Reserved<br />

72 10 Reserved<br />

73 11 Reserved<br />

74 12 PS/2 Mouse<br />

<strong>Interfacing</strong> <strong>the</strong> <strong>Serial</strong> / <strong>RS</strong><strong>232</strong> <strong>Port</strong> V5.0 Page 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!