MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following. (9M) 1) Describe the instructions SWAP A and MOVX@DPTR,A with one example. (3Marks) SWAP A - Function-swap nibbles within the accumulator. Description- Example- SWAP A interchange the low order and high order nibbles of the accumulator. No flags are affected. suppose the A=(11000101B) Langth-1Byte Operation: A3-A0 then after SWAP A A=01011100B MOVX@DPTR,A - Function-Move external Description- A7-A4 Load content of accumulator into External memory indicated by DPTR
Length-1Byte Operation- (DPTR) (A) 2) Describe function of PSEN, EA, XTAL1& XTAL@ pins of 051 microcontroller. (3Marks) PSEN - program store enable is the read strobe to external program memory. when the 8051 is executing code from internal program memory, PSEN is inactive(high) when the device is executing code from external program memory, PSEN is activated twice. EA - EA must be strapped to Vss in order to enable the 8051 to fetch code from external program memory locations starting at 0000H up to 0FFFFH. EA must be strapped to VCC for internal program execution. XTAL1- input to the inverting oscillator amplifier and input to the internal clock generating circuits. XTAL2- this is an output line of the internal inverting oscillator amplifier. 3) Compare data memory and program memory w.r.t. 8051 microcontroller. (3Marks)
Data memory Program memory 1) 8051 provides on chip 256 bytes of It provides on chip 4K bytes of ROM RAM 2) address is 8 bit address is 16 bit 3) it is always used to store data not program it is always used to store program not data 4) Describe one mode of timer of 8051 microcontroller. (3Marks) 13-bit Time Mode (mode 0) Timer mode "0" is a 13-bit timer. It provides compatibility with its predecesor, the 8048. Generally the 13-bit timer mode is not used in new development. When the timer is in 13-bit mode, TLx will count from 0 to 31. When TLx is incremented from 31, it will "reset" to 0 and increment THx. Thus, effectively, only 13 bits of the two timer bytes are being used: bits 0-4 of TLx and bits 0-7 of THx. 16-bit Time Mode (mode 1) Timer mode "1" is a 16-bit timer. This is a very commonly used mode. It functions just like 13-bit mode except that all 16 bits are used.
TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets to 0 and causes THx to be incremented by 1. Since this is a full 16-bit timer, the timer may contain up to 65536 distinct values. If you set a 16-bit timer to 0, it will overflow back to 0 after 65,536 machine cycles. 8-bit Time Mode (mode 2) Timer mode "2" is an 8-bit auto-reload mode. When a timer is in mode 2, THx holds the "reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLx reaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case of modes 0 and 1), it will be reset to the value stored in THx. The auto-reload mode is very commonly used for establishing a baud rate. Split Timer Mode (mode 3) Mode 3 is the split timer mode and is different for each timer. Timer 0 in mode 3 is split into two 8-bit timers. TL0 and TH0 act as separate timers with overflows setting the TF0 and TFI bits respectively. Timer 1 is stopped in mode 3 but can be started by switching it into one of the other modes. The only limitation is that the usual Timer I overflow flag, TF1, is not affected by Timer 1 overflows, since it is connected to TH0. The 8051 appears to have a third timer.
Timer 1 can be turned on and off by switching it out of and into its own mode 3. It can still be used by the serial port as a baud rate generator Q2.) Attempt any TWO of the following (8M) 1) Draw the format of TMOD register and write the function of each bit. (4Marks) TMOD format: TMOD (89h) SFR Bit Name Explanation of Function Timer 7 GATE1 When this bit is set the timer will only run when INT1 (P3.3) is high. When this bit is clear the timer will run regardless of the state 1 of INT1. 6 C/T1 When this bit is set the timer will count events on T1 (P3.5). When this bit is clear the timer will be incremented every machine cycle. 1 5 T1M1 Timer mode bit 1 4 T1M0 Timer mode bit 1 3 GATE0 2 C/T0 When this bit is set the timer will only run when INT0 (P3.2) is high. When this bit is clear the timer will run regardless of the state of INT0. When this bit is set the timer will count events on T0 (P3.4). When this bit is clear the timer will be incremented every machine cycle. 0 0
1 T0M1 Timer mode bit 0 0 T0M0 Timer mode bit 0 The modes of operation are: TxM1 TxM0 Timer Description Mode of Mode 0 0 0 0 1 1 1 0 2 1 1 3 13-bit Timer. 16-bit Timer 8-bit autoreload Split timer mode 3) Write an assembly language program to transfer block of ten bytes stored in internal data memory. (4Marks) mov r0,#0ah mov r1,#30h mov r2,#40h up: mov a,@r1 mov @r2,a inc r1 inc r2 djnz r0,up here: sjmp here
Q.3) Attempt any TWO of the following (8M) 1) List addressing modes of 8051 microcontroller with one suitable instruction each. (4Marks) 1) Register Addressing- mov A,R1 2) Direct Addressing- mov A,40h 3) Register indirect Addressing- mov A,@R1 4) Immediate Addressing- mov A,#04h 2) Write an assembly language program to arrange the given 10 numbers in descending order. (4Marks) REPEAT: CLR 44H MOV R0,#40H MOV A,@R0 MOV R3,A DEC R3 INC R0 MOV 60H,@R0 INC R0 MOV A,@R0 CJNE A,60H,DN AJMP FN DN: JC FN XCH A,60H MOV @R0,A
DEC R0 MOV @R0,60H INR R0 SETB 44H FN:DJNZ R3,AGAIN JB 44H,REPEAT 3) Describe the alternate functions of port3 of 8051 microcontroller. (4Marks) pin name Alternate function P3.0 RXD Serial input line P3.1 TXD Serial output line P3.2 External interrupt 0 INT0 P3.3 External interrupt 1 INT1 P3.4 T0 Timer 0 external input P3.5 T1 Timer 1 external input P3.6 External data memory write strobe WR P3.7 External data memory read strobe RD