;========================================================
; PROG_10 : RUNNING LED
;========================================================
;
;PROGRAM DESCRIPTION:
;This program will turn on 4 LEDs at a time while other 4 LEDs are turned off. Turn on pattern
;is 1st pattern= 10101010, 2nd pattern=01010101 : 1=turn off LED, 0=turn on LED
;
;
;
;HARDWARE NOTES :
;MCU type : ATMEL AT89S51 24PC
;Crystal : 3.58 MHz Crystal
;I/O Port : Port 1 used as an Output to drive the LEDs
;LED Pin Conn :
; : Port1.0 (pin1) LED_0
; : Port1.1 (pin2) LED_1
; : Port1.2 (pin3) LED_2
; : Port1.3 (pin4) LED_3
; : Port1.4 (pin5) LED_4
; : Port1.5 (pin6) LED_5
; : Port1.6 (pin7) LED_6
; : Port1.7 (pin8) LED_7
;The Anodes of LED_0 to LED_7 are connected to a resitors of 560 Ohms then connect to +5D.
;All Cathodes are connected to pins 1 to 8 of the AT89S51 respectively.
;
;Variable Declarations :
LEDOUT EQU P1 ;Port1 pins 1 to 8 of AT89S51
;=============MAINLINE====================================
ORG 0H ;Program Execution starts here
START: MOV A, #10101010B ;Initiate the 1st LED sequence :
;10101010
MOV LEDOUT,A ;Now, light 4 LEDs
CALL DELAY ;This delay determines how
;long the LED Light
MOV A, #01010101B ;Initiate the 2nd LED sequence :
;01010101
MOV LEDOUT,A ;Now, light 4 LEDs
CALL DELAY ;This delay determines how long the LED
;Light
JMP START ;it will go to label START
;================SUBROUTINE : DELAY======================
DELAY:
MOV R7,#100 ;Set R7 to loop 100 times after each R6
;loop for 255 times
OLOOP: MOV R6,#255 ;Set R6 to 255
ILOOP: DJNZ R6, ILOOP ;Decrement R6 by 1, if R6 is not equal
;to "0" then go to label ILOOP
DJNZ R7,OLOOP ;If R6 loops 255 times, decrement R7 by
;1 and if R7 is equal to 0, it will exit
;DELAY and go back to the Main
;Program. If R6 is not equal to 0, then
;ILOOP
RET ;Return to the Main Program
;========================================================
END ;This is the end of the program which will
;instruct the Assembler to stop assembling the
;source file.
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
;Distribution Policy:
; --------------------
; All 8051 PROGRAMS in package with the STARTER MCU-EB8051-"2" MicroController
; Trainer Kit contained in the CD ROM. The usage of this program is described
; in details in the User's Guide : my8051 VOL. 2 MicroController Trainer Kit
; the ATMEL AT89S51 ISP Microcontroller.
;
You may use, copy and distribute it FREE OF CHARGE under the following
; conditions:
;
; 1. For the use with the STARTER MCU-EB8051 Trainer Kit-"2"
; 2. No changes on the original source file.
; 3. Must not be sell for profits.
; 4. Must not use for other similar Trainer Boards.
; 5. Exceptions are only possible with a written permission of the author.
;Implementation:
; All 8051 PROGRAMs in package with the STARTER MCU-EB8051-"2" Trainer Kit have been
; developed with:
;
; Acebus 8051 IDE (demo version) - visit
http://www.acebus.com;
; No formal process has been used during development, and there were
; no efforts in quality assurance or quality management!
;Disclaimer:
; -----------
; All 8051 PROGRAMs in package with the STARTER MCU-EB8051-"2' Trainer Kit
; is provided as it is, without warranty of any kind.
; The author will not be liable for any special, incidental, consequential,
; indirect or similar damages for any reason in the use and mis-use of this
; program.
;
;
; F. Dandy Menor
; Heart Systems
; Baguio City
; Philippines, 2600
;
; myHobby - Educational Trainer
; - Electronics Series