 |
Benjo U. Tirol, author
and former editor in chief of the Electronics Enthusiasts magazine,
send in this series of article detailing how to set the z8mulator to work on the
training experiments discussed in his very popular book Learning
Microcontrollers thru Experiments (published by Alexan Foundation,
available on Alexan outlets and the National Bookstore). Our profound thanks for his
generous and invaluable support! - e-Gizmo Mechatronix Central. |
Using e-Gizmo’s
Z8MULATOR for Learning Microcontrollers thru Experiments - Part I
One
alternative to learning Z8 microcontroller programming is to use a
cost-effective solution such as e-Gizmo’s
Z8MULATOR module.
This module
is an excellent training tool for Z8 microcontroller programming and is
very affordable for students and hobbyists. The module comes with Flash
memory that allows it to be reprogrammed for various stand-alone
applications, and in this case, for learning Z8 programming.
Unlike the
Z86CCP00ZEM emulator, which does not retain your software, the Z8mulator
saves your downloaded program into its flash memory. It runs independently
even if disconnected from the PC--a very handy feature for demonstration
purposes. The stand-alone feature also saves Z8-based circuit designers
substantial development time since the module itself can be used as the
main controller in any application without having to go through detailed
hardware design.
In this
introductory article, we’ll consider two simple experiments (from the book
Learning Microcontrollers thru Experiments published by Alexan
Foundation) and show how the program should be modified to run on the
Z8MULATOR.
Note that
the Z8MULATOR has a 34-pin I/O pin connector. If you already have a
target module using Z86E04/08, you’ll need to rewire ports P2 and P3 as
illustrated in Figure 1, or you can assemble the simple test circuit shown
in Figure 2.

Figure 1. z8mulator to 'z86e04/08' conversion wiring diagram.

Figure 2. Schematic diagram of the test circuit you can build if you do
not have the experiment module yet.
Lesson 1. Using Port 2 to Turn LEDs ON and OFF
.org 0h
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.org 0ch ; replace with
100ch
;
----------------------------INITIALIZATION----------------------
di ; interrupts are disabled
ld spl, #80h ; stack pointer is initialized to 80h
;ld
p01m, #05h ; port 0 as input
; disable this
instruction by placing
; a semi-colon
before the line
ld p2m, #00h ; port 2 as output
ld p3m, #01h ; set up for digital inputs and port 2
;
is in push-pull mode
srp #10h ; stack register pointer for r0 to r15
;
begins at 10h
;
----------------------------- MAIN LOOP -----------------------
start:
ld p2, #11111110b ; LED is switched on
call delay ; delay routine is called to keep LED
;
lit
; during the duration
ld p2, #11111111b ; LED is switched off
call delay ; delay routine is called to keep LED
;
off
; during the duration
jr start
;
------------------------ DELAY ROUTINE -----------------------
delay: ld r0, #0ffh ; initialize counter (try changing
;
the value)
loop1: ld r1, #0ffh ; initialize counter (try changing
;
the value)
loop2: djnz r1, loop2 ; decrement and loop back until
;
r1 is zero
djnz r0, loop1 ; decrement and loop back until
;
r0 is zero
ret ; return to main loop
.end
_________________________________________________________________________________
Lesson 2. Simple Running Lights
.org 00h
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.org 0ch ; replace with
100ch
;
-----------------------------INITIALIZATION---------------------
di ; interrupts are
disabled
ld spl, #80h ; stack pointer
is initialized to 80h
;ld
p01m, #05h ; port 0 as input
; disable this
instruction by placing
; a semi-colon
before the line
ld p2m, #00h ; port 2 as
output
ld p3m, #01h ; set up for
digital inputs and port 2
;
is in push-pull mode
srp #10h ; stack register
pointer for r0 to r15
;
begins at 10h
ld p2, #11111110b ; LED is
switched on where 0= ON,
;
1=OFF
; -------------------------- MAIN LOOP
--------------------------
start:
com p2 ; complement p2
call delay ; delay
com p2 ; restore p2
rl p2 ; lighted LED is
moved one bit to the
;
left
call delay ; delay
jr start
; -------------------- DELAY ROUTINE
---------------------------
delay: ld r0, #02h ; initialize
count down timer
;
(try changing the value)
loop1: ld r1, #00h ; initialize
counter
loop2: ld r2, #00h ; initialize
counter
loop3: djnz r2, loop3 ; decrement and
loop back
;
until r2 is zero
djnz r1, loop2 ; decrement and
loop back
;
until r1 is zero
djnz r0, loop1 ; decrement and
loop back
;
until r0 is zero
ret ; return to main
loop
.end
In the
future we’ll consider the other experiments or lessons in the book
Learning Microcontrollers Thru Experiments and modify the lessons to
adapt them to the Z8MULATOR.
Go to: Using e-Gizmo’s
Z8MULATOR for Learning Microcontrollers thru Experiments - Part II
Go to: Using e-Gizmo’s
Z8MULATOR for Learning Microcontrollers thru Experiments - Part III
|