0% found this document useful (0 votes)
22 views4 pages

Embedded Systems Class Test Programs With Comments

The document compares assembly language with embedded C, highlighting differences in execution time, hex file size, coding time, debugging ease, memory requirements, and coding complexity. It lists data types in embedded C along with their sizes and ranges, describes the functions of RS and AW pins of LCD, and provides examples of real-time operating systems (RTOS). Additionally, it includes sample programs for transferring data between arrays, generating a square wave, toggling a port, and comparing data from two ports.

Uploaded by

ompatil27112005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Embedded Systems Class Test Programs With Comments

The document compares assembly language with embedded C, highlighting differences in execution time, hex file size, coding time, debugging ease, memory requirements, and coding complexity. It lists data types in embedded C along with their sizes and ranges, describes the functions of RS and AW pins of LCD, and provides examples of real-time operating systems (RTOS). Additionally, it includes sample programs for transferring data between arrays, generating a square wave, toggling a port, and comparing data from two ports.

Uploaded by

ompatil27112005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Q1: Answer any FOUR out of SIX

Q1 a. Compare between assembly language program with embedded C.

Feature Assembly Language Embedded C


Execution Time Less execution time More execution time
required required
Hex File Size Less More
Time for Coding More Time Required Quicker
Debugging Not so easy Easy
Memory required for program Less memory Required More memory Required
coding
Coding Complexity Complex Simpler

Q1 b. List data types in Embedded C with their size in bit and data range.

- char: Size = 8 bits, Range = -128 to 127 (signed), 0 to 255 (unsigned)

- int: Size = 16/32 bits, Range = -32,768 to 32,767 (16-bit signed), 0 to 65,535 (16-bit unsigned)

- float: Size = 32 bits, Range = ±3.4 × 10^38

- double: Size = 64 bits, Range = ±1.7 × 10^308

Q1 c. Describe the function of RS and AW pins of LCD.

RS (Register Select): Selects data or command register.

RS = 0: Command register (instructions).

RS = 1: Data register (characters).

AW (Read/Write): Controls LCD mode.

AW = 0: Write mode (write to LCD).

AW = 1: Read mode (read from LCD).

Q1 d. Give any four examples of RTOS.

FreeRTOS: Open-source, lightweight, popular in IoT.

VxWorks: Commercial, used in aerospace and automotive.

µC/OS-II: Preemptive, scalable, used in safety-critical systems.

RTLinux: Real-time Linux extension for complex tasks.


Q1 e. List the instruction of Command Register of LCD (any 4).

0x01: Clear display screen.

0x02: Return home.

0x06: Shift cursor to the right.

0x0C: Display on, cursor off.

Q1 f. Describe the function of VDD and VEE pins of LCD.

VDD: Power supply pin (+5V or +3.3V) for the LCD module.

VEE: Controls LCD contrast, usually connected to a variable resistor.


Embedded Systems Class Test - Programs with Comments

Q2 a. Program to Transfer 10 Bytes from Array A to Array B


#include <stdio.h>
void main() {
// Initialize array A with 10 characters
char A[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

// Initialize an empty array B to store copied data


char B[10];

// Loop to copy data from array A to array B


for(int i = 0; i < 10; i++) {
B[i] = A[i]; // Copy each element from A to B
}

// Optional: Display the result of array B


for(int i = 0; i < 10; i++) {
printf("B[%d] = %c\n", i, B[i]); // Print each element in B
}
}

Q2 b. Program to Generate 2kHz Square Wave using 89c51

#include <reg51.h>
// Function to create a delay for generating a 2kHz square wave
void delay() {
// Calculate delay for 500 microseconds using Timer 0
// TH0 and TL0 are set to create the necessary delay based on an 11.0592 MHz crystal
TH0 = 0xFC; // Load high byte for 500 microseconds delay
TL0 = 0x66; // Load low byte for 500 microseconds delay
TR0 = 1; // Start Timer 0
while (TF0 == 0); // Wait for the timer to overflow (500 microseconds)

TR0 = 0; // Stop Timer 0


TF0 = 0; // Clear the timer overflow flag
}
void main() {
// Infinite loop to toggle the pin P1.1 continuously
while(1) {
P1_1 = ~P1_1; // Toggle the state of pin P1.1 to create a square wave
delay(); // 500 microseconds delay for 2kHz frequency
}
}
Q2 c. Program to Toggle Port p0 Continually with a 200ms Delay

#include <reg51.h>

// Function to create a simple 200ms delay


void delay() {
unsigned int i;

// Loop to generate the delay (value may need adjustment for exact timing)
for(i = 0; i < 2000; i++); // Delay loop
}

void main() {
// Infinite loop to toggle Port 0 bits
while(1) {
P0 = ~P0; // Toggle all bits of Port 0
delay(); // 200 milliseconds delay
}
}

Q2 d. Program to Compare Data from Port 1 and Port 2, Send Bigger to Port 3

#include <reg51.h>

void main() {
unsigned char data1, data2;

// Infinite loop to continuously compare data from Ports 1 and 2


while(1) {
data1 = P1; // Read data from Port 1
data2 = P2; // Read data from Port 2

// Compare data from Port 1 and Port 2


if (data1 > data2) {
P3 = data1; // If data1 is greater, send it to Port 3
} else {
P3 = data2; // Otherwise, send data2 to Port 3
}
}
}

You might also like