## Search this site

### 8051 Serial Port Programming in Assembly and C - Unit 10 - Review Questions & Answers from 8051 Microcontrollers & Embedded Systems by Mazidi

SECTION 10.1: BASICS OF SERIAL COMMUNICATION

1. The transfer of data using parallel lines is ________ (faster, slower) but ______(more expensive,less expensive).

2. True or false. Sending data to a printer is duplex.

3. True or false. In full duplex we must have two data lines, one for transfer and one for receive.

4. The start and stop bits are used in the __________(synchronous, asynchronous) method.

5. Assuming that we are transmitting the ASCII letter "E" (0100 0101 in binary) with no parity bit and one stop bit, show the sequence of bits transferred serially.

6. In Question 5, find the overhead due to framing.

7. Calculate the time it takes to transfer 10,000 characters as in Question 5 if we use 9600 bps. What percentage of time is wasted due to overhead?

8. True or false. RS232 is not TTL-compatible.

9. What voltage levels are used for binary O in RS232?

10. True or false. The 8051 has a built-in UART.

11. On the back of x86 PCs, we normally have COM port connectors.

12. The PC COM ports are designated by DOS and Windows as _______ and ____________

Answers:

1. Faster, more expensive

2. False; it is simplex.

3. True

4. Asynchronous

5. With 0100 0101 binary the bits are transmitted in the sequence:

(a) 0 (start bit) (b) 1 (c) 0 (d) 1 (e) 0 (f) 0 (g) 0 (h) 1 (i) 0 (j) 1 (stop bit)

6. 2 bits (one for the start bit and one for the stop bit). Therefore, for each 8-bit character, a total of 10 bits is transferred.

7. 10000 x 10 = 100000 bits total bits transmitted. 100000/9600 = 10.4 seconds; 2/10 = 20°/o.

8. True

9. +3 to +25 V

10. True

11. 2

12. COM 1 and COM 2

SECTION 10.2: 8051 CONNECTION TO RS232

1. True or False: The PC COM port connector is the RS232 type.

2. Which pins of the 8051 are set aside for serial communication, and what are their functions?

3. What are line drivers such as MAX232 used for?

4. MAX232 can support _______ lines for TxD and ______ for RxD.

5. What is the advantage of the MAX233 over the MAX232 chip?

Answers:

1. True

2. Pins 10 and 11. Pin 10 is for TxD and pin 11 for RxD.

3. They are used for converting from RS232 voltage levels to TTL voltage levels and vice versa.

4. 2, 2

5. It does not need the four capacitors that MAX232 must have.

SECTION 10.3: 8051 SERIAL PORT PROGRAMMING IN ASSEMBLY

1. Which timer of the 8051 is used to set the baud rate?

2. If XTAL = 11.0592 MHz, what frequency is used by the timer to set the baud rate?

3. Which mode of the timer is used to set the baud rate?

4. With XTAL = 11.0592 MHz, what value should be loaded into THl to have a 9600 baud rate? Give the answer in

both decimal and hex.

5. To transfer a byte of data serially, it must be placed in register __

6. SCON stands for and it is a(n) -bit register.

7. Which register is used to set the data size and other framing information such as the stop bit?

8. True or false. SCON is a bit-addressable register.

9. When is TI raised?

10 Which register has the SMOD bit, and what is its status when the 8051 is powered up?

Answers:

1. Timer 1

2. 28,800 Hz

3. Mode2

4. -3 or FDH since 28,800 / 3 = 9,600

5. SBUF

6. Serial control, 8

7. SCON

8. False

9. During transfer of stop bit

10. PCON; it is low upon RESET.

SECTION 10.4: PROGRAMMING THE SECOND SERIAL PORT

(All questions refer to the DS89C4x0 chip)

1. Upon reset, which timer is used to set the baud rate for Serial #0 and Serial #1?

2. Which pins are used for the second serial ports?

3. With XTAL = 11.0592 MHz, what value should be loaded into THl to have a 28,800 baud rate? Give the answer in

both decimal and hex.

4. To transfer a byte of data via the second serial port, it must be placed in register _______

5. SCONl refers to _____________and it is a(n) _______ -bit register.

6. Which register is used to set the data size and other framing information such as the stop bit for the second serial port?

Answers:

1. Timer 1

2. Pins Pl.2 and Pl.3

3. -1 of FFH

4. SBUFl

5. Serial Control 1, 8

6. SCONl

SECTION 10.5: SERIAL PORT PROGRAMMING IN C

1. How are the SFR registers accessed in C?

2. True or false. C compilers support the second serial port of the DS89C420 chip.

3. Registers SBUF and SCON are declared in C using the keyword.

Answers:

1. By using the reg51.h file

2. False

3. SFR