Microprocessor System Lab Exercise #1
Microprocessor System Lab Exercise #1
Microprocessor System Lab Exercise #1
Laboratory Experiment
Page 1
Figure
Laboratory Experiment
1.3
Page 2
The Init Ports is required to set the ports to inputs or outputs as well as other registers. The
turn on LED will require us to load a low logic level to Port2 in order to lit the LED and loading a high
logic level will turn the LED off. The delay subroutine will make us see the transition between turning
on and turning off because without the delay the LEDs will turn on and off at a very fast rate that our
human eye cannot see.
PROCEDURE
1. Connect the emulation cable to the target module which is the TM-1.
2. Adjust your AC/DC adaptor power supply with the output voltage of 9Vdc/0.5A.
3. Connect it to your target module. The inner conductor is the positive terminal.
4. Make sure that the Vcc pin (J1) on the emulator is not connected if your target module has
its own power supply.
5. Turn on the PC, then the emulator, and finally the TM-1.
6. After setting up the hardware, write the following code below on the ZDS software then
debug it and run the program.
Code:
.org
.word
.word
.word
.word
.word
.word
.org
00h
0
0
0
0
0
0
0ch
; ---------------------------------------------------Initialization----------------------------------------------------di
ld
ld
ld
ld
ld
module.
spl, #80h
p01m, #05h
p2m, #00h
p3m, #01h
rp, #10h
;disable interrupts
;stack pointer is initialized at 80h
;port 0 is configured as input
;port 2 is configured as output
;port 3 is digital, port2 in Push-Pull mode
;register pointer is initialized at 10h ; srp #10h - for active high led
; ---------------------------------------------------Main Loop-----------------------------------------------------start:
ld p2, #11111110b
call delay
ld p2, #11111111b
call delay
jr start
;turn on LED
;call delay subroutine
;turn off LED
;call delay subroutine
;go back to start
Page 3
;end of program
7. Observe the running the code above, which bit of MCUs port2 will lit? __________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
____________________
8. After debugging the following code above, change this routine to turn all leds on and off,
connected on PORT 2.
9. Write your code below for procedure no. 8. Using the concept of active low.
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
____________________________________________________________________________________
Exercise 1. Try using different delay periods to vary the ON and OFF duration of the leds. Write your
code below.
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
Laboratory Experiment
Page 4
Exercise 3. Write the code below, in executing exercise 2 using active high concept.
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
________________________________________________________________________________
GENERALIZATION
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
______________________________________________________________________________________________________
____________________________________________________________________________________
Laboratory Experiment
Page 5
Laboratory Experiment
Page 6