10ESL47 Microcontrollers Lab I. Programming Using 8051 Dept. of ECE, B.I.T., Mangalore 1 2012-13 10ESL47 Microcontrollers Lab 1. Write an assembly language program to transfer N = ___ bytes of data from location A:_______h to location B:_______h (without overlap). Let N = 05h, A: 30h B: 40h mov r0,#30h //source address mov r1,#40h //destination address mov r7,#05h //Number of bytes to be moved back: mov a,@r0 mov @r1,a inc r0 inc r1 djnz r7,back //repeat till all data transferred end Result: Before Execution: After Execution: Dept. of ECE, B.I.T., Mangalore 2 2012-13 10ESL47 Microcontrollers Lab 2. Write an assembly language program to exchange N = ___h bytes of data at location A : _____h and at location B : _____h. Let N = 05h, A: 30h, mov r0,#30h mov r1,#40h mov r7,#05h back: mov a,@r0 mov r4,a mov a,@r1 mov @r0,a mov a,r4 mov @r1,a inc r0 inc r1 B: 40h //source address //destination address //count, the number of data to be exchanged djnz r7,back end Result: Before Execution: After Execution: Dept. of ECE, B.I.T., Mangalore 3 2012-13 10ESL47 Microcontrollers Lab 3. Write an assembly language program to find the largest element in a given array of N =___ h bytes at location 9000h. Store the largest element at location 4062h. Let N = 06h mov r3,#6 mov dptr,#4000H movx a,@dptr mov r1,a nextbyte: inc dptr movx a,@dptr clr c mov r2,a subb a,r1 jc skip mov a,r2 mov r1,a skip: djnz r3,nextbyte mov dptr, #4062H mov a,r1 movx @dptr,a end //length of the array //starting address of array //reset borrow flag //next number in the array //other Num-Prev largest no. // JNC FOR SMALLEST ELEMENT //update larger number in r1 //location of the result-4062h //largest number //store at #4062H Result: Before Execution: After Execution: Dept. of ECE, B.I.T., Mangalore 4 2012-13 10ESL47 Microcontrollers Lab 4. Write an assembly language program to sort an array of N =____ h bytes of data in ascending/descending order stored from location 9000h. (Using bubble sort algorithm) Let N = 06h mov R0,#05H loop1:mov dptr, #9000h mov r1,#05h loop2:movx a, @dptr mov b, a inc dptr movx a, @dptr clr c mov r2, a subb A, b jnc noexchg mov a,b movx @dptr,a dec dpl mov a,r2 movx @dptr,a inc dptr noexchg: djnz r1,loop2 djnz r0,loop1 end //count (N-1) array size = N //array stored from address 9000h //initialize exchange counter //get number from array and store in B register //next number in the array //reset borrow flag //store in R2 //2nd-1st No.,since no compare instruction in 8051 // JC - FOR DESCENDING ORDER //exhange the 2 noes in the array //DEC DPTR - instruction not present //decrement compare counter //decrement pass counter Result: Before Execution: After Execution :( Ascending order) Note : Analyze the bubble sort algorithm for the given data. Also try with different sorting algorithms. Dept. of ECE, B.I.T., Mangalore 5 2012-13 10ESL47 Microcontrollers Lab 5. Write an assembly language program to perform the addition of two 16-bit numbers. mov r0,#34h mov r1,#12h mov r2,#0dch mov r3,#0feh clr c mov a,r0 add a,r2 mov 22h,a mov a,r1 addc a,r3 mov 21h,a mov 00h,c end //lower nibble of No.1 //higher nibble of No.1 //lower nibble of No.2 //higher nibble of No.2 // 1234 +f e d c ----------11110 ----------- Result: Dept. of ECE, B.I.T., Mangalore 6 2012-13 10ESL47 Microcontrollers Lab 6. Write an assembly language program to perform the subtraction of two 16-bit numbers. mov r0,#0dch mov r1,#0feh mov r2,#34h mov r3,#12h clr c mov a,r0 subb a,r2 mov 22h,a mov a,r1 subb a,r3 mov 21h,a mov 00h,c end //lower nibble of No.1 //higher nibble of No.1 //lower nibble of No.2 //higher nibble of No.2 // f edc -1 2 3 4 -----------ec a8 ------------- Result: Note: Try with different data. Ex: (Smaller number) – (larger number). Dept. of ECE, B.I.T., Mangalore 7 2012-13 10ESL47 Microcontrollers Lab 7. Write an assembly language program to perform the multiplication of two 16-bit numbers. mov r0,#34h mov r1,#12h mov r2,#78h mov r3,#56h mov a,r0 mov b,r2 mul ab mov 33h,a mov r4,b mov a,r0 mov b,r3 mul ab add a,r4 mov r5,a mov a,b addc A,#00h mov r6,a mov a,r1 mov b,r2 mul ab add a,r5 mov 32h,a mov a,b addc a,r6 mov 00h,c mov r7,a mov a,r3 mov b,r1 mul ab add a,r7 mov 31h,a mov a,b addc A,20h mov 30h,a end // 5678*1234 Result: Note: Write the logic of the program. Try with some other logic. Dept. of ECE, B.I.T., Mangalore 8 2012-13 10ESL47 Microcontrollers Lab 8. Write an assembly language program to find the square of a given number N. Let N = 05 mov a,#05 mov b,a mul ab mov 30h,a mov 31h,b end // a=N=05 // result is stored in 30h and 31h Result: Input: Output: 9. Write an assembly language program to find the cube of a given number. mov r0,#0fh mov a,r0 mov b,r0 mul ab mov r1,b mov b,r0 mul ab mov 32h,a mov r2,b mov a,r1 mov b,r0 mul ab add a,r2 mov 31h,a mov a,b addc A,#00h mov 30h,a end // ro=given number to find the cube of it. //result is stored in 30h, 31h, 32h Result: Input: Output: Dept. of ECE, B.I.T., Mangalore 9 2012-13 10ESL47 Microcontrollers Lab 10. Write an ALP to compare two eight bit numbers NUM1 and NUM2 stored in external memory locations 8000h and 8001h respectively. Reflect your result as: If NUM1<NUM2, SET LSB of data RAM location 2FH (bit address 78H). If NUM1>NUM2, SET MSB of location 2FH (bit address 7FH). If NUM1 = NUM2, then Clear both LSB & MSB of bit addressable memory location 2FH. mov dptr,#8000h movx a,@dptr mov r0,a inc dptr movx a,@dptr clr c subb a,r0 jz equal jnc small setb 7fh sjmp end1 small:setb 78h sjmp end1 equal: clr 78h clr 7fh end1: end Result: 1) Before Execution: X: 8000h = After Execution: D: 02FH = 2) Before Execution: X: 8000h = After Execution: D: 02FH = 3) Before Execution: X: 8000h = After Execution: D: 02FH = & X: 8001 = & X: 8001 = & X: 8001 = 11. Write an assembly language program to count number of ones and zeros in a eight bit number. mov r1,#00h mov r2,#00h mov r7,#08h mov a,#97h again: rlc a jc next inc r1 sjmp here next: inc r2 here: djnz r7,again end ] Result: Input: // to count number of 0s // to count number of 1s // counter for 8-bits // data to count number of 1s and 0s Output: Number of zero’s = r2 = Number of one’s = r1 = Dept. of ECE, B.I.T., Mangalore 10 2012-13 10ESL47 Microcontrollers Lab 12. Write an assembly language program to find whether given eight bit number is odd or even. If odd store 00h in accumulator. If even store FFh in accumulator.** mov a,20h jb acc.0, odd mov a,#0FFh sjmp ext odd: mov a,#00h ext: end // 20h=given number, to find is it even or odd Result: Input: Output: a: 20h: 13. Write an assembly language program to perform logical operations AND, OR, XOR on two eight bit numbers stored in internal RAM locations 21h, 22h. MOV A, 21H ANL A, 22H MOV 30H, A MOV A, 21H ORL A, 22H MOV 31H, A MOV A, 21H XRL A, 22H MOV 32H,A END //do not use #, as data ram 21h is to be accessed //logical AND operation //AND operation result stored in 30h //logical OR operation //OR operation result stored in 31h //logical XOR operation // XOR operation result stored in 32h Result: 1) Before Execution: D: 21H = After Execution: 22H = D: 030H = //AND operation D: 031H = //OR operation D: 032H = //XRL operation Dept. of ECE, B.I.T., Mangalore 11 2012-13 10ESL47 Microcontrollers Lab 14. Write an assembly language program to implement (display) an eight bit UP/DOWN binary (hex) counter on watch window. MOV a,#00 BACK: ACALL DELAY INC a JNZ BACK HERE: SJMP HERE //MOV a, #0ffh for DOWN COUNTER //DEC a for binary DOWN COUNTER DELAY: MOV r1,#0FFH DECR1:MOV r2,#0FFH DECR: MOV r3,#OFFH DJNZ r3,$ DJNZ r2,DECR DJNZ r1,DECR1 RET END RESULT: Accumulator A is incremented in binary from 00, 01, 02…09,0A, 0B,…,0F,10,11,…FF Note: To run this program, after selecting DEBUG session in the main menu use View-> Watch & call Stack window, in the Watches select watch 1(or 2) and press F2 and enter a (for accumulator A) 15. Write an assembly language program to implement (display) an eight bit UP/DOWN decimal counter on watch window. MOV a,#99H //MOV a, 00H for decimal UP COUNTER BACK:ACALL DELAY ADD a,#99H //ADD a,#01H for decimal up counter DA A JNZ BACK HERE:SJMP HERE DELAY:MOV r1,#0FFH DECR1:MOV r2,#0FFH DECR:MOV r3, #0FFH DJNZ r3,$ DJNZ r2, DECR DJNZ r1, DECR1 RET END RESULT: Accumulator A is incremented in BCD from 99,98,97,……….,00. **Note: Show the Delay Calculations and measure on the system. Dept. of ECE, B.I.T., Mangalore 12 2012-13 10ESL47 Microcontrollers Lab 16. Write an assembly language program to convert a BCD number into ASCII. mov a, #09h mov r0,a swap a mov dptr,#9000h acall ascii mov a,r0 acall ascii sjmp $ //the BCD number to be converted to ASCII // output will be in 9000h and 90001h ascii: anl a,#0fh add a,#30h movx @dptr,a inc dptr ret end Result: 17. a. Write an assembly language program to convert a ASCII number into Decimal. mov dptr,#9000h movx a,@dptr subb a,#30h mov 50h,a end //ASCII number to be converted to decimal is stored in // 9000h //Converted decimal data will be in 50h Result: Input: 9000h: Output: 50h: 17.b. Write an assembly language program to convert a decimal number into ASCII. mov dptr,#9000h movx a,@dptr add a,#30h mov dptr,#9002 movx @dptr,a end //Decimal number to be converted to ASCII is store in // 9000h // ASCII will be saved in 9002h Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 13 2012-13 10ESL47 Microcontrollers Lab 18. a. Write an assembly language program to convert a binary (hex) number into decimal. mov a,#0feh mov b,#0ah div ab mov r0,b mov b,#0ah div ab mov 30h,a mov a,b swap A orl a,r0 mov 31h,A end //binary number to be converted to decimal Result: Input: Output: 18.b. Write an assembly language program to convert a decimal number into binary(hex). mov a,#95h mov b,#10h div ab mov r1,b mov b,#0ah mul ab add a,r1 mov 30h,a end //a = Decimal number to be converted to the binary Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 14 2012-13 10ESL47 Microcontrollers Lab 19. Conduct an experiment to configure 8051 microcontroller to transmit characters “MICROCONTROLLERS LAB BIT” to a PC using the serial port and display on the serial window. ****** Note: To use result of this program, after selecting DEBUG session in the main menu use View-> serial window #1. On running & halting the program, the data is seen in the serial window. mov tmod,#20h mov scon,#70h mov th1,#-3 setb tr1 again: mov r0,#03h mov dptr,#8000h nextchar: movx a,@dptr acall transfer inc dptr djnz r0,nextchar sjmp again transfer: mov sbuf,a wait: jnb ti,wait clr ti ret end //setting Timer-1 in mode-2 RESULT: MICROCONTROLLERS LAB BIT is printed on the serial window each time the program is executed. Theory: In serial transmission as opposed to parallel transmission, one bit at a time is transmitted. In serial asynchronous transmission, the data consists of a Start bit (high), followed by 8 bits of data to be transmitted and finally the stop bit. The byte character to be transmitted is written into the SBUF register. It transmits the start bit. The 8-bit character is transferred one bit at a time. The stop bit is transferred. After the transmission, the TI flag = 1 indicating the completion of transmission. Hence in the subroutine wait until TI is set. Later clear the TI flag and continue with transmission of the next byte by writing into the SBUF register. (The program can also be written in interrupt mode). The speed of the serial transmission is set by the baud rate which is done with the help of timer 1. Timer1 must be programmed in mode 2 (that is, 8-bit, auto reload). Baud rate Calculation: Crystal freq/ (12*32) = (11.0592MHz)/(12*32) = 28800. Serial communication circuitry divides the machine cycle frequency (11.0592MHz)/(12) by 32 before it is being used by the timer to set the baud rate. To get 9600, 28800/3 is obtained by loading timer1 with -3 (i.e., FF – 3 = FD) for further clock division. For 2400 baud rate, 28800/12 => -12 = F4 in TH1. Dept. of ECE, B.I.T., Mangalore 15 2012-13 10ESL47 Microcontrollers Lab 20. Conduct an experiment to generate 1second delay continuously using on chip timer. mov tmod,#02h mov th0,#00h clr P1.0 clr a setb tr0 again: mov r7,#0ffh loop: mov r6,#14d wait: jnb tf0, wait clr tf0 djnz r6,wait djnz r7,loop cpl P1.0 sjmp again end RESULT: Accumulator A is incremented in binary from 00, 01,02…09,0A, 0B, …, 0F, 10, 11, …FF every 1 second (for 33MHz clock setting & every 3 seconds for 11.0598MHz) Dept. of ECE, B.I.T., Mangalore 16 2012-13 10ESL47 Microcontrollers Lab II. Programming Using MSP430 Dept. of ECE, B.I.T., Mangalore 17 2012-13 10ESL47 Microcontrollers Lab 21. Write an assembly language program to transfer N = ___ bytes of data from location A:_______h to location B:_______h (without overlap). A=0x8000, B=0x9000, N=5 #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #0x8000, R5 MOV.W #0x9000,R6 MOV.B #5,R7 again: MOV.W @R5+,0(R6) INCD.W R6 DEC R7 JNZ again JMP $ END Result: Input: Output: Dept. of ECE, B.I.T., Mangalore 18 2012-13 10ESL47 Microcontrollers Lab 22. Write an assembly language program to exchange N = ___h bytes of data at location A : _____h and at location B : _____h. A=0x8000, B=0x9000, N=5 #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #0x8000, R5 MOV.W #0x9000,R6 MOV.B #5,R7 again: MOV.W @R5,R8 MOV.W @R6,0(R5) MOV.W R8,0(R6) INCD.W R6 INCD.W R5 DEC R7 JNZ again JMP $ END Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 19 2012-13 10ESL47 Microcontrollers Lab 23. Write an assembly language program to perform the addition of two 32-bit numbers. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #0X9000,R4 MOV.W #0XFFFF,R7 ADD.W R4,R7 MOV.W #0XFFFF,R5 MOV.W #0XFFFF,R6 ADDC R5,R6 JMP $ END //NUM1:FFFF9000 //NUM2:FFFFFFFF Result: Input: Output: 24. Write an assembly language program to perform the subtraction of two 32-bit numbers. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #0X9000,R4 MOV.W #0XFFFF,R7 SUB.W R4,R7 MOV.W #0XFFFF,R5 MOV.W #0XFFFF,R6 SUBC R5,R6 JMP $ END Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 20 2012-13 10ESL47 Microcontrollers Lab 25. Write an assembly language program to perform the multiplication of two 16-bit numbers. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #0XFFFF, R4 MOV.W R4, R8 MOV.W #0X1234, R7 MOV.W #00, R5 MOV.W #00, R10 MOV.W #00, R9 CLRC INC.W R5 UP: ADD.W R4, R8 JNC COPY INC.W R9 COPY:INC.W R5 CLRC CMP.W R5, R7 JNE UP MOV.W R8, R10 JMP $ END ; R4= FFFF ; R7= 1234, (FFFF x 1234) ; PRODUCT LOWER 16 BIT (DB98) ; PRODUCT UPPER 16 BIT (1233) ; SUCCESSIVE ADDITION ; (endless loop) Result: Input: Output: Note: For square of a number give both the numbers same value. Assignment: Find the cube of a number. Dept. of ECE, B.I.T., Mangalore 21 2012-13 10ESL47 Microcontrollers Lab 26. Write an assembly language program to perform the division of two 16-bit numbers. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer UP: COPY: DONE: MOV.W #0XFFFF, R4 MOV.W #0XAA01, R7 MOV.W #00, R5 MOV.W #00, R9 CLRC MOV.W R4, R10 SUB.W R7, R4 JNC DONE INC.W R9 CMP.W R5, R4 JNZ UP JMP $ END ; 16 BIT DIVIDEND ; 16 BIT DIVISOR (FFFF/AA01) ; R9 IS QUOTIENT ; Clear Carry Flag ; R10 IS REMAINDER ; SUCCESSIVE SUBSTRACTION ; (endless loop) Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 22 2012-13 10ESL47 Microcontrollers Lab 27. Write an assembly language program to sort an array of N =____ h bytes of data in ascending/descending order stored from location 9000h.(use bubble sort algorithm) #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #04,R4 MOV.W #0x9000,R10 MOV.W #00,R11 MOV.W R4, R5 REPEAT: MOV.W @R10+, R6 MOV.W R6, R8 MOV.W @R10, R7 MOV.W R7, R9 SUB.W R7, R6 JNC NOEXCHG MOV.W R8, 0(R10) DEC.W R10 DEC.W R10 MOV.W R9, 0(R10) INCD.W R10 NOEXCHG: DEC.W R5 CMP.W R11, R5 JNE REPEAT DEC.W R4 CMP.W R11, R4 JNE UP JMP $ END UP: ; count (N-1) ARRAY SIZE=N ;array stored from address 9000h ; initialize exchange counter ; Get 1st Number from Array ; Get 2nd Number from Array ; JC - FOR DESCENDING ORDER ; //Exchange The 2 No’s In The Array ; (endless loop) Note: For smallest number take the first element in the ascending order sorted array and for largest number take the first element in the descending order sorted array Dept. of ECE, B.I.T., Mangalore 23 2012-13 10ESL47 Microcontrollers Lab 28. Write an assembly language program to implement (display) an 16 bit UP/DOWN binary (hex). #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer AGAIN: MOV.W #0X0000,R5 REP: CALL #DELAY ADD.W #0X0001,R5 JNZ REP JMP AGAIN JMP $ //For DOWN Counter, MOV.W #0XFFFF, R5 //For DOWN counter, ADD.W #0XFFFF,R5 DELAY: MOV.W #0X50,R6 LOOP1: MOV.W #0X50,R7 LOOP: DEC R7 JNZ LOOP DEC R6 JNZ LOOP1 RET END RESULT: R5 is incremented in binary from 0000, 0001,0002…0009,000A, 000B,…,000F,0010,0011,…FFFF,0000,0001, ……. Dept. of ECE, B.I.T., Mangalore 24 2012-13 10ESL47 Microcontrollers Lab 29. Write an assembly language program to implement (display) an 16 bit UP/DOWN Decimal counter. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer AGAIN: MOV.W #0X9999,R5 REP: CALL #DELAY CLRC DADD.W #0X9999,R5 JNZ REP JMP AGAIN JMP $ //For UP Counter, MOV.W #0X00, R5 //For UP counter, DADD.W #0X0001,R5 DELAY: MOV.W #0X50,R6 LOOP1: MOV.W #0X50,R7 LOOP: DEC R7 JNZ LOOP DEC R6 JNZ LOOP1 RET END RESULT: R5 is decremented in BCD from 9999, 9998, ……, 0000, 9999, 9998…… Dept. of ECE, B.I.T., Mangalore 25 2012-13 10ESL47 Microcontrollers Lab 30. Write an assembly language program to convert a 8-bit BCD number into ASCII. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.B #0X12, R5 MOV.B R5,R6 AND.B #0X0F,R6 ADD.B #0X30,R6 AND.B #0XF0,R5 RRA.B R5 RRA.B R5 RRA.B R5 RRA.B R5 ADD.B #0X30,R5 MOV.B R5,R7 JMP $ END Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 26 2012-13 10ESL47 Microcontrollers Lab 31. A. Write an assembly language program to convert a ASCII number into Decimal. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.B #0X35, R5 SUB.B #0X30,R5 MOV.B R5,R6 JMP $ END Result: Input: Output: 31. B. Write an assembly language program to convert a Decimal number into ASCII. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.B #0X05, R5 ADD.B #0X30,R5 MOV.B R5,R6 JMP $ END Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 27 2012-13 10ESL47 Microcontrollers Lab 32. A. Write an assembly language program to convert a binary (hex) number into decimal. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.B #0XFE,R5 MOV.B #0X0A,R6 CALL #AA MOV.B R5,R9 MOV.B R7,R5 CALL #AA AND.W #0X00FF,R7 SWPB R7 RLA.B R5 RLA.B R5 RLA.B R5 RLA.B R5 ADD.W R5,R7 ADD.W R9,R7 JMP $ AA: MOV.B #0XFF,R7 LOOP: INC R7 SUB.B R6,R5 JC LOOP ADD.W #0x0A,R5 RET END Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 28 2012-13 10ESL47 Microcontrollers Lab 32. B. Write an assembly language program to convert a decimal number into binary(hex). #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.B #0X99,R5 MOV.B #0X10,R6 MOV.B #0XFF,R7 LOOP: INC R7 SUB.B R6,R5 JC LOOP ADD.B #0x10,R5 AND.W #0X00FF,R7 MOV.B #0X00,R8 AGAIN:ADD.B #0X0A,R8 DEC R7 JNZ AGAIN ADD.B R5,R8 JMP $ END Result: Input: Dept. of ECE, B.I.T., Mangalore Output: 29 2012-13 10ESL47 Microcontrollers Lab 33. Write an assembly language program to perform logical operations AND, OR, XOR on two 16 bit numbers. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label visible outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer MOV.W #0X1234, R5 MOV.W #0XABCD,R6 MOV.W R6,R7 MOV.W R6,R8 AND.W R5,R6 XOR.W R5,R7 INV.W R8 INV.W R5 AND.W R8,R5 INV.W R5 JMP $ END Dept. of ECE, B.I.T., Mangalore //R6=R5 AND R6 //R7=R5 XOR R7 //R8=NOT R8 //R5=R8 OR R5 30 2012-13 10ESL47 Microcontrollers Lab III. Interfacing Dept. of ECE, B.I.T., Mangalore 31 2012-13 10ESL47 Microcontrollers Lab 34. a. Write a C program to generate square wave of amplitude ___ V of frequency _________Hz using DAC. Display the waveform on the CRO. 35. a. Write a C program to generate square wave of amplitude ___ V of frequency _________Hz using DAC. Display the waveform on the CRO. Circuit Diagram for wave form generation: Dual DAC U5 8 0 5 1 P0.0 . . P0.7 B1 . . B8 DAC 0800 Xout CRO U3 P1.0 . . P1.7 Dept. of ECE, B.I.T., Mangalore B1 . . B8 32 DAC 0800 Ch1 Yout Ch2 2012-13 10ESL47 Microcontrollers Lab Program: #include <REG51xD2.H> void delay(unsigned int x) { for(;x>0;x--); } /* delay routine */ main() { unsigned char on = 0x7f,off=0x00; unsigned int fre = 230; while(1) { P0=P1=on; delay(fre); P0=P1=off; delay(fre); /* write apmlitude to port */ /* clear port */ } } DESIGN: Let f = 2 kHz, Therefore T = 1/f= 0.5msec, Count value for the delay is (T/ 1clock cycle period) = 0.5 x 10-3sec/1.085 x 10-6sec Hence Count value is =460. Hence for 50% Duty cycle the Count value is half of the Count value=230. Note: Delay produced by the program will depend on the microcontroller you are using, so frequency of the waveform generated may not match with the given frequency. 34. b. Write a C program to generate ramp wave of amplitude ___ V using DAC. Display the waveform on the CRO. Program: #include <REG51xD2.H> main() { unsigned char amp = 0xff; unsigned char i=0; P0=P1=0x00; while(1) { { for(i=0;i<amp;i++) P0=P1=i; } } /* P0 as Output port */ /* Generate ON pulse */ } Dept. of ECE, B.I.T., Mangalore 33 2012-13 10ESL47 Microcontrollers Lab 34.c. Write a C program to generate triangular wave of amplitude ___ V using DAC. Display the waveform on the CRO. Program: #include <REG51xD2.H> main() { unsigned char i=0; P0=P1=0x00; while(1) { for(i=0x00;i<0xff;i++) P0=P1=i; for(i=0xff;i>0x00;i--) P0=P1=i; } /* P0 as Output port */ /* Generate ON pulse */ /* Generate OFF pulse */ } 34.d Program for dual DAC interfacing to generate sine waveform. To generate a sine wave, we first need a table whose values represent the magnitude of the sine of angles between 0 360 degrees. The values for the sine function vary form -1.0 to +1.0 for 0- to 360- degree angles. Therefore, the table values are integer numbers representing the voltage magnitude for the sine of theta. This method ensures that only integer numbers are output to the DAC by the 8051 microcontroller. Table below shows the angles, the sine values, the voltage magnitudes, and the integer values representing the voltage magnitude for each angle. To generate table, we assumed the full-scale voltage of 10 V for DAC output. Fullscale output of the DAC is achieved when all the data inputs of the DAC are high. Therefore, to achieve the full-scale 10 V output, we use following equation. Vout=5V+(5V*Sinθ) Angle ‘θ’ in degrees 0 10 . . . . . . . 350 360 Sinθ Vout=5V+(5V*Sinθ) Dept. of ECE, B.I.T., Mangalore 34 Values sent to DAC(decimal) Vout*25.6 2012-13 10ESL47 Microcontrollers Lab Program: #include <REG51xD2.H> void main() { unsigned char i, wave[36]={128,148,171,192,209,225,238,245,253,255,253, 245,238,225,209,192,171,128,104,82,64,43,28,15,07,01,00,0 1,07,15,28,43,64,82,104}; P0 = 0x00; while(1) { for (i=0; i<36; i++) P0=P1=wave[i]; } } Dept. of ECE, B.I.T., Mangalore 35 2012-13 10ESL47 Microcontrollers Lab 35. Write a C program to interface stepper motor. Circuit Diagram: 8 0 5 1 P 0.0 P 0.7 Stepper Motor Driver circuit Stepper Motor Theory: Stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied. Stepper Motor Advantages: 1. The rotation angle of the motor is proportional to the input pulse. 2. The motor has full torque at standstill (if the windings are energized) 3. Precise positioning and repeatability of movement since good stepper motors have an accuracy of 3 – 5% of a step and this error is non cumulative from one step to the next. 4. Excellent response to starting/stopping/reversing. 5. Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply dependant on the life of the bearing. 6. The motors response to digital input pulses provides open-loop control, making the motor simpler and less costly to control. 1. It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the shaft. 2. A wide range of rotational speeds can be realized as the speed is proportional to the frequency of the input pulses. Stepper Motor Disadvantages: 1. Resonances can occur if not properly controlled. 2. Not easy to operate at extremely high speeds. Open Loop Operation: One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open loop system. Open loop control means no feedback information about position is needed. This type of control eliminates the need for expensive sensing and feedback devices such as optical encoders. Your position is known simply by keeping track of the input step pulses. Stepper Motor Types: • Variable-reluctance • Permanent-magnet Dept. of ECE, B.I.T., Mangalore 36 • Hybrid 2012-13 10ESL47 Microcontrollers Lab // Program to interface stepper motor #include <REG51xD2.H> void delay (unsigned int x) { for(;x>0;x--); return; } main ( ) { unsigned char Val, i; P0=0x00; while(1) { Val = 0x11; for (i=0;i<4;i++) { P0 = Val; Val = Val<<1; delay (500); } } } /* Delay Routine */ /* Val= Val>>1; for clockwise direction*/ Motor Specifications: Step Angle = 1.8 degrees Step angle accuracy = 5% Holding Torque = 40Ncm Rotor Inertia = 115grcm2 Weight = 0.5Kg Insulation = Class B Dept. of ECE, B.I.T., Mangalore 37 2012-13 10ESL47 Microcontrollers Lab 36. Write a C program to interface LCD and keypad Block Diagram: P1.0 . . P1.7 8 0 5 1 LCD KEY BOARD P2 P0 Keyboard: HEX values of the keys: LABLE ON THE KEYTOP HEX CODE LABLE ON THE KEYTOP HEX CODE 0 1 2 3 4 5 6 7 8 9 . + 0 1 2 3 4 5 6 7 8 9 0A 0B * / % AC CE CHK = MC MR M M+ 0C 0D 0E 0F 10 11 12 13 14 15 16 17 Dept. of ECE, B.I.T., Mangalore 38 2012-13 10ESL47 Microcontrollers Lab Program to interface LCD and KEYPAD : #include <REG51xD2.H> #include "lcd.h" unsigned char getkey(); void delay(unsigned int); main() { unsigned char key,tmp; InitLcd(); //Initialise LCD WriteString("Key Pressed="); // Display msg on LCD while(1) { GotoXY(12,0); //Set Cursor Position key = getkey(); //Call Getkey method } } unsigned char getkey() { unsigned char i,j,k,indx,t; P2 = 0x00; //P2 as Output port indx = 0x00;//Index for storing the 1st value of scanline for(i=1;i<=4;i<<=1) //for 4 scanlines { P2 = 0x0f & ~i; //write data to scanline t = P0; //Read readlines connected to P0 t = ~t; if(t>0) //If key press is true { delay(6000); //Delay for bouncing for(j=0;j<=7;j++) //Check for 8 lines { t >>=1; if(t==0) //if get pressed key { k = indx+j; //Display that by converting to Ascii t = k>>4; t +=0x30; WriteChar(t); //Write upper nibble t = k & 0x0f; if(t > 9) t+=0x37; else t+=0x30; WriteChar(t); //write lower nibble return(indx+j); //Return index of the key pressed } } } indx += 8; //If no key pressed increment index } } void delay(unsigned int x) //Delay routine { for(;x>0;x--); } Dept. of ECE, B.I.T., Mangalore 39 2012-13 10ESL47 Microcontrollers Lab Additional Programs 1. Program to check whether given number is palindrome or not. mov 30h,#81h mov r0,30h mov r1,#08h mov 31h,#00h clr c back: mov a,30h rlc a mov 30h,a mov a,31h rrc a mov 31h,a djnz r1,back cjne a,00h,npal mov a,#0ffh sjmp next npal: mov a,#00h next: sjmp $ end 2. Program to find the average of N eight-bit numbers. Mov dptr, #9000h Mov r0, #04h Mov r1, #00h Mov r2, #00h Clr c Mov r4, #04h Back: mov a, @dptr Mov r3, a Inc dptr Mov a, r1 Add a, r3 Jnc ahead Inc r2 Ahead: mov r1,a Djnz r0,back Mov r5, #00h Clr c Mov a,r1 Again:subb a, r4 Inc r5 Jc next Sjmp again Next:cjne r2,#00,loc Dec r5 Dept. of ECE, B.I.T., Mangalore Add a,r4 Movx @dptr,a Mov a,r5 Inc dptr Movx @dptr, a Sjmp end1 Loc: dec r2 Sjmp again End1:lcall 0003h end 40 2012-13 10ESL47 Microcontrollers Lab 3. Program to generate first ten Fibonacci numbers. Mov dptr, #9000h Mov r3, #08h Movx a, @dptr Mov r0,a Inc dptr Movx a, @dptr Back: xch a, r0 Add a,r0 Inc dptr Movx @dptr,a Djnz r3,back Lcall 0003h 4. Program to add multibyte numbers. Mov dptr,#9000h Mov r1,#04h Mov r2,#90h Mov r3,#91h Mov r4,#92h Clr c Mov dph,r2 Back: movx a, @dptr Mov r5,a Mov dph,r3 Movx a,@dptr Addc a,r5 //Note:For multibyte subtraction put subb a,r5 Mov dph,r4 Movx @dptr,a Inc dptr Djnz r1,back Jnc end1 Mov a,#01h Movx @dptr, a End1:lcall 0003h End 5. Program to search a key element in an array and display its position if it is found else display 00h to indicate not found. Mov dptr,#9000h Movx @dptr,a Mov f0,#02 Sjmp end1 Mov r1,#0a Down:inc dptr Mov r2,#00 Djnz r1,next Next:movx a,@dptr Mov a ,#00 Inc r2 Mov dpl,#50 Cjne a,f0,down Movx @dptr,a Mov dpl,#50 End1:lcall 0003 Mov a,#ff End Movx @dptr,a Mov a,r2 Inc dptr Dept. of ECE, B.I.T., Mangalore 41 2012-13 10ESL47 Microcontrollers Lab Viva Questions 1. 2. 3. 4. 5. 6. 7. What do you mean by Embedded System? Give examples. Why are embedded Systems useful? What are the segments of Embedded System? What is Embedded Controller? What is Microcontroller? List out the differences between Microcontroller and Microprocessor. How are Microcontrollers more suitable than Microprocessor for Real Time Applications? 8. What are the General Features of Microcontroller? 9. Explain briefly the classification of Microcontroller. 10. Explain briefly the Embedded Tools. 11. Explain the general features of 8051 Microcontroller. 12. How many pin the 8051 has? 13. Differentiate between Program Memory and Data Memory. 14. What is the size of the Program and Data memory? 15. Write a note on internal RAM. What is the necessity of register banks? Explain. 16. How many address lines are required to address 4K of memory? Show the necessary calculations. 17. What is the function of accumulator? 18. What are SFR’s? Explain briefly. 19. What is the program counter? What is its use? 20. What is the size of the PC? 21. What is a stack pointer (SP)? 22. What is the size of SP? 23. What is the PSW? And briefly describe the function of its fields. 24. What is the difference between PC and DPTR? 25. What is the difference between PC and SP? 26. What is ALE? Explain the functions of the ALE in 8051. 27. Describe the 8051 oscillator and clock. 28. What are the disadvantages of the ceramic resonator? 29. What is the function of the capacitors in the oscillator circuit? 30. Show with an example, how the time taken to execute an instruction can be calculated. 31. What is the Data Pointer register? What is its use in the 8051? 32. Explain how the 8051 implement the Harvard Architecture? 33. Explain briefly the difference between the Von Neumann and the Harvard Architecture. 34. Describe in detail how the register banks are organized. 35. What are the bit addressable registers and what is the need? 36. What is the need for the general purpose RAM area? 37. Write a note on the Stack and the Stack Pointer. 38. Why should the stack be placed high in internal RAM? 39. Explain briefly how internal and external ROM gets accessed. 40. What are the different addressing modes supported by 8051 Microcontroller ? 41. Explain the Immediate Addressing Mode. 42. Explain the Register Addressing Mode. 43. Explain the Direct Addressing Mode. Dept. of ECE, B.I.T., Mangalore 42 2012-13 10ESL47 Microcontrollers Lab Explain the Indirect Addressing Mode. 45. Explain the Code Addressing Mode. 46. Explain in detail the Functional Classification of 8051 Instruction set 47. What are the instructions used to operate stack? 48. What are Accumulator specific transfer instructions? 49. What is the difference between INC and ADD instructions? 50. What is the difference between DEC and SUBB instructions? 51. What is the use of OV flag in MUL and DIV instructions? 52. What are single and two operand instructions? 53. Explain Unconditional and Conditional JMP and CALL instructions. 54. Explain the different types of RETURN instructions. 55. What is a software delay? 56. What are the factors to be considered while deciding a software delay? 57. What is a Machine cycle? 58. What is a State? 59. Explain the need for Hardware Timers and Counters? 60. Give a brief introduction on Timers/Counter. 61. What is the difference between Timer and Counter operation? 62. How many Timers are there in 8051? 63. What are the three functions of Timers? 64. What are the different modes of operation of timer/counter? 65. Give a brief introduction on the various Modes. 66. What is the count rate of timer operation? 67. What is the difference between mode 0 and mode 1? 68. What is the difference Modes 0,1,2 and 3? 69. How do you differentiate between Timers and Counters? 70. Explain the function of the TMOD register and its various fields? 71. How do you control the timer/counter operation? 72. What is the function of TF0/TF1 bit 73. Explain the function of the TCON register and its various fields? 74. Explain how the Timer/Counter Interrupts work. 75. Explain how the 8051 counts using Timers and Counters. 76. Explain Counting operation in detail in the 8051. 77. Explain why there is limit to the maximum external frequency that can be counted. 78. What’s the benefit of the auto-reload mode? 79. Write a short note on Serial and Parallel communication and highlight their advantages and disadvantages. 80. Explain Synchronous Serial Data Communication. 81. Explain Asynchronous Serial Data Communication. 82. Explain Simplex data transmission with examples. 83. Explain Half Duplex data transmission with examples. 84. Explain Full Duplex data transmission with examples. 85. What is Baud rate? 86. What is a Modem? 87. What are the various registers and pins in the 8051 required for Serial communication? Explain briefly. 88. Explain SCON register and the various fields. 89. Explain serial communication in general (synchronous and asynchronous). Also explain the use of the parity bit. 44. Dept. of ECE, B.I.T., Mangalore 43 2012-13 10ESL47 Microcontrollers Lab 90. Explain the function of the PCON register during serial data communication. 91. How the Serial data interrupts are generated? 92. How is data transmitted serially in the 8051? Explain briefly. 93. How is data received serially in the 8051? Explain briefly. 94. What are the various modes of Serial Data Transmission? Explain each mode briefly. 95. Explain with a timing diagram the shift register mode in the 8051. 96. What is the use of the serial communication mode 0 in the 8051? 97. Explain in detail the Serial Data Mode 1 in the 8051. 98. Explain how the Baud rate is calculated for the Serial Data Mode 1. 99. How is the Baud rate for the Multiprocessor communication Mode calculated? 100. Explain in detail the Multiprocessor communication Mode in the 8051. 101. Explain the significance of the 9th bit in the Multiprocessor communication Mode. 102. Explain the Serial data mode 3 in the 8051. 103. What are interrupts and how are they useful in Real Time Programming? 104. Briefly describe the Interrupt structure in the 8051. 105. Explain about vectored and non-vectored interrupts in general. 106. What are the five interrupts provided in the 8051? 107. What are the three registers that control and operate the interrupts in 8051? 108. Describe the Interrupt Enable (IE) special function register and its various bits. 109. Describe the Interrupt Priority (IP) special function register and its need. 110. Explain in detail how the Timer Flag interrupts are generated. 111. Explain in detail how the Serial Flag interrupt is generated. 112. Explain in detail how the External Flag interrupts are generated. 113. What happens when a high logic is applied on the Reset pin? 114. Why the Reset interrupt is called a non-maskable interrupt? 115. Why do we require a reset pin? 116. How can you enable/disable some or all the interrupts? 117. Explain how interrupt priorities are set? And how interrupts that occur simultaneously are handled. 118. What Events can trigger interrupts, and where do they go after getting triggered? 119. What are the actions taken when an Interrupt Occurs? 110. What are Software generated interrupts and how are they generated? 111. What is RS232 and MAX232? 112. What is the function of RS and E pins in an LCD? 113. What is the use of R/W pin in an LCD? 114. What is the significance of DA instruction? 115. What is packed and unpacked BCD? 116. What is the difference between CY and OV flag? 117. When will the OV flag be set? 118. What is an ASCII code? Dept. of ECE, B.I.T., Mangalore 44 2012-13 10ESL47 Microcontrollers Lab MICROCONTROLLER- LAB QUESTION BANK 1. a) Write an ALP to move a Block of N-data starting at location X to location Y. b) Write a C program to interface stepper motor to 8051. 2. a) Write an ALP to exchange two blocks of data present at location X and Y respectively. b) Write a C program to generate Sine waveform using DAC. Display the waveform on CRO. 3. a) Write an ALP to arrange a set of N 8-bit numbers starting at location X in ascending/descending order. b) Write a C program to generate triangular wave of amp = ____ using DAC. Display the waveform on CRO. 4. a) Write an ALP to perform 16-bit addition/subtraction. b) Write a C program to interface DC motor to 8051. 5. a) Write an ALP to perform 16-bit multiplication. b) Write a C program to generate Ramp wave of amp = ____ using DAC. Display the waveform on CRO. 6. a) Write an ALP to find square/cube of given 8-bit data. b) Write a C program to interface stepper motor to 8051. 7. a) Write an ALP to count number of 1’s and 0’s in the given 8-bit data. b) Write a C program to interface Elevator to 8051. 8. a) Write an ALP to find whether given number is even or odd. b) Write a C program to interface LCD panel and Hex keypad to 8051. 9. a) Write an ALP to implement a binary/decimal ______ counter. b) Write a C program to interface stepper motor to 8051. 10. a) Write an ALP to convert given ASCII number to its equivalent Decimal number. b) Write a C program to interface Elevator to 8051. 11. a) Write an ALP to convert given Decimal number to its equivalent ASCII. b) Write a C program to interface LCD panel and Hex keypad to 8051. 12. a) Write an ALP to convert given Hexadecimal number to its equivalent Decimal number. b) Write a C program to interface DC motor to 8051. 13. a) Write an ALP to convert given Decimal number to its equivalent Hexadecimal. b) Write a C program to interface DC motor to 8051. 14. a) Write an ALP to convert two digit BCD number to its equivalent ASCII value. b) Write a C program to generate square wave of amp = ____ using DAC. Display the waveform on CRO. 15. a) Write an ALP to find the largest / smallest element in an array. b) Write a C program to interface stepper motor to 8051. Dept. of ECE, B.I.T., Mangalore 45 2012-13 10ESL47 Dept. of ECE, B.I.T., Mangalore Microcontrollers Lab 46 2012-13 10ESL47 Microcontrollers Lab Instruction set Dept. of ECE, B.I.T., Mangalore 47 2012-13 10ESL47 Dept. of ECE, B.I.T., Mangalore Microcontrollers Lab 48 2012-13 10ESL47 Microcontrollers Lab Practice does not make perfect. Only perfect practice makes perfect. Dept. of ECE, B.I.T., Mangalore 49 2012-13