Issue
153 April 2003
Test-Driving
the Z8
BRINGING
UP THE SOFTWARE
The
Z8 Encore! device that comes with the development kit
is a general-purpose microcontroller with a bevy of
on-chip goodies. The good news is that it’s really nice
to have all of those hardware gadgets to play with.
The bad news is that I haven’t written in Z80 code in
years, and I don’t want to learn the new Z8F6403 assembler
mnemonics just to be able to blink a dot on one of the
Lite-On display bricks. Besides, although the kit is
loaded, it’s still lacking one essential ingredient,
Ethernet.
Zilog
offers a ready-to-roll web server with a 10BaseT Ethernet
interface for approximately $800. If you don’t need
all of the bells and whistles on the $800 model, I’ll
show you how to get on the ’Net for less than $100 with
the $49 Z8 Encore! development kit.
After
carefully studying the physical attributes of the development
board, I explored the CD-ROM that accompanied the hardware.
There was just as much to learn about the example code
as there was about the jillions of parts on the Z8F6403-based
development board. I came into this project knowing
that the development kit included a C compiler and an
IDE. So, I decided to start by going after the samples
to load and compile correctly.
My
first brush with the Z8 Encore! IDE (ZDS II) smelled
a bit like Rabbit and tasted like 8051. Like Rabbit
Semiconductor’s ICs, the Z8F6403 is heavily register
and sub-register-based when it comes to accessing the
I/O ports and its internal peripherals. That makes sense
because the Rabbit micro is based on Z80 principles.
I was surprised yet pleased that the look and feel of
ZDS II was almost identical to the Keil C51 µVision
IDE. That meant that I could concentrate on getting
up to speed with the Z8F6403’s lingo without having
to fight the IDE.
I
love debugger mechanisms; however, in my opinion, the
best debugger tool when you’re on the ropes is a working
serial port. If you can get the C language printf statement
to put your characters in a HyperTerminal window, then
you have a means of communicating with yourself via
the program code. Take a peek at previous example code
that I’ve written for Circuit Cellar articles, and you’ll
see that I like to put debug printf in lines like "I
made it to here" as progress markers.
So,
the first thing I did was make sure I could pass data
through the development board console port to a HyperTerminal
session on a separate PC. Instead of reinventing the
stone cylinder, I used (and modified) the uartcode example
code to test my understanding of the Z8F6403’s UARTs.
The uartcode contains statements that initialize both
UARTs, read and write to program flash memory, and exercise
the printf function. When you run the uartcode code
from your own Z8 Encore! development kit, you’ll see
something similar to Photo 3.
|

(Click
here to enlarge)
|
Photo
3—This is a HyperTerminal shot showing the results
of a modified demo program I used to get familiar
with the Z8F6403 coding scheme and architecture.
The numbers are examples of printf options (i.e.,
string, integer, decimal, and float). EDWIN was
written in ASCII in a nondescript place in memory.
I decided to join EDWIN in his hideout. |
As
I was exploring the serial I/O code and hardware, I
was pleasantly surprised to find that the OCD and ZDS
II debugger components worked as advertised; and just
like the Keil C compiler, I had a great view of the
registers, processor internals, and various segments
of code and data memory. I could even open multiple
memory windows to look at different parts of the flash
memory or register set at the same time.
ZDS
II allows you to either simulate the code or download
it to the development board in IEEE-695 format through
the Target Interface Module Board. Source code for a
flash memory loader is included with the development
kit firmware for those of you who will need to load
the Z8F6403 flash memory without the help of the Target
Interface Module Board.
With
initial success in my back pocket, I proceeded to load
and run all of the sample code on the kit’s CD-ROM.
A couple of the programs used the Lite-On displays to
scroll messages. One message read "WELCOME TO Z8
ENCORE!" Another message started with a group of
smiley face images and then displayed "XTOOLS RULES!!!"
followed by the room temperature as reported by the
DS1722. I found it hard to believe that the Florida
Room was a perfect "25 DEGREES C," so I put
my finger on the DS1722 to see if the temperature reading
had actually changed. It had.
It
got better and better as I went. So far, I’ve seen plenty
of working example code. ZDS II has proven to be an
effective development tool and any software developer
who decides to scroll "XTOOLS RULES!!!" on
his company’s demo board can code with me any day.
When
I thought I was really ready to break out on my own
and write some code, I decided to run the main driver’s
demo program. As it turned out, it was probably already
loaded, and I decided to do my own thing and erase it
when I was experimenting with the serial code. Now I
had a serial connection established to an alternate
PC. When I fired up the program, not only did I get
the scrolling "WELCOME" message on the Lite-Ons,
I got the screen full of what you see in Photo 4. Everything
that I’ve talked about is in the menu. Now, not only
can I play, I also have the source code for enabling
and using the SPI and I2C subsystem ICs. In addition,
I use this program to do some manual debugging of flash
memory, SRAM, and the I/O ports if necessary.
|

(Click
here to enlarge)
|
Photo
4—You can test-drive the Z8F6403 from this console
display. Choosing the LED menu item allows you to
enter characters that are then automatically scrolled
across the four Lite-On dot bricks. |
OK,
I’m potty trained. Let’s write some real Z8F6403 code
and add Ethernet capability to the Z8 Encore! development
board.