Sei sulla pagina 1di 10

Homework Title / No.

: ___1_______________________Course Code :ECE-310 _________ Course Instructor : _Miss Ritu_____________Course Tutor (if applicable) : ________ Date of Allotment : _____________________ Date of submission :26/02/2010__________ Students Roll No.___54____________________ Section No. :RH6802_______________________ Declaration: I declare that this assignment is my individual work. I have not copied from any other students work or from any other source except where due acknowledgment is made explicitly in the text, nor has any part been written for me by another person. Students Signature : Ramjee prasad__ Evaluators comments: _____________________________________________________________________ Marks obtained : ___________ out of ______________________ Content of Homework should start from this page only:

(1)Why microcontrollers are more in use than microprocessors? Solution: A microcontroller has a combination of all the following stuff on a single chip: Microcontroller = CPU + Peripherals + Memory Peripherals = Ports + Clock + Timers + UARTS + ADC +LCD drivers + DAC + other stuff Memory = EEPROM + SRAM+ EPROM + FLASH A microprocessor is just a CPU. If a system designer using a general purpose register such as Pentium or the 86 family must add RAM, ROM, and I/O ports and timers externally to make them functional. This addition of external peripheral makes the system bulkier and much more expensive. A microcontroller is a specialized form of microprocessor that is designed to be self-sufficient and cost-effective, where a microprocessor is typically designed to be general purpose. Microcontrollers are frequently found in automobiles, office machines, toys, and appliances. The microcontroller is the integration of a number of useful functions into a single IC package. These functions are:

The ability to execute a stored set of instructions to carry out user defined tasks. The ability to be able to access external memory chips to both read and write data from and to the memory. discrete input and output bits, allowing control or detection of the logic state of an individual package pin. In-circuit programming and debugging support. Also, a microcontroller is part of an embedded system, which is essentially the whole circuit board. Ex- intercom, telephone, security system, FAX machine, Lighting control, cellular phone, and lots of home appliances, and automation of machine lots of stuff that make our life easier fast.

A fixed amount of on-chip ROM, RAM, and number of I/O ports in microcontroller makes them ideal for many applications in which cost and space are critical. In many applications such as TV remote control, there is no need of computing power of 86 or even 8086 microprocessor. (2)What are the minimum hardware components required for 8051 to work with its internal ROM? Also show their connections? Solution: The microcontroller uses ROM as memory bank and he keeps the user instruction and stores the result . For these purpose, the 8051 has two types of memory and these are Program Memory and Data Memory. Program Memory (ROM) is used to permanently save the program being executed, while Data Memory (RAM) is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Depending on the model in use about the 8051 at most a few Kb of ROM and 128 or 256 bytes of RAM is used.

The EEPROM is a special type of memory not contained in all microcontrollers. Its contents may be changed during program execution (similar to RAM ), but remains permanently saved even after the loss of power (similar to ROM). It is often used to store values, created and used during operation (such as calibration values, codes, values to count up to etc.), which must be saved after turning the power supply off. A disadvantage of this memory is that the process of programming is relatively slow. It is measured in miliseconds.

(3)How many internal counters are there in 8051? Explain their working.

Solution: The 8051 microcontroller has 2 timers/counters called T0 and T1. As their names suggest, their main purpose is to measure time and count external events. Besides, they can be used for generating clock pulses to be used in serial communication, so called Baud Rate. Timer T0 The timer T0 consists of two registers TH0 and TL0 representing a low and a high byte of one 16-digit binary number.

Accordingly, if the content of the timer T0 is equal to 0 (T0=0) then both registers it consists of will contain 0. If the timer contains for example number 1000 (decimal), then the TH0 register (high byte) will contain the number 3, while the TL0 register (low byte) will contain decimal number 232.

Since the timer T0 is virtually 16-bit register, the largest value it can store is 65 535. In case of exceeding this value, the timer will be automatically cleared and counting starts from 0. This condition is called an overflow. Two registers TMOD and TCON are closely connected to this timer and control its operation. TMOD Register (Timer Mode) The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to the timer 1. There are 4 operational modes and each of them is described herein.

Bits of this register have the following function:

GATE1 enables and disables Timer 1 by means of a signal brought to the INT1 pin (P3.3): o 1 - Timer 1 operates only if the INT1 bit is set. o 0 - Timer 1 operates regardless of the logic state of the INT1 bit. C/T1 selects pulses to be counted up by the timer/counter 1: o 1 - Timer counts pulses brought to the T1 pin (P3.5). o 0 - Timer counts pulses from internal oscillator. T1M1,T1M0 These two bits select the operational mode of the Timer 1. T1M0 0 1 0 1 Mode 0 1 2 3 Description 13-bit timer 16-bit timer 8-bit autoreload Split mode

T1M1 0 0 1 1

GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2): o 1 - Timer 0 operates only if the INT0 bit is set. o 0 - Timer 0 operates regardless of the logic state of the INT0 bit. C/T0 selects pulses to be counted up by the timer/counter 0: o 1 - Timer counts pulses brought to the T0 pin (P3.4). o 0 - Timer counts pulses from internal oscillator. T0M1,T0M0 these two bits select the operational mode of the Timer 0. T0M0 0 1 0 1 Mode 0 1 2 3 Description 13-bit timer 16-bit timer 8-bit autoreload Split mode

T0M1 0 0 1 1

Timer 0 in mode 0 (13-bit timer) This mode configures timer 0 as a 13-bit timer which consists of all 8 bits of TH0 and the lower 5 bits of TL0. As a result, the Timer 0 uses only 13 of 16 bits.

Timer 0 in mode 1 (16-bit timer) Mode 1 configures timer 0 as a 16-bit timer comprising all the bits of both registers TH0 and TL0. That's why this is one of the most commonly used modes. Timer operates in the same way as in mode 0, with difference that the registers count up to 65 536 as allowable by the 16 bits.

Timer 0 in mode 2 (Auto-Reload Timer) Mode 2 configures timer 0 as an 8-bit timer. Actually, timer 0 uses only one 8-bit register for counting and never counts from 0, but from an arbitrary value (0-255) stored in another (TH0) register. Timer 0 in Mode 3 (Split Timer) Mode 3 configures timer 0 so that registers TL0 and TH0 operate as separate 8-bit timers. In other words, the 16-bit timer consisting of two registers TH0 and TL0 is split into two independent 8-bit timers. This mode is provided for applications requiring an additional 8-bit timer or counter. The TL0 timer turns into timer 0, while the TH0 timer turns into timer 1. In addition, all the control bits of 16-bit Timer 1 (consisting of the TH1 and TL1 register), now control the 8-bit Timer 1. Even though the 16-bit Timer 1 can still be configured to operate in any of modes (mode 1, 2 or 3), it is no longer possible to disable it as there is no control bit to do it. Thus, its operation is restricted when timer 0 is in mode 3. The only application of this mode is when two timers are used and the 16-bit Timer 1 the operation of which is out of control is used as a baud rate generator. Timer Control (TCON) Register TCON register is also one of the registers whose bits are directly in control of timer operation. Only 4 bits of this register are used for this purpose, while rest of them is used for interrupt control to be discussed later.

TF1 bit is automatically set on the Timer 1 overflow. TR1 bit enables the Timer 1. o 1 - Timer 1 is enabled. o 0 - Timer 1 is disabled. TF0 bit is automatically set on the Timer 0 overflow. TR0 bit enables the timer 0. o 1 - Timer 0 is enabled.

0 - Timer 0 is disabled.

PART: B

(1)Draw the internal memory map of 8051 microcontroller. Solution:Memory Architecture The 8051 has four types of memory (i)internal RAM, (ii)special function registers, (iii)program memory, ( i) external data memory.

Internal RAM: Internal RAM is located from address 0 to address 0xFF. RAM from 0x00 to 0x7F can be accessed directly, and the bytes from 0x20 to 0x3F are also bit-addressable. RAM from 0x80 to 0xFF must be accessed indirectly, using the @R0 or @R1 syntax, with the address to access loaded in R0 or R1. Special function register: Special function registers (or, SFR) are located from address 0x80 to 0xFF, and are accessed directly using the same instructions as for the lower half of RAM. Some of the SFR's are also bit-addressable. program memory: Program memory (PMEM, though less common in usage than IRAM and XRAM) is located starting at address 0. It may be on- or off-chip, depending on the particular model of chip being used. Program memory is read-only, though some variants of the 8051 use on-chip Flash memory: Flash memory and provide a method of re-programming the memory in-system or inapplication. Aside from storing code, program memory can also store tables of constants that can be accessed by MOVC A, @DPTR, using the 16-bit special function register DPTR

(2)What are the addressing modes of 8051? How many types of instructions are their? Solution: The CPU can access data in various ways. It data could be in a register or be provided as an immediate value. The 8051 provides a total of five distinct addressing modes. 1. Immediate addressing mode 2. Register addressing mode 3. Direct addressing mode 4. Register addressing mode 5. Indexed addressing mode

Immediate addressing mode: In this addressing mode, the source operand is constant. In immediate addressing mode, the operand comes immediately. The immediate data must be preceded by the pound sign # sign.

The followings instruction are used in these addressing mode: MOV A, #25H MOV R4, #62H MOV B, #40H ; load 25H into accumulator A ; load the decimal value 62 into R4 ; load 40H into B

MOV DPTR, #4521H ; DPTR= 4521H Since the DPTR register is of 16-bit, it can also be accessed as two 8-bit registers, DPH and DPL, where DPH is high byte and DPL is the low byte. MOV DPTR, #2553H is same as the, MOV DPL, #53H MOV DPH, # 25H We can use the EQU directive to access immediate data as shown below: COUNT ... MOV MOV .. R4, #COUNT DPTR, #MYDATA ; R4= 1E(30=1EH) ; DPTR=200H EQU 30

To send the data to port to 8051 ports. Ex: MOV P1, #55H Register addressing mode: register addressing mode involves the use of register to hold the data to be manipulated. Ex:MOV A, RO ; Copy the contents of RO in A MOV R2, A ADD A, R5 ADD R5, A in this mode the source and destination register must be the same size otherwise it will shows error In this we can move data between them and Rn (for n= 0 to 7) but movement of between Rn register is not allowed. Direct addressing mode: ; Copy the contents of A in RO

In the Direct addressing mode, the data is in RAM memory location whose address is known , and this address is given as a part of the instruction. Compare with the immediate addressing mode , in which the operand itself provide with the instruction. The # sign distinguishes between the two modes. Ex:MOV RO, 40H MOV 56H, A MOV R4, 7F The RAM locations 0 to 7 are allocated to bank 0 registers R0-R7. these register can be accessed in two ways, MOV A, 4 Or, MOV A, R4 See the following code; MOV R2, #5 MOV A, 2 MOV B, 2 MOV 7, 2 ; Copy R2 to R7 ;since MOV R7, R2 is invalid Although it is easier to use the names R0-R7 than their memory addresses, RAM locations 30H to 7FH can not be accessed in any way other than by their addresses, since they have no names. Register indirect addressing mode: In the register addressing mode , aregister is used as a pointer to the data. if the data is inside the CPU, only register R0 and R1 are used for this purpose. When R0-R1 are used to hold the address of RAM locations, they must be preceded by the @ sign, as shown below, MOV A,@R0 ;move contents of RAM locations whose ; address is held by R0 into A Indexedr addressing mode: Indexed addressing mode is used in accessing data elements of look-up table located in the program

ROM space of the 8051.the instruction used for this purpose is MOV A, @+DPTR. The 16-bit register DPTR and register A are used to form the address of the data element stored on-chip ROM. (3)If external memory (ROM) have to be used with 8051 then how much memory can be connected and why? Answer: - In case memory (RAM or ROM) built in the microcontroller is not sufficient, it is possible to add two external memory chips with capacity of 64Kb each. P2 and P3 I/O ports are used for their addressing and data transmission.

In the 8051 microcontroller, there are 16 address lines from port 0 and port 2 there for we can excess 216 = 64 K of external memory i.e. ROM. External memory is used in cases when the internal ROM and RAM memory available on chip is not sufficient. Two separate external memory spaces are made available by the 16-bit PC and the DPTR and by different control pins enabling external RIM chips. Two external ROM of up to 64 K can be added to any chip in the 8051 family.

Potrebbero piacerti anche