Beruflich Dokumente
Kultur Dokumente
GUILALAS
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.
Exercise No. 2
Turning LED's on and off using TM-1
OBJECTIVES
1. Identify the programming structure of Z86E04 using its own assembly language.
2. Look into importance of basic software techniques to control port that is to set or reset the ports pins.
3. Design a program for active high and active low.
4. Write and execute a hello world program which blinks the LEDs connected to port2 at bit 0.
EQUIPMENT
Quantity
1 PC with ZDS Software
1 Zilog Z86CCP00ZEM Development Board
1 Zilog Training Module (TM-1)
1 RS 232 Serial Cable
1 Emulation Cable
1 Power Supply
BASIC
Before we start programming we look at the basic circuit for the Z8 microcontroller. Figure 1 shows the basic circuit with crystal.
Since we are going to use the Z86CCP00ZEM emulator for our experiments, we will get the 5V from the emulator but for other modules a
separate power supply is needed. Also the crystal is not necessarily needed because our emulator contains the crystal oscillator circuit.
Make sure to set the jumpers on the emulator properly.
HARDWARE
In this lesson, we will be using the Zilog TM-1. This module is active low which means to activate a LED the MCU should output
a logic 0 or we can use an 8-bit LED module connected to the MCU's PORT2. This LED's are active high which means to activate a LED
the MCU should output a logic 1. Figure 2 shows the schematic.
SOFTWARE
We will be writing a hello world program which blinks the LEDs connected to PORT2. To do this we follow the program flow chart
shown below:
Figure 1.3
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
7. Connect the emulation cable to the target module which is the TM-1.
8. Adjust your AC/DC adaptor power supply with the output voltage of 9Vdc/0.5A.
9. Connect it to your target module. The inner conductor is the positive terminal.
10. Make sure that the Vcc pin (J1) on the emulator is not connected if your target module has its own power supply.
11. Turn on the PC, then the emulator, and finally the TM-1.
12. After setting up the hardware, write the following code below on the ZDS software then debug it and run the program.
Code:
.org 00h
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.org 0ch
; ---------------------------------------------------Initialization-----------------------------------------------------
di ;disable interrupts
ldspl, #80h ;stack pointer is initialized at 80h
ld p01m, #05h ;port 0 is configured as input
ld p2m, #00h ;port 2 is configured as output
ld p3m, #01h ;port 3 is digital, port2 in Push-Pull mode
ldrp, #10h ;register pointer is initialized at 10h ; srp #10h - for active high led module.
; ---------------------------------------------------Main Loop------------------------------------------------------
start:
ld p2, #11111110b ;turn on LED
call delay ;call delay subroutine
ld p2, #11111111b ;turn off LED
call delay ;call delay subroutine
jr start ;go back to start
; -----------------------------------------------Delay subroutine--------------------------------------------------
13. Observe the running the code above, which bit of MCUs port2 will lit? __________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
__________________________________________________________________________________________________________
14. After debugging the following code above, change this routine to turn all leds on and off, connected on PORT 2.
15. 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.
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
_________________________________________________________________________________________________
Exercise 2.What will happen to the 8-bit active high led module shown in figure 1.2 if bit 1, 4, 5 and 7 will lit on? Just shade the circle.
Exercise 3.Write the code below, in executing exercise 2 using active high concept.
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
Exercise 4. What is the purpose of the instruction ld p2, #11111110b? Observe the output if you will change or add another ld p2
instruction.
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
GENERALIZATION
__________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________
______________________________________________________________________________________________________________