+ All Categories
Home > Documents > 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time...

5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time...

Date post: 31-Mar-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
16
1 Vidyalankar T.Y. Diploma : Sem. VI [CD/CO] Embedded Systems Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100 Q.1 (a) Attempt any THREE of the following [12] Q.1 (a) (i) Draw the harvard Architecture with neat labeled diagram [4] (A) Q.1 (a) (ii) Compare assembly language and embedded C language [4] (A) Parameter Assembly C Ease of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating Tedious Simple Hex file size Small More Memory required Less More Compatibility Changes with MC Portable Q.1 (a) (iii)Draw and describe the ICE. [4] (A) Emulator or in circuit emulator(ICE) : It is used to debug a target system without using actual processor. It allows the program to be tested on actual hardware system with the facilities like break points or single stepping. ICE connected between the host computer and board to be tested. Q.1 (a) (iv) State the functions of E,RS,WR and Busy of LCD module. [4] (A) RS :Register Select :There are two important register inside the LCD i.e Instruction Command code register and data register. The RS pin is used for their selection. If RS=‘0’ : Instruction Command Code Register RS=‘1’ : Data Register. R/W: Read/Write: This input allows the users to write information to the LCD or read information from the LCD. R/W=‘0’: Write , R/W=‘1’: Read E: Enable: The enable pin is used by the LCD to latch the information presented to its data pins when data is supplied to data pins a high to low pulse of minimum duration 450ns wide must be applied to this pin in order latch information. Vidyalankar
Transcript
Page 1: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

1

Vidyalankar T.Y. Diploma : Sem. VI [CD/CO]

Embedded Systems Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100

Q.1 (a) Attempt any THREE of the following [12]Q.1 (a) (i) Draw the harvard Architecture with neat labeled diagram [4](A)

Q.1 (a) (ii) Compare assembly language and embedded C language [4](A)

Parameter Assembly C Ease of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating Tedious Simple Hex file size Small More Memory required Less More Compatibility Changes with MC Portable

Q.1 (a) (iii)Draw and describe the ICE. [4](A) Emulator or in circuit emulator(ICE) : It is used to debug a target system without using actual

processor. It allows the program to be tested on actual hardware system with the facilities like break points or single stepping. ICE connected between the host computer and board to be tested.

Q.1 (a) (iv) State the functions of E,RS,WR and Busy of LCD module. [4](A) RS :Register Select :There are two important register inside the LCD i.e Instruction

Command code register and data register. The RS pin is used for their selection. If RS=‘0’ : Instruction Command Code Register RS=‘1’ : Data Register.

R/W: Read/Write: This input allows the users to write information to the LCD or read information from the LCD. R/W=‘0’: Write , R/W=‘1’: Read

E: Enable: The enable pin is used by the LCD to latch the information presented to its data pins when data is supplied to data pins a high to low pulse of minimum duration 450ns wide must be applied to this pin in order latch information.

Vidyala

nkar

Page 2: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

2

Q.1 (b) Attempt any ONE of the following [6]Q.1 (b) (i) Draw the embedded software development cycle and describe. [6](A)

SOFTWARE DEVELOPMENT LIFE CYCLE: 1. Requirement gathering and Analysis: During requirement gathering, the specific requirement

of the software to be built and gathered and documented. If the software is bespoke software then there is single customer who can give these requirements. The requirement gets documented in the form of a system requirements specification document. This document acts as a bridge between customer and the designer chartered to build the product

2. Planning: The purpose of planning phase is to come up with a schedule, the scope and resource of requirements for a release. A plan explains how the requirements will be met and by which time. It needs to take into account the requirements-what will be met and what will not be met-for the current release to decide on the scope for project, look at resource availability and to come out with set of milestones and release date for the project.

3. Design: The purpose of the design phase is to figure out how to satisfy the requirements enumerated in system requirement specification document. The design phase produces a representation that will be used by the following phase, the development phase. The representation should serve two purposes. First, from this representation, it should be possible to verify that all the requirements are satisfied. Second, this representation should give sufficient information for the development phase to proceed with the coding and implementation of the system.

4. Development and Coding: Design acts as a blueprint for the actual coding to proceed. This development or coding phase comprises coding the programs in the chosen programming language. It produces the software that meets the requirements the design was meant to satisfy. In addition to programming, this phase also involves the creation of product documentation.

5. Testing: As the program are coded (in the chosen programming language), they are also tested. In addition, after the coding is complete, the product is subjected to testing. Testing is the process of exercising the software product in pre-defined ways to check if the behavior is the same as expected behavior.

6. Deployment and Maintenance: Once a product is tested, it is given to the customer who deploy it in their environments. As the users start using product in their environment they may observe dependencies between the actual behavior of the product and what they were given to expect. Maintenance is made up of corrective maintenance (for example, fixing customer-reported problem), adaptive maintenance (for example, making the software run on new version of an operating system or database), and preventive maintenance (for example, changing the application program code to avoid a potential security hole in an operating system code)

Q.1 (b) (ii) Define multitasking. Describe the process of multitasking with suitable example. [6](A) Define multitasking. Describe the process of multitasking with suitable example.

The ability of operating system to hold the multiple tasks (processes) in memory and allot CPU for each task by task switching is known as multitasking. Multitasking involves scheduling of CPU time among various tasks as per scheduling algorithm.

Vidyala

nkar

Page 3: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

3

The co- operative multitasking, pre emptive multitasking and non pre emptive multitasking has the following scheduling algorithms First come first served /FIFO Last come First served/LIFO Shortest Job First Scheduling Priority based Scheduling Round Robin scheduling. Non pre emptive : First come First served : This algorithm allocates the CPU time to task based on the order in which they enter the ‘Ready’ queue. The first entered task gets the service first. The draw back of this method is that it supports monopoly of the task. A task does not need any input/output operation, continues it’s execution until it finishes it’s task. If the tasks contain any input output operation, the CPU is relinquished by the task. In general FCFS favours CPU intensive usage tasks and input/output intensive usage task.

Q.2 Attempt any FOUR of the following : [16]Q.2 (a) Draw the architecture of 8051 [4](A)

Q.2 (b) Write 80C51 ‘C’ Program to toggle bit of P1.5 continuously with a 250ms. Use the

timer interrupt delay. [4]

(A) Consider the mode ‘1’ of the timer. The maximum delay generated in mode ‘1’ is 71.7ms.Therefor to generate the delay of 250ms the timer is operated for 3.48 = 3 times. # include <stdio.h> # include<reg51.h> sbit wave = P1^5; void main ( ) { While(1) { unsigned intx,y; for (x=0;x<3;x++) { Wave = 0; TMOD=0x00; TH1=0x00; TL1= 0x00; TR1=1; While (TF1= =0)

Vidyala

nkar

Page 4: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

4

TR1=0; TF1=0; } for (y=0;y<3;y++) { Wave = 1; TMOD=0x00; TH1=0x00; TL1= 0x00; TR1=1; While (TF1= =0) TR1=0; TF1=0; } } }

Q.2 (c) Write 80C51 assembly language program to add two BCD numbers. [4](A) MOV A,#99

MOV R1,#99 ADD A,R1 DA A MOV 20H,A MOV A,#00 ADDC A,#00 MOV 21H,A

Q.2 (d) Write an assembly language program to multiply data in RAM location 22H by the

data in RAM location 15H.Put the result in external RAM 80H and 81H. [4]

(A) MOV A,22H MOV B,15H MUL AB MOV R1,#80H MOVX @R1, A MOV A,B INC R1 MOVX @R1,A

Q.2 (e) Define the semaphore and deadlock. [4](A) Semaphore :

RTOS kernels provide a semaphore to ensure the integrity of data during sharing the common data.

Resource count and a wait queue is associated with semaphore where the resource count shows availability of resource and the wait queue manages the tasks waiting for resources from the semaphore.

A semaphore functions as a manager which decides whether a task has the access to the resource.

When task acquires the semaphore, it receives an access to the resource. The number of times the semaphore can be acquired by the task is determined by the

resource count of a semaphore. The resource count is decremented by one, when a task acquires the semaphore and its

resource count is incremented by one when a task releases the semaphore.

Vidyala

nkar

Page 5: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

5

Deadlock : A deadlock is a situation in which two or more tasks or processes waiting for each other to

release a resource, or more than two processes are waiting for resources in a circular chain and neither request can be satisfied.

Deadlock is a common problem in multiprocessing and multitasking where numbers of tasks or processes share a specific type of mutually exclusive resource.

Now a day, the computers or embedded systems designed for the time-sharing or real time are equipped with a hardware lock which provides exclusive access to processes, forcing serialized access.

There is no general solution to avoid deadlocks. Q.2 (f) State any 4 specifications of an embedded system with their significance of it. [4](A) 1. Single-functioned: An embedded system usually executes only one program, repeatedly.

For example, a pager is always a pager. In contrast, a desktop system executes a variety of programs, like spreadsheets, word processors, and video games, with new programs added frequently. Tightly design to execute single program Single purpose Some are multifunction but single purpose

2. Tightly constrained: All computing systems have constraints on design metrics, but those on embedded systems can be especially tight. A design metric is a measure of an implementation’s features, such as cost, size, performance, and power. Low cost Simple function Fewer component based Perform fast function Low power dissipation

3. Reactive and real-time: Many embedded systems must continually react to changes in the system’s environment, and must compute certain results in real time without delay. For example, a car's cruise controller continually monitors and reacts to speed and brake sensors. It must compute acceleration or decelerations amounts repeatedly within a limited time; a delayed computation result could result in a failure to maintain control of the car. In contrast, a desktop system typically focuses on computations, with relatively infrequent (from the computer’s perspective) reactions to input devices. In addition, a delay in those computations, while perhaps inconvenient to the computer user, typically does not result in a system failure.

4. Reliability: Sometimes our PC hangs, while we are working on it. We need to reset the system, if such situation occur. But this is not possible in case of embedded system Because we use our embedded system for some critical work. Sometimes reset pin is also not available for such system. If such situation occur in the embedded system then there should be automatic reset in the system.

5. Limited user interface: Our desktops have full-fledged IO devises so can be used by any number of users. But embedded system do not have sophisticated interfaces for IO. Some of the embedded system do not have any IO devices available for user. Therefore there are limited user interface.

6. HW-SW systems Software is used for more features and flexibility Hardware (processors, ASICs, memory etc. are used for performance and security

OR Real time and multirate operation: It define the ways in which the system works, react to evens, interrupt and schedule the system. Complex algorithm: The algorithm is application specific so it is not simple.

Vidyala

nkar

Page 6: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

6

Complex graphic user interface: Since it should be user friendly, it should contain complex graphic user interface. Dedicated function: This is application specific. So the system should design for dedicated function. Power dissipation: Power dissipation should be low if the system is running for long time.

Q.3 Attempt any FOUR of the following : [16]Q.3 (a) What do you meant by device drivers? [4](A) Each devices in a system needs drivers routines. An ISR related to a device driver functions.

A device driver is a function used by a high level language programmer and does the interaction with the device hardware and communicates the data to the device, sends control commands to the device and runs the code for reading the device data.

The device driver is designed for generic commands 1. configuration or initialisation 2, Activating 3. Driving 4. Resetting IO 5. connect 6. Bind 7. Read 8. Write 9. Delete 10. Close etc.

The device driver functions uses software interrupts instruction SWI which initiates the interrupt service. The device uses the system and I/O buses required for device service, device drivers can bet considered as a function in software layer of an application program and the device. The device driver routine control a device without requiring understanding of the device configuration, control, status data and other registers, when using generic function. Device driver runs the ISR of the device. Each ISR is the low level part of the device driver generic function which executes on software interrupt Instruction .e.g. LCD display device drivers in mobile phones.

Application program sends the command to write a name (text) on LCD screen on mobile. The device driver calls SWI and an ISR performs the function without the application programmer knowing the interfacing hardware, its addresses used command and status register information.

Q.3 (b) Find the contents of port after execution of the following code. (i) P2 = ~ 0xFF (ii) ACC = ACC & 0x00

[4]

(A) (i) P2 = ~ 0xFF P2 = 0 × 00 (ii) ACC = ACC & 0x00 ACC = 0 × 00 Q.3 (c) Describe the functions performed by RTOS. [4](A) The operating system supervises the application software running on hardware and organizes

access to resources according the priorities of the tasks or event occurrence. The real time operating systems performs 1. Multitasking: simultaneously performing more that one task. 2. Manages the software and hardware resources 3. Providing services to the applications 4. Decides the scheduling polices customized for real time applications to meet the deadlines

of tasks 5. Scale up or scale down O.S. for application Collects the software for consistently in controlling hardware.

Q.3 (d) Give the classification of embedded system. [4](A) Embedded systems are classified in 3 parts:

Small scale 8 bit or 16 bit microcontroller is used. Medium scale 16 bit or 32 bit microcontroller or microprocessor is used. Such as DSP, Risc. Sophisticated embedded system ASIP, ARM, IP processors are used.

Vidyala

nkar

Page 7: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

7

Q.3 (e) Write 89C51 ‘C’ Program to rotate stepper motor 90 degree in clock wise direction. Motor has step angle of 2 degree . Use the stepper motor in full step sequence.

[4]

(A) #include<reg51.h> #define PhaseA 0x09; #define PhaseB 0x0C; #define PhaseC 0x06; #define PhaseD 0x03; void delay(unsigned int); void main() { unsinged int p; for (p=0;p<11; p++) { P1=PhaseA; delay(100); P1=PhaseB; delay(100); P1=PhaseC; delay(100); P1=PhaseD; delay(100); } While (1) {} } void delay(unsigned int t) { unsigned int j, k; for(j=0; j<t; j++) for(k=0; j<1275; k++); }

Q.4 (a) Attempt any THREE of the following : [12]Q.4 (a) (i) Draw the format of SCON and describe all bits [4](A)

Vidyala

nkar

Page 8: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

8

Q.4 (a) (ii) Define the following assembler directives CODE, DATA, XDATA.

[4]

(A) CODE : It is the address of the program memory (0000 to FFFF) DATA : It is the address of internal RAM and address of special function register. XDATA : It is the address of external data memory (0000 to FFFF)

Q.4 (a) (iii)State the function of pins : VPP,EA,PSEN,Prog,ALE [4](A)

Symbol Status Description ALE

Output

It is used to demultiplex address and data bus, AD0-AD7.

PSEN

Output It is used to read the content of program available in external ROM or It is used to read the extent of external ROM.

EA

Input When EA is connected to logic 0 external access is enabled else disabled.

VPP Input It is the EPROM programming voltage Q.4 (a) (iv) Differentiate RTOS with desktop operating system (Any four points). [4](A)

RTOS Desktop OS Predictable schedule Unpredictable but efficient schedule More deterministic Less deterministic Ability to scale up and down to meeting application needs (scalable)

Less scalability

Fast context switching Higher context switch latency. Uses priority pre-empitve scheduling Uses round robin way of scheduling. Support for diskless embedded systems by allowing executables to boot and run from RAM or RAM

Has to be booted from disk

Reduced memory requirements More memory requirements. Faster performance slower

Q.4 (b) Attempt any ONE of the following : [6]Q.4 (b) (i) Write 89C51 ‘C’ Program to transfer the message “MSBTE” serially at 4800

baudrate continuously. Use 8 bit data and 1 stop bit. [6]

(A) #include <stdio.h> #include <reg51.h> void sertext (unsigned char) ; void main( ) { TMOD = 0x20 ; SCON = 0x50 ; TH1=0xFA ; TR1 = 1 ; sertext ('M') ; sertext ('S') ; sertext ('B') ; sertext ('T') ; sertext ('E') ; while (1) {

Vidyala

nkar

Page 9: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

9

} } void sertext (unsigned char x) { SBUF = x ; while (TI = = 0) ; { TI = 0 ; } }

Q.4 (b) (ii) Write ‘C’ language program to generate following waveform continuously

using DAC0808. The reference voltage for DAC is 5Vdc.

[6]

(A) Given from wave form 5V=FF, 4V=CC, 3V=99,2V=66,1V=33,0V= 00. For dely of 10ms Timer 1 mode 1 count = DBA6 #include <stdio.h> #include <reg51.h> sbitcs = P3^3 ; sbitwr = P3^4 ; sbitxfer = P3^5 ; void delay () void main( ) { cs = 0 ; while (1) { wr = 1 ; xfer = 1 ; P1 = 0x00 ; xfer = 0 ; wr = 0 ; Delay( ) wr = 1 ; xfer = 1 ; P1 = 0x33 ; xfer = 0 ; wr = 0 ; Delay( ) wr = 1 ; xfer = 1 ; P1 = 0x66 ; xfer = 0 ; wr = 0 ; Delay( ) wr = 1 ;

Vidyala

nkar

Page 10: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

10

xfer = 1 ; P1 = 0x99 ; xfer = 0 ; wr = 0 ; Delay( ) wr = 1 ; xfer = 1 ; P1 = 0xCC ; xfer = 0 ; wr = 0 ; Delay( ) wr = 1 ; xfer = 1 ; P1 = 0xFF; xfer = 0 ; wr = 0 ; Delay( ) } } Void delay () { TMOD = 0x10; TH1= 0xDB; TL1=0xA6; TR1; While (TF1==0) TR1=0; TF1=0; }

Q.5 Attempt any FOUR of the following : [16]Q.5 (a) Why 8051 is known as Boolean processor? [4](A) Generally the CPU performs numerical calculation on bytes. This is useful in numeric

processing. However controller deals with bits not bytes. The microcontroller is used to turn ON and OFF the switch, motor, relay ,indicator,LEDs etc. It is also used to monitor LOW or HIGH state of sensor or logic devices. The 8051 microcontroller provides all above facilities with bit level logical instructions,bit level memory addresses. Total 17booleaninstructions.It can operate on 144 general purpose bits of RAM. The SFR of 8051 are also bit addressable .

Q.5 (b) Interface 4x4 matrix key pad to 8051 and write the C language program to send the

key code on any port. [4]

(A) #include <stdio.h> #include <reg51.h> #define ROW P1 #define COL P3 void delay(unsigned int); void main ( ) { unsigned char keypad[4][4] ={ ‘0’ , ‘1’ , ‘2’ , ‘3’ , ‘4’ , ‘5’ , ‘6’, ‘7’ , ‘8’ , ‘9’, ‘A’ , ‘B’, ‘C’ ,

‘D’ , ‘E’ , ‘F’ } ; unsigned char colloc , rowloc ;

Vidyala

nkar

Page 11: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

11

COL = 0xFF; while(1) { do { ROW = 0x00 ; colloc = COL ; colloc &= 0x0F ; } while (colloc!= 0x0F) ; do { do { delay (20); colloc = COL ; colloc &= 0x0F ; } while (colloc == 0x0F) ; delay (20); colloc = COL ; colloc &= 0x0F ; } while (colloc == 0x0F) ; while(1) { ROW = 0xFE ; colloc = COL ; colloc &= 0x0F ; if (colloc!= 0x0F) { rowloc = 0 ; break ; } ROW = 0xFD ; colloc = COL ; colloc &= 0x0F ; if (colloc!= 0x0F) { rowloc = 1 ; break ; } ROW = 0xFB ; colloc = COL ; colloc &= 0x0F ; if (colloc!= 0x0F) { rowloc = 2 ; break ; } ROW = 0xF7 ; colloc = COL ;

Vidyala

nkar

Page 12: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

12

colloc &= 0x0F ; rowloc = 3 ; break ; } if (colloc == 0x0E) P0 = keypad [rowloc][0] ; else if (colloc == 0x0D) P0 = keypad [rowloc][1] ; else if (colloc == 0x0B) P0 = keypad [rowloc][2] ; else P0 = keypad [rowloc][3] ; } } void delay (unsigned int i) { unsigned int x , y ; for ( x = 0 ; x < i ; x++ ) s for ( y = 0 ; y < 1275 ; y++) ; }

Q.5 (c) List the method of IPC and describe any one. [4](A) Message Pipes Signal RPC and Socket

Signal : A system message sent from one process to another, not usually used to transfer data but instead used to remotely command the partnered process.

Q.5 (d) State any 4 features of IDE and ICE. [4](A) 1. Facility for defining a processor family as well as defining its version.

2. Includes source code engineering tools that incorporate the editor, compiler for C and embedded C++,

3. It has a source code engineering tools such as Assembler, linker, locator, logic analyser, stethoscope, and help to user

4. Optimizes the use of memory 5. It provides the multiuser environment 6. Design process division in to a number of sub parts. 7. Simulation of hardware such as emulator, peripherals and I/O devices on a host PC 8. Supports break points 9. Debugging facility 10. Verification of performance of the target system. 11. Includes a logic analyzer for up to 256 or 512 transactions on the address and data buses

after triggering Features of ICE It is used to debug a target system without using actual processor. 2. It allows the program to be tested on actual hardware system 3. It provides the facilities like break points or single stepping. 4. ICE connected between the host computer and board to be tested.

Vidyala

nkar

Page 13: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

13

Q.5 (e) Interface LCD to 8051 and write the C language program to Display "KPA" on it. [4](A)

#include <stdio.h> #include <reg51.h> sfrIdata = 0x90 ; sbitrs = P3^3 ; sbitrw = P3^4 ; sbiten = P3^5 ; sbit busy = P1^7 ; void delay ( unsigned int ); void lcdcmd ( unsigned char ); void lcddata ( unsigned char ); void lcdready ( ) ; void main ( ) { lcdcmd(0x38); lcdcmd(0x0F); lcdcmd(0x01); lcdcmd(0x06); lcdcmd(0x86); lcddata('K'); lcddata('P'); while (1) { } } void lcdcmd (unsigned char value ) { lcdready( ) ; Idata= value ; rs = 0 ; rw = 0 ; en = 1 ; delay (1); en = 0 ; return ; } void lcddata (unsigned char value ) { lcdready( );

Vidyala

nkar

Page 14: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

14

Idata= value ; rs = 1 ; rw = 0 ; en = 1; delay (1); en = 0 ; return ; } void lcdready( ) { busy = 1 ; rs = 0 ; rw = 1 ; while (busy = = 1) { en = 0 ; delay (1) ; en = 1 ; } return; } void delay ( unsigned inti ) { unsigned int j , k ; for ( j = 0 ; j <i ; j++) ; for ( k = 0 ; k < 1240 ; k++) ; }

Q.5 (f) What do you mean by starvation? [4](A) Starvation is the problem caused in multitasking system. When a process does not get the

required resources for a long time then it is referred as starvation. The priority based scheduling algorithms executes the processes. Always the higher priority task

art of the ready queue get the chance to be executed. The priority can be assigned while creation of the task of SJF (shortest job first) assign the

highest priority to the task which has minimum execution time. If there are two tasks in the ready queue, A and B the task with highest priority (say B) is

executed first and A is waiting for B to be completed. Now if in between some other task having higher priority than task A is ready in queue. The task A will not be executed and if any other high priority task is dependent on the results obtained by task A. then the higher priority task will not be executed as A is not executed.

Thus the task A is not getting the required resource for its execution for the long time. This is called as starvation.

Thus starvation is said to occur when a task with a lower priority is not getting a chance to executed if more and more processes with higher priorities enter the ready queue before the process with lower priority state is executed.

If can be effectively solved by dynamically raising the priority of the low priority task which is under starvation this technique is called as “aging”.

Vidyala

nkar

Page 15: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Prelim Question Paper

15

Q.6.Attempt any FOUR of the following : [16]Q.6 (a) State the functions of following Instructions SWAP A, XCHD A,@R0,XCH

A,R1,CPL A [4]

(A) WAP A Interchange the nibbles of register A: put the high nibble in the low

nibble position and the low nibble in the high nibble position CPL A Complement each bit of A: every I becomes a 0, and each 0

becomes a 1 XCHD A@Rp Exchange lower nibble between A and address in Rp XCH A.Rr Exchange data bytes between register Rr and A

Q.6 (b) Draw the port structure of P0 and P3 of 8051. [4](A)

P0 P3

Q.6 (c) Write a ‘C’ or assembly language program to generate the square wave of 1KHzfrequency on P3.0 using interrupt.

[4]

(A) Consider the mode ‘1’ of the timer. Therefore to generate the delay of 0.5ms Count = FE34H # include <stdio.h> #include<reg51.h> sbit wave = P3^0; void timer0(void) interrpt1 { wave= ~wave; TH0=0xFE; TL0=0x34; } void main ( ) { TMOD=0x01; IE=0x82; TH1=0xFE; TL1= 0x34; TR1=1; While (1) {} }

Q.6 (d) Draw labeled interfacing diagram to interface LED to P3.1 of 89C51. Write 89C51

‘C’. Program to turn on and off LED after some delay. [4]

(A) #include<reg51.h> sbit LED = P3^1 void delay ( unsigned int ) void main() { while (1)

Vidyala

nkar

Page 16: 5 ES Soln - Vidyalankarvidyalankar.org/upload/5_ES_Soln.pdfEase of writing Program Complex Easy Time for coding More Less Time for execution Less More Debugging Tedious Simple Updating

Vidyalankar : T.Y. Diploma ES

16

{ LED =~LED Delay (100) } } void delay(unsigned int t) { unsigned int j, k; for(j=0; j<t; j++) for(k=0; j<1275; k++); }

Q.6 (e) Write Logical operators in ‘C’ for AND, OR, EXOR and NOT for 89C51and state

one example of each. [4]

(A) AND = & , OR = | , EXOR= ^ ,NOT= ~

Vidyala

nkar


Recommended