Skip to main content

Microcontrollers SEM 2 UNIT 4

Unit 4: 8051 Timers and Serial Communication



Question 1 (6 Marks): Explain the concept of timers and counters in the 8051 microcontroller and their different modes of operation.

Answer:

The 8051 has two built-in 16-bit timers/counters (Timer0 and Timer1). These timers can be configured to operate in different modes to perform various timing and counting functions.

Modes of Operation:

  • Mode 0 (13-Bit Timer): In this mode, both Timer0 and Timer1 operate together as a single 13-bit timer. When the combined timer reaches its maximum value (8191), it overflows, generating an interrupt (if enabled).
  • Mode 1 (16-Bit Timer): In this mode, Timer0 or Timer1 acts as an independent 16-bit timer. When the timer reaches its maximum value (65535), it overflows, generating an interrupt (if enabled).
  • Mode 2 (Auto-Reload): This mode allows automatic reloading of a preload value into the timer after an overflow occurs. This is useful for generating repetitive pulse trains or square waves.




Question 2 (6 Marks): Describe how to generate a pulse using Mode 1 and a square wave using Mode 2 on a port pin in the 8051 with assembly language programming examples.

Answer:

Generating a Pulse using Mode 1:

  1. Configure Timer0 (or Timer1) in Mode 1 using the Timer Mode Control Register (TMOD).
  2. Load a desired value (delay count) into the timer registers (TH0 and TL0 for Timer0).
  3. Enable Timer0 overflow interrupt (if needed).
  4. In the interrupt service routine (ISR), set the desired port pin high to generate the pulse.
  5. After a specific delay (determined by the load value), the timer overflows, triggering the ISR.
  6. In the ISR, set the port pin low to end the pulse.

 

Generating a Square Wave using Mode 2:

  1. Configure Timer1 in Mode 2 using TMOD.
  2. Load a desired value (half the square wave period) into the timer registers.
  3. Set a bit in the Timer1 Control Register (TCON) to enable auto-reload.
  4. Set the desired port pin high initially.
  5. In the Timer1 overflow interrupt service routine (similar to Mode 1), toggle the port pin (high to low or vice versa) to create the square wave.

 



Question 3 (6 Marks) (Continued): Explain the basics of serial data communication and the RS-232 standard.

Serial Data Communication:

  • Involves transmitting data one bit at a time over a single wire (compared to parallel communication using multiple wires).
  • Used for communication between devices with different clock speeds or over long distances.
  • Requires specific timing and synchronization between the transmitting and receiving devices.

RS-232 Standard:

  • RS-232 (Recommended Standard 232) is a widely used standard for serial communication.
  • Defines electrical characteristics, signal levels, and pin assignments for a serial port.

Serial communication is essential for connecting the 8051 to various external devices like sensors, displays, and other microcontrollers.

 



Question 4 (6 Marks): Describe a simple serial port programming example in assembly language to transmit a message and receive data serially on the 8051.

Answer:

; Define baud rate and SFR registers

MOV SBUF, #'H'  ; Character to transmit

; Set baud rate and enable serial port (refer to your microcontroller datasheet)

 

; Wait for transmission complete flag (TI) to be set

LOOP:

    JNZ SBUF, LOOP  ; Wait until SBUF is empty (transmission complete)

 

; Clear Transmission Complete flag

CLR TI


Comments

Popular posts from this blog

Microcontrollers SEM 2 UNIT 1

Unit 1: 8051 Microcontroller (General Questions and Answers) Question 1 (6 Marks): Differentiate between a microprocessor and a microcontroller. Question 2 (6 Marks): Briefly describe the 8051 microcontroller architecture with the help of a block diagram. Answer: The 8051 microcontroller follows the Harvard architecture, separating program memory from data memory. Key components include: Central Processing Unit (CPU): Processes instructions, performs calculations, and controls program flow. It consists of: Arithmetic Logic Unit (ALU) for arithmetic and logical operations. Control Unit (CU) for fetching, decoding, and executing instructions. Registers for temporary data storage and program control. Question 3 (6 Marks): Explain the functionalities of any three 8051 microcontroller pins with the help of a pin diagram. Answer: Port 0 (P0.0 - P0.7): 8-bit bidirectional I/O port. Each pin can be configured as input or output for connecting with external devices (sensors, LEDs, etc.). ALE (A...

Top 3 most important questions for Engineering Drawing SEM I

These are the top 3 questions with highest probability to come in SEM I Exam  

Applied science Sem 1 UNIT 3

    UNIT 3 : Corrosion   Q1) Explain any five factors affecting corrosion. Position in Galvanic Series: More active metals corrode faster when in electrical contact in a conducting medium. Relative Areas of Anode and Cathode: Corrosion rate depends on the ratio of cathodic to anodic area. a larger anodic area minimizes corrosion. Purity of Metal: Impurities create galvanic cells, leading to corrosion. Temperature: Higher temperatures speed up both atmospheric and electrochemical corrosion. Conductivity of Corroding Medium: The electrical conductivity of the medium affects the rate of electrochemical corrosion. Higher conductivity results in faster corrosion.         Q2) Define Hot dipping. Explain coating method with neat labelled diagram to protect metal from corrosion and give applications. Hot Dipping: Hot dipping is a method that in...