EE 223 – CIRCUIT THEORY I



MICROPROCESSORS I

EEE 411

Selected Questions and Answers from Previous Year’s Final Exams

28 Jun. 1999(Meke-up Q-3) (a) Write a program to change the data bits used for framing to 8 data bit in a RS-232 serial port

b) If a RS-232 port operating at 7 data bits, even parity, one stop bit and 9600 baud rate, Calculate the time in seconds required to send 64K of data using this port.

c) Briefly explain the registers used in Standard Parallel port (SPP).

Solution:

a) Line Control Register (LCR) is used to configure the framing in a serial communication. Having the following features of the Line Control Register, we can program the frame as follows:

D7 D6 D5 D4 D3 D2 D1 D0

|DLAB |Break |Parity2 |Parity1 |Parity0 |Stop |Data1 |Data0 |

-We need to read the current settings of the LCR and change the number of data bits to become 8-bit and write it back to the LCR register.

-The address of the LCR is COM ports base address + 3 (3F8H + 3)

- We will need to change D1 &D0 to 11

.MODEL SMALL

.CODE

MAIN: MOV DX,3F8H

ADD DX,3

IN AL,DX

OR AL,00000011B

OUT DX,AL

MOV AH,4CH

INT 21H

END MAIN

b) RS-232 is operating at –7 data bits / even parity / one stop bit/ 9600 bps

- One frame will contain 1 start bit+ 7 data bits+ 1 parity bit + 1 stop bit = 10 bits (total)

- 64 K bytes = 216 = 65536 bytes of data=65536*8=524288 data bits

- For each frame 7-bit data is transmitted. So 524288/7 = 74898.108 frames will be needed.

- Each frame is 10-bit. So, = 74898*10 =748981.08 bits will be transmitted.

- 748980/9600 = 78.019 seconds

c) The registers of Standard Parallel Port (SPP) are: - Data Register

- Status Register

- Control Register

3 Jun. 1999(2nd Midterm Q-1)

Briefly Explain the most important signals of RS-232 communication and their corresponding bits in the UART registers.

If a serial port will be operated at the following settings:

8 Data bits, 2 Stop bits, even parity and 9600 bps

Write the required program segment to bring the port to these settings and estimate the time in seconds required to send 4096 bytes of data using this port.

Write a program to send a character through this port.

(Base address of the port is 2F8H)

Solution:

a)

Signals of RS-232 Communication UART Registers

TD (TxD) :Transmit Data Transmitter Holding Buffer (Bit 7 of LCR)

RD (RxD) :Receive Data Receiver Buffer (Bit 7 of LCR)

CTS :Clear To Send CTS (Bit 4 of MSR)

DCD/CD :Data Carrier Detect CD (Bit 7 of MSR)

DSR :Data Set Ready DSR (Bit 5 of MSR)

DTR :Data Terminal Ready Force DTR (Bit 0 of MCR)

RTS :Request To Send Force RTS (Bit 1 of MCR)

RI :Ring Indicator RI (Bit 6 of MSR)

LCR: Line Control Register

MSR: Modem Status Register

MCR: Modem Control Register

b) – The settings are: 8 Data bits / 2 Stop bits / Even parity and 9600 bps (baud rate)

The LCR has to be programmed in the following way:

D7 D6 D5 D4 D3 D2 D1 D0

|DLAB |Break |Parity2 |Parity1 |Parity0 |Stop |Data1 |Data0 |

|1 |0 |0 |1 |1 |1 |1 |1 |

- The address of the LCR is COM ports base address + 3 (3F8H + 3)

MOV DX,3F8H

ADD DX,3 ;the address of LCR is base address +3

MOV AL,10011111B

OUT DX,AL

MOV AL,12

MOV DX,3F8H ;the address of the Divisor Latch Low Byte is base address +0

OUT DX,AL

MOV AL,00

INC DX ;the address of the Divisor Latch Low Byte is base address +0

OUT DX,AL

-The baud rate=9600. Divisor value = max. ref. Frequency/ Target baud rate

=115,200/9600 = 12

-So Divisor Latch must have 12 (0CH) at the low byte and 00 at the high byte.

The time required to send 4096 bytes of data:

- For each byte of data 12 bits (total) will be transmitted.

- Number of frames required = 4096

- Number of bits to be sent = 4096 * 12 = 49152 bits

- The time required to transmit = 49152/9600 = 5.12 seconds.

c) Sending (Transmitting) a character through the serial port at 3F8H.

Note, that in the program below we assume that the above port settings have already been configured. Also assumes that both the transmitting and receiving sides are working.

.MODEL SMALL

.DATA

BASE DW 3F8H ;base address of the COM port

CHAR DB ‘A’ ; assume that ‘A’ is the character to be transmitted

.CODE

MAIN: MOV AL,00000011B ; set DTR and RTS from the Modem Control Register (MCR)

MOV DX,BASE ;

ADD DX,4 ; MCR is at base address + 4

OUT DX,AL

MOV DX,BASE ;

ADD DX,6 ; The MSR is at base address +6

CHECK1: IN AL,DX ; check DSR and CTS from the Modem Status Register

MOV BL,00110000B ; bits 4 and 5 of MSR must be one

AND AL,BL

CMP AL,BL

JNE CHECK1

MOV DX,BASE ;

ADD DX,5 ; The MSR is at base address +5

CHECK2: IN AL,DX ; check if Trans. Holding Register is Empty from LSR

MOV BL,00100000B ; from bit 5 of the LSR

AND AL,BL

CMP AL,BL

JNE CHECK2

MOV DX,BASE ; Transmitter Holding Buffer it at base address +0

MOV AL,CHAR ; assume AH contains the character to be transmitted.

OUT DX,AL ; write the byte to Trans. Holding Buffer

MOV AH,4CH

INT 21H

END MAIN

-----------------------

1 = Divisor Latch Access Bit

0 = Access to receiver/ Transmitter buffer

0=break

1=disable break

XX0 = No parity

001 = Odd parity

011 = Even parity

101 =High parity(Mark)

111=Low parity(Space)

0=1 stop bits

1=2 stop bits

00 =5 data bits

01 =6 data bits

10 =7 data bits

11 =8 data bits

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download