Micro Controller few qa

Embed Size (px)

Citation preview

  • 8/4/2019 Micro Controller few qa

    1/2

    (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 + MemoryPeripherals = Ports + Clock + Timers + UARTS + ADC +LCD drivers + D

    AC + other stuffMemory = 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 makesthe system bulkier and much more expensive. A microcontroller is a specializedform 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 ta

    sks.

    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 stateof an individual package pin. In-circuit programming and debugging support. Also, a microcontroller is part of an embedded system, which is essentially thewhole 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 powerof 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:

    PART:B(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 pr

    ovided as an immediate value. The 8051 provides a total of five distinct addressing modes.1. Immediate addressing mode2. register addressing mode3. direct addressing mode4.register addressing mode5. indexed addressing mode

    Immediate addressing mode:In this addressing mode, the source operand is constant. In immediate addressingmode, the operand comes immediately. The immediate data must be preceded by thepound sign # sign.the followings instruction are used in these addressing mode:

    MOV A, #25H ; load 25H into accumulator AMOV R4, #62H ;load the decimal value 62 into R4MOV B, #40H ;load 40H into B

  • 8/4/2019 Micro Controller few qa

    2/2

    MOV DPTR, #4521H ; DPTR= 4521HSince 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, #53HMOV DPH, # 25Hwe can use the EQU directive to access immediate data as shown below:

    COUNT EQU 30... ..MOV R4, #COUNT ; R4= 1E(30=1EH)MOV DPTR, #MYDATA ; DPTR=200Hto send the data to port to 8051 ports.Ex: MOV P1, #55HRegister 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 AMOV R2, A ; Copy the contents of A in ROADD A, R5

    ADD R5, Ain this mode the source and destination register must be the same size otherwiseit will shows errorIn this we can move data between the and Rn (for n= 0 to 7) but movement of between Rn register is not allowed.Direct addressing mode:In the Direct addressing mode , the data is in RAM memory location whose addressis known , and this address is given as a part of the instruction. Compare withthe immediate addressing mode , in which the pperand itself provide with the instruction. the # sign distinguishes between the two modes. Ex:-MOV RO, 40HMOV 56H, AMOV R4, 7F

    the RAM locations 0 to 7 are allocated to bank 0 registers R0-R7. these registercan be accessed in two ways,MOV A, 4or, MOV A, R4See the following code ;

    MOV R2, #5MOV A,2MOV B,2MOV 7,2 ; Copy R2 to R7

    ;since MOV R7, R2 is invalidAlthough 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. ifthe 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 precededby the @ sign, as shown below,MOV A,@R0 ;move contents of RAM locations whose

    ; address is held by R0 into AIndexedr addressing mode:Indexed addressing mode is used in accessing data elements of look-up table located in the programROM space of the 8051.the instruction used for this purpose is MOV A, @+DPTR. The16-bit register DPTR and register A are used to form the address of the data ele

    ment stored on-chip ROM.