Vous êtes sur la page 1sur 16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Microcontrollers & Embedded Systems


Recommend 3.4k

Press Ctrl & '+' To enlarge text and pics!

CHAPTERS
Home Topics

Home

Chapter 6 : Introduction to an Embedded System and ITs Design

Chapter 1 : Introduction Chapter 2 : 8051 Assembly Language Programming Chapter 3 : Jump, Loop and Call Instructions : I/O Port Programming Chapter 4 : Serial Communication Chapter 5 : Real World Interfacing Chapter 6 : Introduction to an Embedded System and ITs Design

Q. 1. What is an embedded system? Ans. It is an electronic device that incorporates micro processors within its implementation. The main task of an embedded system is to perform one and only one task. Hence, software is stored in ROM chip. Q. 2. What are the applications of an embedded system? Ans. Embedded systems are found in wide range of application areas. Initially they were used for expensive industrial control applications. Today embedded systems have become so inexpensive that they are used in almost every electronic product in our life. Applications 1. Aerospace e.g. Navigation systems, space exploration. 2. Automotive e.g. GPS mapping, air bag controls, fuel injection control. 3. Children Toys e.g. Video games, Robots 4. Communications e.g. satellite, hubs, switches. 5. Computer Peripherals e.g. printers, keyboards, modems, scanners etc. 6. Home e.g. VCRs cameras, sewing machines, intercom. 7 Industrial e g robots, Elevator Control 8. Medical e.g. patient monitors, heart pacers. Q. 3. In embedded system, the system performance depend upon which parameters? Ans. This parameter specifies the execution time of an embedded system. It is a measure of the time required for the embedded system to execute the desired task. The system performance is dependant on the clock frequency on the instructions per second. The two main measures of system performance are: 1. Latency time: This is time required for the complete execution of a task. 2. Through put: A number of task can be simultaneously carried out per unit time eg. a digital camera. Q. 4. Determine whether 8051 can be used to execute single program instruction (single stepped) using external circuitry (no software) only? Ans. 8051 has no on-chip ROM. In 8051 it is possible to execute a single instruction by using PSEN (Program Store Enable) signal. PSEN is output signal and must be connected to OE pin of ROM containing the program code. It is important to emphasize the role of EA and PSEN when connecting 8031/51 to external ROM. When EA pin is connected to GND, the 8031/51 fetches opcode from external ROM by using PSEN. Q. 5. What are the two conditions under which program of codes are latched from external rather than internal memory? Ans. We connect the EA pin to indicate the program code is stored in microcontrollers on-chip ROM.

Loremate.com on
Facebook Like 3,483

ptuece.loremate.com/microcontroller/node/8

1/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

To indicate the program code is stored in external ROM, this pin must be connected to GROUND. 2. If our program exceed from 4K then stil EA pin is connected to GROUND. Q. 6. Mention and briefly describe the powerful features, the serial port of 8051. Ans. Serial communication is used for transferring data between two systems located at distances of 100s of feet to millions of miles apart.

In this a single data line is used, the byte of data must be converted to serial bits using a parallel-in-serial out shift register, then it can be transmitted over a single data line. Serial data communication uses two methods, asynchronous and synchronous. Q. 7. What are the features of ARM instruction set? Ans. It includes a number of features designed to allow the CPU to better pipeline them for execution. ARM design use of a 4-bit condition code on the front of every instruction, meaning that every instruction can be made a conditional. It also the ability to fold shifts and rotates into data processing (arithmetic, logical, registerregister move) instructions, eg. the C statement a + = (J << 2), could be rendered as single instruction on ARM, register allocation permitting. It has also some features rarely seen on other architectures that are considered RISC, such as PC-relative addressing and pre-and post-increment addressing modes. Most of earlier ARM processors have 3 stage pipeline, the stages being fetch, decode and execute. Higher performance processor such as ARM have 5 stage pipeline. Q. 8. What do you understand by software partitioning? Ans. It is task of Mapping the processes to the processors. A process can be implemented on multiple processors as well multiple process can be implemented on a single processor. The variables should be partitioned amongst the memories, buses. Q. 9. What do you understand by Allocation? Ans. It is the task of selecting the numbers and types of processors to implement the processors. It includes selecting the processors, memories and buses. It is design of system architecture. Q. 10. What is the mean of scheduling? Ans. It is task of finding out when each of multiple processes on the single processor will achieve a change to execute on the processor. The synthesis tools today have change the designers tack to write sequential programs with knowledge about hardware that is to be synthesized. Q. 11. List reasons that LCDs are gaining wide spread use, replacing LEDs. Ans. 1. The declining pieces of LCDs. 2. The ability to display numbers, characters, and graphics. This is in contrast to LEDs, which are limited to numbers and a flew characters. 3. Incorporation of a refreshing controller into LCD, there by relieving the CPU of the task of refreshing LCD. In contrast, LED must be refreshed by CPU to keep displaying the data. Q. 12. Discuss instruction command codes for programming on LCD.
ptuece.loremate.com/microcontroller/node/8 2/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Ans. The instruction command codes that can be sent to LCD to clear the display or force the cursor to home position or blink the cursor. RB = 0 to check the busy flag bit to see if LCD is ready to receive information. The busy flag is D7 and can be read with when R/W =1 and RS 0 when D7 1, LCD is busy taking care of internal operations and will not accept any new information. When D7= 0, LCD is ready to receive new information. Q. 13. List design technology of an Embedded System. Ans. It involves in the way which we implement the concept of designed system functionality. In order to improve the embedded system design, one must know the entire design process. One process is top down process, which is carried out since past decade.

In this process the designer defines the system with help of several abstraction levels. At system level, the designer describes the system functionality in some language like English but preferable an executable language like C called system specification. The designer defines these specifications by distributing portions of it among several general or single purpose processors, yielding behavioral specification for each processor. The designer then converts these specifications to register transfer specifications by converting the behavior on general purpose processors to assembly code. Then designer refines the RT level specification of single purpose processor to logical specifications. Finally the designer refines the remaining specifications into an implementation, that consist of machine code for General Purpose Processor and a gate level net list for Single Purpose Processors. Q. 14. Explain the design parameters of Embedded System (ES). Ans. The various parameters of ES are : 1. Power :The amount of power consumed by system. By knowing the amount of power required by a system we may determine the lifetime of a battery, cooling requirements for an Integrated circuit etc. 2, Non recurring Engg. cost (NRE cost) : It is one time momentary costs that is required at the time of designing the system. A number of units can be designed. Once a system is designed, additional design cost is not required for other units. 3. Reliability: The system should be able to work properly even if anything happens to the system. The system software must cope up with all kinds of situations without human intervention. The amount by which system software can cope with the situations without any interventions decides the reliability of embedded system. 4. Response time: It is time required for embedded system to react to certain situations or events quickly. The response time must be as small as possible. 5. Flexibility: It is the amount by which the designer can change the functionality of ES without bearing a heavy NRE cost. Generally the software of ES is more flexible. 6. Maintainability: It is the ability by which the designer can change the ES after system has been released.
ptuece.loremate.com/microcontroller/node/8 3/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

7. Safety: This parameter indicates the probability by which system is safe to user i.e. it indicates the probability that system will not be harmful to the user. 8. Correctness : This parameter is of importance because it gives the user a confidence that he has been successful in implementing the ES functionality correctly while the entire process is being designed systems functionality can be tested by test circuitry. 9. Memory size: An ES must be designed such that the design meets with all system requirements and acquires a finite amount of memory space. The memory space is normally restricted. 10. Unit cost: It includes the cost that is required for producing each unit of ES. It is found out excluding NRE cost. 11. Time to prototype: It specifies the time i.e. required for an ES to construct a working version of system. The working version of system may be bigger or expensive than final system that is to be implemented. 12. Performance: It specifies the execution time of ES. For good system performance it is recommended that execution time should be as small as possible. 13. Time to Market: It specifies the time required to develop the ES, so that ES can be released and sold to the customers. Time is dependent on design time, manufacturing time and testing time. 14. Test ability: It is ability of ES to prepare a setup to test the embedded system software. Q. 15. Write a short note on software/hardware co design. Ans. Hardware of processor : An embedded system designer may create a single processor by designing a custom digital circuit or designer can purchase a pre-designed single purpose processor. This portion is called as hardware of processor. Software : An ES designer uses a general purpose processor, by programming the processors memory to carry out required functionality. This portion of implementation is called as software. The hardwire/software co design emphasizes on unified view of hardware and software and develops synthesis tools and simillators that allow the co-development of systems using both hardware and software. It is extensively used in research community to high research. The research focuses on the requirements of simultaneous consideration of both hardware & software during synthesis. Q. 16. Explain ARM processor. Ans. It is originally the Acorn RISC Machine which is a 32-bit RISC processor that is widely used in a number of applications. ARM variants are in widespread use in embedded and low-power applications due to their power saving design features. A conexant ARM processor used mainly in routers. The ARM 2 processor has 32-bit data bus, 26-bit address space and sixteen 32-bit registers. One of these registers served as program counter with its top 4 bits and lowest 2-bits holding the processor status flags. The ARM2 was possibly the simplest useful 32-bit micro processor in the world, with only 30,000 transistors. A successor ARM3 was produced with 4kB cache which further improved performance. In late 1980s Apple Computer started working with Acorn on newer versions of ARM core. The work was so important that Acorn spun off the design team in 1990 into a new company called Advanced RISC Machines. For this reason ARM lengthened to advanced RISC machine. The core has remained largely the same size throughout these changes. ARM2 had 30,000 transistors, while ARM 6 grew to only 35,000. The idea is that the end user combines ARM core with a number of optional parts to produce a complete CPU, one that can be built on old fabs and still deliver lost of performance at low cost The ARM chip has become one of most used CPU designs in the world, found in everthing from hard drives, to mobile phones, to routers, to calculators, to childrens toys
ptuece.loremate.com/microcontroller/node/8 4/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Q. 17. Write a short note on present trends in Embedded system? Ans. The far most important trend in ES is trend related to ICS. It is also called Moors Law.

Moore also predicted some decade ago that such exponential growth slows dowrt. T is mainly caused due to the improvements in IC manufacturing in smaller parts. T minimum part size for CMOS IC in 2002 was approx. 130 nanometers. Above - diagram shows the chip capacity in millions of transistor per chip per year from 10 to 2010 plofted on logarithmic scale. The trend of increasing chip capacity has allowed low cost high performance embedded systems. Q. 18. Describe the functions of pins of typical LCD Ans. Pin Description for LCD Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Symbol Vss Vcc Vee RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 I/O I I I/O I/O I/O I/O I/O I/O I/O I/O I/O description Ground + 5V power supply Power supply to control contrast RS 0 to select command register RS =1 to select data register. R/W = 0 for white , R/W = 1 for read Enable The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus

ptuece.loremate.com/microcontroller/node/8

5/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Vx, and VEE: V and for controlling LCD contrast. V provide + 5v and ground respectively, VEE is used RS, register select : There are two very important registers inside the LCD. The RS pin is used for their selection. If RS = 0 the instruction command code register is selected, allowing the uses to send a command such as clear display cursor at home etc. If RS = I the data register is selected, allowing the user to send data to be displayed on LCD. R/W, read/write: R/W I/P allows the user to write information to the LCD or read information from it. R/W = 1 when reading, R/W = 0 when writing. E, enable The enable pm is used by LCD to latch information presented to its data pins. When data is supplied to data pins, a high to low pulse must be applied to this pin in order for LCD to latch in the data present at data pins. This pulse must be a minimum of 450ns wide. DOD7 : The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of LCDs internal registers.

Q. 19. Draw pin positions for various LCD from optrex. Ans.

Q. 20. How to send commands to LCD without checking the busy flag? Ans. The better way to monitor the busy flag before issuing a command or data to LCD. This is shown: Check busy flag before This is shown: check busy flag before sending data, command to LCD P1 = data pin P2.0 connected to RS pin P2.1 connected to R/W pin P2.2 connected to E pin ORG MOV A, # 38 H ; mit-LCD 2 lines, 5 x 7 matrix ACALL COMMAND ; issue command M0V A, # OEH ; LCD on, cursor on ACALL COMMAND ; issue command MOV A, # OIH ; clear LCD command ACALL COMMAND ; issue command MOV A, # 86 H ; cursor: line 1, pos.6 ACALL COMMAND _DISPLAY: ACALL COMMAND command subroutine MOV A, # N display letter N MOVA,#O .; display letter 0 ACALL DATA_DISPLAY HERE : SJMP HERE stay HERE COMMAND : ACALL READY
ptuece.loremate.com/microcontroller/node/8 6/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

MOV P1, A CLR P2.0 CLR P2.1 SET B P2.2 CLR P2.2 RET DATA_DISPLAY: ACALL READY MOV P1, A SET B P2.0 CLR P2.1 SET B P2.2 CLR P2.2 RET READY: SET B P1.7 CLR P2.0 SET B P2.1

is LCD ready? issue command code RS = 0 for command R/w 0 to write to LCD E = 1 for H-to-L pulse E =0, latch in

Is LCD ready? issue data RS = I for data R/w = 0 to write to LCD E = 1 for H-to-L pulse E 0 latch in

make P1.7 input port RS = 0 access command reg R/w = 1 read command reg. E = 1 for H-to-L Pulse E = 0 H-to-L pulse stay until busy flag = 0

read command reg & check busy flag BACK : CLR P2.2 SET B P2.2 JB P1.7, BAC1 RET END The Busy flag is D7 of command register. To read the command register we make R/w 1, RS = 0, and a H-to-L pulse for E pin will provide us the command register.. After reading the command register, if D7 bit is high, LCD is busy & no information should be issued to it. Only when D7-0, data or command is send to LCD. In this method no time delays are used.

Q. 21. Draw LCD Timer Diagram. Ans.

tpWH = Enable pulse width 450 ns (minimum) tDsw = Data Set up time = 195ns (mm.) tH = Data hold time = IOns (mm.) tAS = Set up time prior to E (going high) for both RS & R/W = 140 ns (min.) tAH = Hold time after E has come down for both RS & R/W = 10ns (min.)

Q. 22. Show address locations of LCD and how they are accessed? Ans. In LCD, one can put data at any location. Address locations are: PS R/W DB7 DB6 DB5 DB4 DB3 DB2 DBI DBO 0 0 I A A A A A A A where AAAAAAA = 0000000 to 0100111 for line I and AAAAAAA 1000000 to 1100111 for line 2.
ptuece.loremate.com/microcontroller/node/8 7/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

LCA Addressing: DB7 (min) DB6 1 DB5 0 0 1 1 DB4 0 1 0 1 DB3 0 0 0 0 DB2 0 0 0 0 DB1 0 1 0 1 DB0 0 1 0 1 0 1 0 1

Line 1 1 Line 1 1 (max) 1 Line 2 (min) Line 2 (max)

The upper range can go as high as 0100111 for 40 characters wide LCD while for 20character side LCD it goes up to 010011 (19 decimal). Upper range 0100111 = 39 decimal which corresponds to location 0 to 39 for LCD of 40x2 size

Q. 23. Show the interfacing to ADC. Ans ADC is analog to digital converters Digital computers use binary (discrete) values, but in physical world everything is analog (continuous) Temperature, pressure, humidity, and velocity are a few examples of physical quantities A physical quantity is converted to electrical signals using a device called transducer Transducers are also referred to as sensors Although there are sensors for temperature, velocity, pressure, light & many other natural quantities they produce an output that is voltage or current. ADC 804 chip IC is analog to digital converter in the family of ADC 800 series from national semiconductor . It works with + 5volts and has a resolution of 8-bits. In ADC 804, conversion time varies depending on the clocking signals applied to CLKR and CLKIN pins, but it cannot be faster than 110 gus. Conversion time is defined as the time it takes ADC to convert the analog I/P to digital number. ADC 804 pin Description: CS Chip select is an active low I/P used to activate ADC 804 chip To access ADC 804, this pin must be low. RD (Read) This is an I/P signal and in active low ADC converts the analog I/P to its binary equivalent and holds it in an internal register RD is used to get the converted data out of ADC 804 chip When CS = 0, if a high to low pulse is applied to RD pin, 8-bit digital 0/P shows up at D0-D7 data pins The RD pin is also referred to as output enable WR This is an active low input used to inform the ADC 804 to start the conversion process If CS = 0 when WR makes a low to high transition, ADC 804 starts converting the analog I/P value of V to an 8-bit digital number The amount of time it takes to convert varies depending on CLK IN and CLK R values CLK IN an input pin connected to an external clock source when an external clock is used for timing To use the internal clock generator (also called self-clocking) of ADC 804, the CLK IN & CLK R pins are connected to a capacitor and resistor as shown in Diagram In that case the clock frequency is determined by the equation.

R = 10 K ohms, C 150 pF Substitute in above eq we getf= 606 KHz In that case conversion time is 110 ,us CS 0 and send a high to low pulse to RD pin to get data out of ADC 8041C chip. The timing for this process is shown.

ptuece.loremate.com/microcontroller/node/8

8/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Q. 24. How the interfacing of DAC to 8051 is possible? Ans. The digital to analog converter (DAC) is a device widely used to convert digital pulses to analog signals. IC DACs use R/2R method. The first criterion for judging DAC is its resolution, which is a function of number of binary inputs. The common ones are 8, 10 and 12 bits. The number of data bits inputs decides the resolution of DAC since the number of analog output levels is 2, n is number of data bits inputs. In MC 1408 (DAC 808) the digital I/Ps are converted to current (out) and& by connecting a register to out pin, we convert the result to voltage. The total current provided by I pin is a function of binary numbers at DO-D7 I/Ps of DAC 808 and the out reference current (ref) Iout = I ref ( D7 2 4 where DO is LSB, D7 is MSB for I/Ps and ref is the I/P current that must be applied to pin 14. Diagram shows the generation of current reference (ref 2mA) by using 5-V power supply and 1K., 1.5KQ standard resistors. Assuming ref = 2mA, if all the I/Ps to DAC are high, the maximum output current is 1.99 mA. Connect the output pin out .to a resister and convert this current to voltage & monitor the output on the scope. In real life it can cause in accuracy since input resistance of load where it is connected will also affect the output voltage. For this reason, ref current 0/P is isolated by connecting it to an opamp. D6 8 D5 D4 16 D3 32 D2 64 D1 128 D0 ) 256

To generate a sine wave, the values for sine function vary from -1.0 to +1.0 for 0 to 360 degree angles. To find the value sent to DAC for various angles, simply multiply the V0 voltage by 25.60 because there are 256 steps and full scale V0 is 10 volts: 256 steps 10 V = 25.6 steps/volt.

Q. 25. Explain the interfacing a stepper Motor. Ans.


ptuece.loremate.com/microcontroller/node/8 9/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

A stepper motor is widely used device that translates electrical pulses into mechanical movement. It is used for position control. Every stepper motor has a permanent magnet rotor surrounded by stator. The most common stepper motors have 4 stator windings that are paired with center tapped common as shown in diagram. This stepper motor is called 4- phase stepper motor. The center tap allows a change of current direction in each of two coils when a winding is grounded, thereby resulting in polarity change of stator. While a conventional motor shaft runs freely, the stepper motor moves in a fixed repeatable increment which allows one to move it to a precise position. This repeatable fixed movement is a possible as a result of basic magnetic theory where poles of the same polarity repel and opposite poles attract. The direction of rotation is dictated by the stator poles. The stator poles are determined by current sent through the wire coils. As the direction of current is changed, polarity also changed causing the reverse motion of the rotor. As the sequence of power is applied to each stator winding, the rotor will rotate.

4-step sequence:

Fig.. Stator Winding Configuration

TJLN 2003 connection for Stepper Motor Pin8 GNDPin9+5V Use a separate power supply for the motor How much movement is associated with single step depends on the internal construction of the motor, in particular the number of teeth on stator and the rotor.
ptuece.loremate.com/microcontroller/node/8 10/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

The step angle is minimum degree of rotation associated with a single step. Various motors have different step angles called steps per resolution. The relation between RPM, steps per revolution and steps per second is intuitive and is:

In 4-step sequence, after completing every four steps, rotor moves only one tooth pitch. Therefore, in stepper motor with 200 steps per revolution, its rotor has 50 teeth, since 4 x 50 = 200 steps are needed to complete one revolution. Means the smaller the step angle the more teeth the rotor passes. To allow for finer resolutions, all stepper motors allow called 8-step switching sequence or half stepping. Half step 8-step sequence: Clockwise Step # 1 2 3 4 5 6 7 8 Winding A 1 1 1 0 0 0 0 0 Winding B 0 0 1 1 1 0 0 0 Winding C 0 0 0 0 1 1 1 0 Winding D 1 0 0 0 0 0 1 1

The motor speed measured in steps/second is a function of switching rate.

Fig. Using Transistors for Stepper Motor Drive

Q. 26. Discuss the interfacing to the keyboard. Ans. At the lowest level keyboards are organized in a matrix of rows and scolumns. The CPU accesses both rows and columns through ports. Therefore with two 8-bit ports, an 8 x 8 matrix of keys can be connected to microprocessor. When a key is pressed a row and a column make a contact; otherwise there is no connection between rows and columns. In IBMPC keyboards, a single microcontroller takes care of hardware and software interfacing of keyboard. In such systems, it is software interfacing of keyboard. In such systems, it is function of programs stored in EPROM of microcontroller to scan the keys continuously, identify which one has been activated, and present it to the motherboard.

ptuece.loremate.com/microcontroller/node/8

11/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Fig. Matrix keyboard Connection to Ports Diagram shows 4 x 4 matrix connected to two Ports. The rows are connected to an output port and the columns are connected to an Input port. If no key has been pressed, reading the I/P port will yield ls for all columns since they are all connected to high (Vcc). If all rows are grounded and key is pressed one of the columns will have 0 since the key pressed provides the path to ground. It is function of microcontroller to scan the keyboard continuously to detect and identify the key pressed. To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, then it reads the columns. If the data read from the columns is D3DO = liii, no key has been pressed, and the process continues until a key press is detected. If one of column bits has zero, this means key press has occurred. After key press is detected, the microcontroller will go through the process of identifying key starting with the top row, the micro controller grounds it by providing a low to row DO only, then it reads the columns. If the data read is all is, no key in that row is activated and the process is moved to next row. It grounds the next row, reads the columns, and checks for any zero. This process continues until the row is identified. After identification of row in which key has been pressed, the next task is to find out which column the pressed key belongs to. sThis should be easy since the microcontroller knows at any time which row and column are being accessed.

Q. 27. Draw and Describe the 8051 connection to Stepper Motor and code a program to rotate it continuously. Ans. 8051 connection to Stepper Motor: Us an ohm meter to measure the resistance of the leads. This should identify which COM leads are connected to which winding leads.

ULN 2003 connection for Stepper Motor Pin 8 = GND .Pin9=+5V Use a Separate Power supply for Motor 2. The common wires are connected to +ve side of motors power supply. In many motors, + 5V is sufficient. 3. ULN 2003 driver is used to energize the stator. If transistor have been used as drivers MOV A, # 66H BACK: MOV P1, A
ptuece.loremate.com/microcontroller/node/8

load step sequence issue sequence to motor


12/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

RRA ACALL DELAY DJMP BACK DELAY MOV R2, # 100 HI : MOV R3, # 255 H2 : DJNZ R3, H2 DJNZ R2, HI

rotate right clockwise ;wait keep going

RET Change the value of DELAY to set the speed of rotation.

Q. 28. Write a program to sends the ASCII code for pressed key to P0.1? Ans. M0V P2, # OFFH Ki :MOVP1,#0 MOV A, P2 ANL A, 00001111B CJNE A, # 00001111B, KI K2: ACALL DELAY MOV A, P2 ANL A, # 00001111B make P2 an I/P port ; ground all rows at once read all col. (ensure all keys open) masked unused bits check till all keys released call 20 m sec delay see if any key is pressed mask unused bits. key pressed a wait closure check till key pressed wait 20 m sec de bounce mask unused bits key pressed, find row if. none keep polling ground row 0 read all columns mask unused bits key row 0 , find the col. ground row. read all columns mask unused bits key row , find the col. ground row 2 read all columns mask unused bits key rows 2 , find the col. ground row 3 read all columns. mask unused bits key row 3 , find the col. if none, false 1/ P , repeat set DPTR start of Row 0 find col time check key closure

CJNEA, # 00001111 B, over SJMP K 2 OVER: ACALL DELAY MOV A, P2 ANL A, # 00001111 B CJNEA;# 00001111B, Over I SJMP K2 OVERI : MOVP1,# 1111111 B MOV A, P2 ANL A, # 00001111 B CJNE A, # 00001111 B, Row_0 MOV P1, # 11111101 B MOV A, P2 ANL A, # 00001111 B CJNE A, # 00001111 B, Row_i MOV P1, # liiilOiiB MOV A, P2 ANL A, # 00001111B CJNE A, # 00001I11B, Row_2 MOOVPI,# 11110111 B MOV A, P2 ANLA, # 0000II11B CJNE A, # 00001111B, Row_3 LJMP K2 Row_0: MOV DPTR, # K CODE 0 SJMP FIND Row_i : MOV DPTR, # K CODE 1

. key belongs to set DPTR = start of Row I Sjmp find find col.key belongs to Row 2 mov dptr # kcode 2 set dptr = start of row 2 Sjmp find Find : rrc Jnc match Inc dptr Sjmp find
ptuece.loremate.com/microcontroller/node/8

find col. Belongs to a set dptr = start of row 3 see if any cy bit low point to next col. adress keep searching
13/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

Match : clr a Mov ca,@a + dptr Mov p0,a Ljmp k1 ;ascii look up table for each row Org 300 h K code 0 : db 0,1,2,3 K code 0 : db 4,5,6,7 K code 0 : db 8,9,a,b K code 0 : db c,d,e,f set A = 0 (match is found) get ASCII code from table display pressed key

Row 0 row 1 Row 2 Row 3ss

Q. 29. Explain difference between ROMP PROM, EPROM, EE PROM. Ans. ROM: Read Only Memory (ROM) is a type of memory that does not lose it contents when the power is turned off. So it is also called nonvolatile memory. Different types of ROM such as PROM, EPROM, EEPROM, flash EPROM and mask ROM. PROM (Programmable ROM) : It is user programmable memory. For every bit of PROM, there exit a fuse. PROM is programmed by blowing the fuses if the information burned into PROM is wrong, that PROM must be discarded since its internal fuses are blown permanently. So ROM also called OPT (one-time-programmable) or burning ROM. EPROM (Erasable Programmable ROM) : In EPROM, one can program the memory chip and erase it thousands of times. This is especially necessary during development of prototype of a micro processor-based project. A widely used EPROM called UVEPROM, where UV stands for ultra violet. The only problem with UV-EPROM is that erasing its contents can take up to 20 minutes. EEPROM (electrically erasable PROM) : It has several advantages over EPROM, its method of erasure is electrical and Therefore instant, as opposed to 20 minute erasure time required for UV-EPROM. In EEPROM one can select which byte to be erased, in. contrast to UV-EPROM, in which the entire contents of ROM are erased. The main advantage of EEPROM is one can program and erase its contents while it is still in the system board. It does not require physical removal of memory chip from its socket.

Q. 30. Explain RAM and its types. Ans. RAM memory is called volatile memory. Sometimes RAM is also referred to as RAWM (read and write memory). Three types of RAM are static RAM (SRAM), NV- RAM and Dynamic RAM (DRAM) SRAM Storage cells in static RAM are made of flip-flops and Therefore do not require refreshing in order to keep their data. The problem with the use of flip-flops for storage cells is that each cell requires at least 6 transistors to build, and cell holds only 1 bit of data In recent years, the cells have been made of 4 transistors which still is too many. The use of 4-transistor cell plus the use of CMOS technology has given birth to a high capacity SRAM, but its capacity is far below DRAM. NV RAM (Non volatile RAM) SRAM is volatile; there is new type of non volatile RAM called NV- RAM. It allows the CPU to read and write to it, but when power is turned off the contents are not last NV-RAM combines the best of RAM & ROM Every NV-RAM chip internally is made of following components 1. It uses extremely power efficient (very, very low power consumption) SRAM cells built out of CMOS 2. It uses an internal lithium battery as a backup energy source. 3. It uses an intelligent control circuitry. DRAM The first Dynamic RAM (DRAM) has density of 1024 bits and it used a capacitor to store each bit. The use of a capacitor as a means to store data cuts down the
ptuece.loremate.com/microcontroller/node/8 14/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

number of transistors needed to build the cell, however it requires constant refreshing due to leakage This is in contrast to SRAM, whose individual cells are made of flip flops. The major advantage of DRAM is, it has high density, cheaper cost per bit & lower power consumption per bit The disadvantage is that it must be refreshed periodically, due to fact that capacitor cell loses its charge, further more, while it is being refreshed, the data cannot be accessed Now a days DRAM has a capacity of 1 mega bit.

Q. 31. Draw 8051 connection to external 1 Data RAM and Explain Ans. 8051 family also has 64K bytes of data memory space. 8051 has 128 K bytes of address space where 64K bytes set aside for program code and other 64K bytes are set aside for data. Program space is accessed using the program counter to locate and fetch instructions, but data memory space is accessed using DPTR register and an instruction called MOVX, where X stands for external to connect 8051 to external SRAM, both RD (P3.7) and WR (P3.6) pin is used.

In writing data to external data RAM, use the instruction MOV X @ DPTR, A, where the contents of register A are writer to external RAM whose address is pointed to DPTR register.

Q. 32. Explain the interfacing of 8051 with external ROM.

EA Pin : Connect the EA pin to V to indicate that program code is stored in microcontroller on chip ROM, To indicate that the program code is stored in external ROM, this pin must be connected to ground. P0 and P2 role in providing address : Since the PC (Program counter) of 8051 is 16- bit, it is capable of accessing up to 64 K bytes of program code. In 8051 port 0 and port 2 provide 10-bit addresses to access external memory of these two ports, P0 provides the lower 8-bit addresses. A0-A7 and P2 provides the upper 8-bit address. A8A15 P0 is also used to provide 8-bit data bus. D0-D7 P0.0 P0.7 are used for both address and data paths. This is called data/address multiplexing in chip design. ALE pin is an output pin. ALE is address latch enable. When ALE = 0, 8051 uses P0 for data path and when ALE = 1 it is used for address path.

ptuece.loremate.com/microcontroller/node/8

15/16

11/17/12

Chapter 6 : Introduction to an Embedded System and ITs Design | Microcontrollers & Embedded Syst

In above diagram ALE = 0 & P0 is used as data bus sending data out or bringing data in. Whenever 8031/51 wants to use P0 as an address bus, it puts addresses A0-A7 on P0 pins & activates ALE = I indicate P0 has addresses. PSEN (Program store enable signal) : It is an 0/P signal for 8031/51 and must be connected to OE pin of ROM containing program code. When EA pin is connected to GND, the 8051 fetches op code from external ROM by using PSEN. Fig. Address Data Multiplexing

Fig. 8031151 connection to external program ROM In system where external ROM contains program code, burning program into ROM leaves microcontroller chip untouched.

ptuece.loremate.com/microcontroller/node/8

16/16

Vous aimerez peut-être aussi