Programs for 8051 microcontroller on keil uvision 3 / BLINKING OF LEDS USING 8051 kit /DISPLAY OF DIGITS ON THE SEVEN SEGMENT DISPLAY USING 8051


Programs for 8051 microcontroller on keil uvision 3



BLINKING OF LEDS USING 8051

AIM OF THE EXPERIMENT: To interface the LEDs to the 8051 and blink them continuously.

SOFTWARE REQUIRED: Keil Software
HARDWARE REQUIRED: Computer System, 8051 kit

COURSE OUTCOME/S:ETC/ECE 5.4.5: Design and implement microcontroller based applications

OBJECTIVES (SKILL SET / KNOWLEDGE TESTED / IMPARTED):
The main objective is to get familiar LED interfacing with 8051
To get familiar with 8051 kit


PROCEDURE:


  1. Open Keil
  2. Click on Project
  3. Select New Project
  4. Give name for the Project and Save.
  5. Go to SST dialogue box
  6. Go to SST89X516RD2( Click Ok.
  7. Click NO (Since the code is in Assembly not C)
  8. Target ( Source Group 1
  9. Add a File
  10. Go to File ( Click New( Save
  11. Give filename.asm and Save.
  12. Go to Source group1 ( Add existing file type to asm source file
  13. Select File
  14. Add (Close
  15. Open Source group1 ( File gets added
  16. Type the Program ( Save
  17. Click on options for Target
  18. Change the crystal frequency to 11.059 MHz
  19. Go to output tab ( Select Hex file ( OK ( Save
  20. Build the Program 
  21. Select the Target( Go to Project ( Build Target( this will create a Hex file.
  22. Double click on SST on Desktop
  23. Click on Start ( Go to My Computer
  24. Right click and manage ( Go to Device Manager(Ports( Check which port
  25. Press Reset and keep it pressed ( Go to options ( Select the correct COM port 
  26. Now release the reset at the same time you press OK
  27. You will see IAP status ( Default target ‘’ is successful
  28. Click on download( go to filename .hex, which is created after build.
  29. Click Open ( OK ( Yes
  30. Done ( Status will be displayed.
  31. Press Reset on the kit to see the LEDs blinking.



PROGRAM:


; LED Blinking
; Switch setting: SW25: (1-2), SW24: (1-2), SW26: (2-3).

org 00h
ljmp start ;jump to start on reset


;Delay routine approx. 1.5 seconds

delay:
mov r3,#0x02
mov r4,#0x0
mov r5,#0x0
loop:
djnz r5, loop
djnz r4, loop
djnz r3, loop
RET

; LED Blinking main program
start:
mov P2, #00h
acall delay
mov P2, #0FFh
acall delay
sjmp start

 END

RESULTS:LED blinking was observed on the 8051 kit


CONCLUSION: LED Program was successfully loaded and run on 8051 kit and LED blinking observed.




DISPLAY OF DIGITS ON THE SEVEN SEGMENT DISPLAY USING 8051

AIM OF THE EXPERIMENT: To interface the Seven Segment Display to the 8051, and display numbers 0-9 continuously.

SOFTWARE REQUIRED: Keil Software
HARDWARE REQUIRED: Computer System, 8051 kit

COURSE OUTCOME/S:ETC/ECE 5.4.5: Design and implement microcontroller based applications

OBJECTIVES (SKILL SET / KNOWLEDGE TESTED / IMPARTED):
The main objective is to get familiar with the Seven Segment interfacing with 8051
To study the Seven segment display


PROCEDURE:


  1. Open Keil
  2. Click on Project
  3. Select New Project
  4. Give name for the Project and Save.
  5. Go to SST dialogue box
  6. Go to SST89X516R02( Click Ok.
  7. Click NO (Since the code is in Assembly not C)
  8. Target ( Source Group 1
  9. Add a File
  10. Go to File ( Click New( Save
  11. Give filename.asm and Save.
  12. Go to Source group1 ( Add existing file type to asm source file
  13. Select File
  14. Add (Close
  15. Open Source group1 ( File gets added
  16. Type the Program ( Save
  17. Click on options for Target
  18. Change the crystal frequency to 11.059 MHz
  19. Go to output tab ( Select Hex file ( OK ( Save
  20. Build the Program 
  21. Select the Target( Go to Project ( Build Target( this will create a Hex file.
  22. Double click on SST on Desktop
  23. Click on Start ( Go to My Computer
  24. Right click and manage ( Go to Device Manager(Ports( Check which port
  25. Press Reset and keep it pressed ( Go to options ( Select the correct COM port 
  26. Now release the reset at the same time you press OK
  27. You will see IAP status ( Default target ‘’ is successful
  28. Click on download( go to filename .hex, which is created after build.
  29. Click Open ( OK ( Yes
  30. Done ( Status will be displayed.
  31. Press Reset on the kit to see the LEDs blinking.



PROGRAM:

/*------------------7 Segment Display---------------------*/
/*Switch setting: SW22: (1-2), SW23: (1-2)*/
/*Peripheral: Common Anode 7 Segment Display.* /
/*Interfacing Pins:
P0.0------> A
P0.1------> B
P0.2------> C
P0.3------> D
P0.4------> E
P0.5------> F
P0.6------> G
P0.7------> H
-----------------------------------------------------------------------------------------
Jumper Settings:
J1: 1-2 J2:Any J3:2-3 J4: 1-2 J5:Any J6:2-3
======================================================================*/

org 0x00
ljmp start ;Jump to start on reset
delay: ;delay routine: approx 1.5 second
mov r3,#0x04
mov r4,#0x0
mov r5,#0x0
loop:
djnz r5, loop
djnz r4, loop
djnz r3, loop
       RET

;Lookup table for bit patterns for numerals
;TBL:    DB   0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10
TBL:    DB   0xF6,0x90,0xE5,0xB5,0x93,0x37,0x77,0x94,0xF7,0xB7

start:
mov P0,#0xFF          ; Turn off all LEDs
mov r1 ,#0x0A        ; Load the count equal to no of digits to be
; Displayed, use register other than used in delay function
mov dptr ,#TBL          ; Load the pointer to the start of look up table
LOOP1:
mov a,#00                ; clear the accumulator
movc a ,@a+dptr ; Load the bit pattern for the digit pointed by DPTR
cpl a
mov P0,a
inc dptr ; increment the pointer
lcall delay
djnz r1, LOOP1          ; Loop till all 0-9 digits are displayed on 7-seg
sjmp start                ; Go to the start, REstart the numbers 0-9
END



RESULT: Seven Segment displaying numbers 0-9 were observed on the 8051 kit



CONCLUSION: 7-segment Program was successfully loaded and runon 8051 kit and 7-segment display was seen displaying numbers from 0-9 continuously