You are on page 1of 3

MICROPROCESSORS I

EEE 411 Selected Questions and Answers from Previous Years 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 DLAB D6 Break D5 D4 D3 Parity Parity Parity 2 1 0 XX0 = No parity 001 = Odd parity 011 = Even parity 101 =High parity(Mark) 111=Low parity(Space) D2 Stop D1 D0 Data1 Data0 00 =5 data bits 01 =6 data bits 10 =7 data bits 11 =8 data bits 0=1 stop bits 1=2 stop bits

0=break 1=disable break 1 = Divisor Latch Access Bit 0 = Access to receiver/ Transmitter buffer

-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 ADD IN OR OUT MOV INT END b)

DX,3F8H DX,3 AL,DX AL,00000011B DX,AL AH,4CH 21H MAIN

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 TD (TxD) :Transmit Data RD (RxD) :Receive Data CTS :Clear To Send DCD/CD :Data Carrier Detect DSR :Data Set Ready DTR :Data Terminal Ready RTS :Request To Send RI :Ring Indicator LCR: Line Control Register MSR: Modem Status Register MCR: Modem Control Register b) D7 DLAB 1 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: D6 Break 0 D5 Parity 2 0 D4 Parity 1 1 D3 Parity 0 1 D2 Stop 1 D1 D0 Data1 Data0 1 1 UART Registers Transmitter Holding Buffer (Bit 7 of LCR) Receiver Buffer (Bit 7 of LCR) CTS (Bit 4 of MSR) CD (Bit 7 of MSR) DSR (Bit 5 of MSR) Force DTR (Bit 0 of MCR) Force RTS (Bit 1 of MCR) RI (Bit 6 of MSR)

- The address of the LCR is COM ports base address + 3 (3F8H + 3) MOV ADD MOV OUT MOV MOV OUT MOV INC OUT DX,3F8H DX,3 AL,10011111B DX,AL AL,12 DX,3F8H DX,AL AL,00 DX DX,AL ;the address of LCR is base address +3

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

-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 CHAR DB .CODE MAIN: MOV MOV ADD OUT MOV ADD IN MOV AND CMP JNE MOV ADD IN MOV AND CMP JNE

3F8H A AL,00000011B DX,BASE DX,4 DX,AL DX,BASE DX,6 AL,DX BL,00110000B AL,BL AL,BL CHECK1 DX,BASE DX,5 AL,DX BL,00100000B AL,BL AL,BL CHECK2

;base address of the COM port ; assume that A is the character to be transmitted ; set DTR and RTS from the Modem Control Register (MCR) ; ; MCR is at base address + 4 ; ; The MSR is at base address +6 ; check DSR and CTS from the Modem Status Register ; bits 4 and 5 of MSR must be one

CHECK1:

CHECK2:

; ; The MSR is at base address +5 ; check if Trans. Holding Register is Empty from LSR ; from bit 5 of the LSR

MOV DX,BASE MOV AL,CHAR OUT DX,AL MOV AH,4CH INT 21H END MAIN

; Transmitter Holding Buffer it at base address +0 ; assume AH contains the character to be transmitted. ; write the byte to Trans. Holding Buffer

You might also like