circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 155 June 2003
Encore!
Zilog's Z8 Flash Memory-Based Micro


LOOSEN UP

Before diving into the code for a new micro, it’s always good to start with something that already works. You can avoid immediate frustration by running (and reading) the tutorial code included in the development kit. The kit comes with a sample assembly test program on the CD; it prints a message on the four 5 × 7 LEDs.

This application includes four files: encore_main.asm, xtools2_led.asm, scroll2_led.asm, and lights_out.asm. Basically, the main file continuously calls the other three files in endless succession. The xtools2_led.asm file defines a number of macros to write data to the 5 × 7 LEDs and calls these from a number of routines, which set particular character combinations on the displays. The combinations appear as characters jumping from one display position to the next (i.e., “XTOOLS RULES”). The scroll2_led.asm file is similar code with a second message, “PASS.” The lights_out.asm file simply turns off all of the LEDs.

The routine used a character-jumping technique, so the scroll wasn’t the smoothest. To get warmed up, I chose to rewrite this for a smoother scroll. Although the 5 × 7 LEDs in the PCB kit are separated, the spacing is only 0.1”. This happens to be the same as the LED spacing within each display; therefore, as the columns of a character scroll between two displays, the column spacing remains constant as it scrolls through this darkened space. This adds to the smoothness of the scroll.

Certainly, the application could have been written in a single .asm file, but the technique used demonstrates the use of multiple files. Thus, it’s part of the learning experience.

I altered the LED routines to accept register data (i.e., R5 to R9), as opposed to the sample’s use of constants. This change allows the same routine to be used to write all data. In the original sample, the message is defined by the constants in each routine (i.e., one routine for displaying each set of characters on the four LEDs). Now the message is defined in a table of column data for each character (with a column of 00 data as an empty column between characters). Only the table length limits the message length.

The last piece of the puzzle is a loop (download from the Circuit Cellar ftp site) that indexes into the table, transfers the appropriate data into R5-R9, and calls the display routine. Incrementing the table pointer by one each time through the loop allows the character data to scroll one column at a time.