0% found this document useful (0 votes)
50 views1 page

MDE8051 Toggle

This document contains code to toggle the bits of ports P1 and P2 on an 8051 microcontroller trainer board with a one second delay. It connects the ports to LEDs so their toggling can be seen. The code loads alternating patterns into the ports, then calls a delay subroutine before repeating. The delay subroutine uses nested loops to count down registers over approximately one second based on the microcontroller's clock speed.

Uploaded by

pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views1 page

MDE8051 Toggle

This document contains code to toggle the bits of ports P1 and P2 on an 8051 microcontroller trainer board with a one second delay. It connects the ports to LEDs so their toggling can be seen. The code loads alternating patterns into the ports, then calls a delay subroutine before repeating. The delay subroutine uses nested loops to count down registers over approximately one second based on the microcontroller's clock speed.

Uploaded by

pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

;Toggling the bits of P1 and P2 on MDE 8051 Trainer with one-sec Delay

;Tested by M. Mazidi
;Modified from Examples in chaps 3 and 8 of 8051 Microcontroller book by Mazidis &
McKinlay
;Connect the P1 and P2 to LEDs to see the toggling.
ORG 0
MOV A,#0
MOV P1,A ;P1 as output
MOV P2,A ;P2 as output
BACK: MOV A,#55H
MOV P1,A
MOV P2,A
ACALL SDELAY ;one sec delay
MOV A,#0AAH
MOV P1,A
MOV P2,A
ACALL SDELAY
SJMP BACK
;-------------------------
;One sec. delay for DS89C4x0 with MDE8051 Trainer
;XTAL=11.0592 MHz on MDE8051, 1/11.0592 MHz=90 nsec
;45 x 255 x 242 x 4 x 90 ns = 999.7 msec
;Notice DS89C4x0 uses 4 clocks for Machine Cycle.

SDELAY:
MOV R5, #45
H3: MOV R4, #242
H2: MOV R3, #255
H1: DJNZ R3, H1
DJNZ R4, H2
DJNZ R5, H3
RET
;-----------------------
END

You might also like