EasyManua.ls Logo

Finest 509 - Page 24

Default Icon
29 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5.3.4 A Sample Program (FICOM.H)
The following program is an example of a C language program
which he
l
ps users to understand the data format and the data
interfacing method, and also to develop their own programs.
[Interrupt Usage and Selection between COM1 and COM2]
#define COM1 0
#define COM2 0
/* Base addresses of serial ports */
#define COM1BASE 0x03f8
#define COM2BASE 0xx02f8
#define COMBASE ( (comport = = COM1)?COM1BASE:
COM2BASE)
/* Registers */
#defineTHR (COMBASE +0) /* Transmit Holding Register */
#defineRBR (COMBASE +0) /* Receive Buffer Register */
#defineIER (COMBASE +1) /* Interrupt Enable Register */
#defineIIR (COMBASE +2) /* Interrupt Identification Register*/
#defineLCR (COMBASE +3) /* Line Control Register */
#defineMCR (COMBASE +4) /* Modem Control Register */
#defineLSR (COMBASE +5) /* Line Status Register */
#defineMSR (COMBASE +6) /* Modem Status Register */
44 45
/* Parameters to bioscom function */
#define DATABIT7 0X02 /* Data bit */
#define DATABIT8 0X03
#define STOPBIT1 0X00 /* Stop bit */
#define
STOPBIT2
0X04
#define NOPARITY 0X00 /* Parity bit */
#define ODDPARITY 0X08
#define EVENPARITY 0X18
#define BAUD1200 0X80 /* Baud rate */
#define BAUD2400 0Xa0
#define BAUD4800 0Xc0
#define BAUD9600 0Xe0
/* 8259 PIC (Programmable Interrupt Controller */
#defineIMR 0x21 /* I/O address of 0CW1 (IMR) of 8529 PIC */
#define0CW 0x20 /* I/O address of 0CW2 of 8259 PIC */
/* 0CW: Operation Command Word */
/* IMR: Interrupt Mask Register */
# define MASKON 0x e7 /* Mask IRQ3/IRQ4 on
IMR */
* define MASKOFF 0x18 /* Mask IRQ3/IRQ4 off
IMR */
#define EOI 0x20 /* Non-specific End of Interrupt command
0CW2*/
/* Interrupt Request Numbers */
#define IRQ0 0x 08 /* Interrupt Vector for Timer */
#define IRQ3 0x 0b /* Interrupt Vector for COM2 */
#define IRQ4 0x 0c /* Interrupt Vector for COM1 */
#define IRQ8 0x 70 /* Interrupt Vector for RTC (Real TIme Clock) */
#define IRQ16 0x 1C /* Interrupt Vector to called Timer */
#define IRQNUM ( ( comport = = COM1)? IRQ4 : IRQ3)

Related product manuals