1
1
1
The TMOD register (Timer Mode Control) is an 8-bit register in 8051 microcontrollers.
1. Thermocouples.
2. RTDs (Resistance Temperature Detectors).
3. Thermistors.
4. Infrared sensors.
g) Define the terms: scalability, predictability related to RTOS.
1. Digital calculators.
2. Automatic washing machines.
c) C Language Program to Toggle All Bits of Ports P0, P1, P2, and P3
#include <reg51.h>
void delay() {
int i, j;
for (i = 0; i < 100; i++)
for (j = 0; j < 100; j++);
}
void main() {
while (1) {
P0 = ~P0;
P1 = ~P1;
P2 = ~P2;
P3 = ~P3;
delay();
}
}
d) 9-pin RS-232C Connector and Significance of DTR and DSR Signals
Diagram:
-----------------
| 1 2 3 4 5 |
| 6 7 8 9 |
-----------------
Pins:
1. DCD (Data Carrier Detect)
2. RXD (Receive Data)
3. TXD (Transmit Data)
4. DTR (Data Terminal Ready)
5. GND (Ground)
6. DSR (Data Set Ready)
7. RTS (Request to Send)
8. CTS (Clear to Send)
9. RI (Ring Indicator)
Diagram:
+------+ +-------+
P2.0 -> | SOC | ADC0804 | Data | -> P0 (Data Bus)
P2.1 <- | EOC | | Lines |
P2.2 -> | OE | +-------+
Explanation:
Steps:
Description:
Assembly language can be included in a C program using the asm keyword. This allows
embedding low-level instructions for tasks requiring precise control over hardware or speed
optimization.
Example:
#include <reg51.h>
void main() {
P1 = 0x00; // Initialize Port 1
asm {
MOV A, #0x55 // Load value into accumulator
MOV P1, A // Output value to Port 1
}
while (1);
}
b) USB Protocol
Diagram:
+------------+ +------------------+
Host | Root Hub |<--->| USB Devices |
| Controller | | (Mouse, Keyboard)|
+------------+ +------------------+
Explanation:
c) Features of Zigbee
Diagram:
Rows Columns
P1.0 ----> R1 C1 <---- P2.0
P1.1 ----> R2 C2 <---- P2.1
P1.2 ----> R3 C3 <---- P2.2
P1.3 ----> R4 C4 <---- P2.3
Description:
Step Calculation:
4-Step Sequence:
#include <reg51.h>
void delay() {
int i, j;
for (i = 0; i < 300; i++)
for (j = 0; j < 100; j++);
}
void main() {
unsigned char steps[4] = {0x09, 0x0A, 0x06, 0x05}; // Step sequence
int i, count = 50; // 50 steps for 90°
while (count--) {
for (i = 0; i < 4; i++) {
P1 = steps[i]; // Output to stepper motor
delay();
}
}
}
Definition: A hardware timer used to reset the system if the software fails to operate
correctly within a specified time.
Working:
1. The timer starts counting after the system is powered on.
2. The system must periodically reset the timer (referred to as "kicking" or
"feeding the dog").
3. If the timer overflows, it generates a system reset, assuming the system is
stuck or malfunctioning.
Advantages:
1. Ensures system reliability in case of software failure.
2. Detects and recovers from software crashes or infinite loops.
Semaphore:
void delay() {
int i, j;
for (i = 0; i < 100; i++)
for (j = 0; j < 100; j++);
}
void lcd_init() {
lcd_cmd(0x38); // 2 lines, 5x7 matrix
lcd_cmd(0x0C); // Display ON, Cursor OFF
lcd_cmd(0x06); // Increment cursor
lcd_cmd(0x01); // Clear display
lcd_cmd(0x80); // Set cursor to row 1, column 1
}
void main() {
lcd_init();
lcd_data('W');
lcd_data('E');
lcd_data('L');
lcd_data('C');
lcd_data('O');
lcd_data('M');
lcd_data('E');
while (1);
}
Program:
#include <reg51.h>
void delay() {
int i;
for (i = 0; i < 50; i++); // Approx 100 µs delay for 12 MHz crystal
}
void main() {
while (1) {
P1 ^= 0x20; // Toggle P1.5
delay();
}
}
1. Real-Time Operation:
o Perform tasks within specific time constraints for real-time applications like
automotive systems or industrial control.
2. Specific Functionality:
o Designed to perform a dedicated task, unlike general-purpose computers.
3. Low Power Consumption:
o Optimized for energy efficiency, especially for battery-operated systems.
4. Memory Constraints:
o Limited RAM and ROM to save costs and power consumption.
5. Reliability and Stability:
o Must operate continuously without failure, often under harsh conditions.
6. Small Form Factor:
o Compact in size, enabling integration into other devices like smartphones or
appliances.
1. Definition:
o Allows the highest-priority task to take control of the CPU, even if another
task is running.
2. Features:
o Task switching is immediate when a higher-priority task becomes ready.
o Ensures critical tasks get CPU time without delay.
3. Advantages:
o High responsiveness for real-time applications.
4. Disadvantages:
o Higher overhead due to frequent context switching.
1. Definition:
o Allocates a fixed time slice (quantum) to each task in a cyclic order.
2. Features:
o Fair CPU time allocation among tasks.
o Tasks are executed in a first-come, first-serve manner.
3. Advantages:
o Simple and predictable.
4. Disadvantages:
o May not prioritize critical tasks effectively.
Interfacing Diagram:
89C51 Microcontroller
P2.0 - P2.6 --> A-G segments of 7-segment display
P2.7 --------> Common Cathode/Anode (via transistor)
#include <reg51.h>
unsigned char digits[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66,
0x6D, 0x7D, 0x07, 0x7F, 0x6F};
// 7-segment codes for 0-9 (common cathode)
void delay() {
int i, j;
for (i = 0; i < 1000; i++)
for (j = 0; j < 100; j++);
}
void main() {
int i;
while (1) {
for (i = 0; i < 10; i++) {
P2 = digits[i]; // Send code to 7-segment display
delay(); // Wait for some time
}
}
}