Holtek HT-IDE User manual

HT-IDE User’s Guide
Second Edition
Copyright © 1999 by HOLTEK SEMICONDUCTOR INC. All rights reserved. Printed in Taiwan. No
part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form
by any means, electronic, mechanical photocopying, recording, or otherwise without the prior written
permission of HOLTEK SEMICONDUCTOR INC.

NOTICE
The information appearing in this Data Book is believed to be accurate at the time of publication.
However, HOLTEK assumes no responsibility arising from the use of the specifications described.
The applications mentioned herein are used solely for the purpose of illustration and HOLTEK
makes no warranty or representation that such applications will be suitable without further
modification, nor recommends the use of its products for application that may present a risk to
human life due to malfunction or otherwise.
HOLTEK reserves the right to alter its products without prior notification.

Contents
Part I Integrated Development Environment ............. 1
Chapter 1 Overview and Installation ........................................... 3
Introduction .................................................................................................... 4
System Configuration .................................................................................... 5
Installation ..................................................................................................... 7
System requirement ................................................................................. 7
Hardware installation .............................................................................. 7
Software installation ................................................................................ 8
Chapter 2 Quick Start .................................................................... 11
Chapter 3 HT-IDE Menu – File/Edit/View/Tools/Options ........ 15
Start the HT-IDE System ............................................................................ 15
File Menu ...................................................................................................... 17
Edit Menu ..................................................................................................... 18
View Menu .................................................................................................... 19
Tools Menu .................................................................................................... 20
Mask option ............................................................................................ 20
Diagnose .................................................................................................. 21
OTP programmer .................................................................................... 22
Library manager ..................................................................................... 22
VROM editor ........................................................................................... 23
Download voice ....................................................................................... 24
LCD simulator ........................................................................................ 24
Options Menu ............................................................................................... 24
Contents
i

Project command .................................................................................... 24
Debug command ..................................................................................... 27
Directories command ............................................................................. 29
Editor command ..................................................................................... 29
Color command ....................................................................................... 30
Font command ........................................................................................ 30
Chapter 4 HT-IDE Menu – Project ............................................... 31
Create a New Project ................................................................................... 32
Open and Close a Project ............................................................................. 32
Manage the Source Files of a Project .......................................................... 33
To add a source file to the project .......................................................... 33
To delete a source file from the project ................................................. 34
To move a source file up or down ........................................................... 34
Build a Project’s Task Files .......................................................................... 34
To build a project task file ...................................................................... 35
To rebuild a project task file .................................................................. 35
Assemble/Compile ........................................................................................ 35
To assemble or compile a program ........................................................ 36
Print Option Table Command .................................................................... 36
Chapter 5 HT-IDE Menu – Debug ................................................ 37
Reset the HT-IDE System ........................................................................... 38
To reset from the HT-IDE commands .................................................... 39
To reset from the target board ............................................................... 39
Emulation of Application Programs ............................................................ 40
To emulate the application program ..................................................... 40
To stop emulating the application program .......................................... 40
To run the application program to a line .............................................. 40
To directly jump to a line of an application program ........................... 41
Single Step .................................................................................................... 41
Breakpoints ................................................................................................... 42
Breakpoint features ............................................................................... 42
Description of breakpoint items ............................................................ 43
How to set breakpoints .......................................................................... 45
Trace the Application Program .................................................................... 47
About the trace mechanism and its requirements ............................... 47
To stop the trace mechanism ................................................................. 49
About the trace record format ............................................................... 52
Chapter 6 HT-IDE Menu – Window ............................................. 55
Window Menu Commands ........................................................................... 56
Open Windows List ...................................................................................... 59
HT-IDE User’s Guide
ii

Chapter 7 Simulation ..................................................................... 61
Start the Simulation .................................................................................... 61
Input Ports .................................................................................................... 63
From PAD window .................................................................................. 63
From file .................................................................................................. 64
Output Ports ................................................................................................. 65
Chapter 8 Using the OTP Programmer ...................................... 67
Introduction .................................................................................................. 67
Installation of the OTP Programmer .......................................................... 68
How to Program the OTP Chips .................................................................. 69
File menu ................................................................................................ 71
Command menu ..................................................................................... 71
View menu ............................................................................................... 73
Help menu ............................................................................................... 73
Programmer Stand Alone Mode .................................................................. 73
Power on or system reset state .............................................................. 74
Primary functions ................................................................................... 74
Gang Programmer ........................................................................................ 81
Part II Development Language and Tools .................. 83
Chapter 9 Holtek C Language ...................................................... 85
Introduction .................................................................................................. 85
C Program Structure .................................................................................... 86
Statements .............................................................................................. 86
Comments ............................................................................................... 86
Identifiers ..................................................................................................... 87
Reserved words ....................................................................................... 87
Data types and sizes ............................................................................... 87
Declaration .............................................................................................. 88
Constants ...................................................................................................... 89
Integer constants .................................................................................... 89
Character constants ............................................................................... 89
String constants ...................................................................................... 89
Enumeration constants .......................................................................... 89
Operators ...................................................................................................... 90
Arithmetic operators .............................................................................. 91
Relational operators ............................................................................... 91
Contents
iii

Equality operators .................................................................................. 91
Logical operators .................................................................................... 91
Bitwise operators .................................................................................... 92
Assignment operators ............................................................................ 92
Increment and decrement operators ..................................................... 92
Conditional operators ............................................................................. 93
Comma operator ..................................................................................... 93
Precedence and associativity of operators ............................................ 93
Type conversions ..................................................................................... 94
Program Control Flow .................................................................................. 95
Functions ...................................................................................................... 98
Classic form ............................................................................................ 98
Modern form ........................................................................................... 99
Pointers and Arrays ................................................................................... 100
Pointers ................................................................................................. 100
Arrays .................................................................................................... 100
Structures and Unions ............................................................................... 101
Preprocessor Directives ............................................................................. 102
Predefined names ................................................................................. 108
Holtek C Compiler Specifics ...................................................................... 108
Using multiple souce files .................................................................... 108
Input/Output ports system calls .......................................................... 109
Reset and interrupts ............................................................................ 110
Difference between Holtek C and ANSI C ................................................. 111
Keywords ................................................................................................ 111
Variables ................................................................................................. 111
Constants ............................................................................................... 111
Functions ................................................................................................ 111
Arrays ..................................................................................................... 111
Constant variables ................................................................................ 111
Initial value ........................................................................................... 112
Multiply/Divide/Modulus ..................................................................... 112
Stack ...................................................................................................... 112
Holtek C Compiler ...................................................................................... 113
Command arguments ........................................................................... 113
ASM calls C functions .......................................................................... 113
Chapter 10 Assembly Language and Cross Assembler ......... 115
Notational Conventions ............................................................................. 115
Statement Syntax ....................................................................................... 116
Name ..................................................................................................... 116
Operation .............................................................................................. 117
Operand ................................................................................................. 117
HT-IDE User’s Guide
iv

Comment ............................................................................................... 117
Assembly Directives ................................................................................... 117
Conditional-Assembly directives ......................................................... 117
File control directives ........................................................................... 118
Program directives ............................................................................... 120
Data definition directives .................................................................... 124
Macro directives ................................................................................... 125
Assembly Instructions ............................................................................... 128
Name ..................................................................................................... 128
Mnemonic .............................................................................................. 128
Operand, operator and expression ...................................................... 128
Miscellaneous ............................................................................................. 130
Forward references ............................................................................... 130
Local labels ........................................................................................... 130
Reserved assembly language words .................................................... 131
Assembler Options ..................................................................................... 132
Assembly Listing File Format ................................................................... 132
Chapter 11 Cross Linker .............................................................. 135
What the Cross Linker Does ..................................................................... 135
Cross Linker Options ................................................................................. 135
Libraries ................................................................................................ 135
Section address ..................................................................................... 136
Generate map file ................................................................................. 136
Map File ...................................................................................................... 136
HLINK Task File and Debug File ............................................................. 137
Chapter 12 Library Manager ...................................................... 139
What the Library Manager Does .............................................................. 139
To Set Up the Library Files ....................................................................... 139
Create a new library file ...................................................................... 141
Add a program module into a library file ........................................... 142
Delete a program module from a library file ...................................... 142
Extract a program module from library and create an object file .... 142
Object module information .................................................................. 142
Part III Utilities .............................................................. 143
Chapter 13 µC VROM Editor (HT-VDS827) .............................. 145
Contents
v

Introduction ................................................................................................ 145
Quick Start for µC Voice Microcontrollers ................................................ 145
Step-by-Step guide ............................................................................... 145
Resources supported by the development system .............................. 148
Quick reference ..................................................................................... 155
Using the VROM Editor ............................................................................ 157
File type ................................................................................................ 158
Creating a new .VPJ file ...................................................................... 158
Play with sample rate .......................................................................... 163
File menu .............................................................................................. 163
Window menu ....................................................................................... 164
Using the HT-Voice Editor ......................................................................... 164
New/Record command .......................................................................... 165
Play command sample rate .................................................................. 166
Open command ..................................................................................... 167
Save command Voice type .................................................................... 169
Other commands .................................................................................. 170
Using the HT-Binary Editor ...................................................................... 170
Creating a new file ............................................................................... 171
Opening a file ........................................................................................ 171
Editing ................................................................................................... 171
Saving .................................................................................................... 173
Other commands .................................................................................. 174
Chapter 14 LCD Simulator .......................................................... 175
Introduction ................................................................................................ 175
LCD Panel File ........................................................................................... 175
Relationship between the panel file and the current project ............ 176
Entry situations of the HT-LCDS ........................................................ 176
Set up the LCD Panel File ......................................................................... 177
Set the panel configurations ................................................................ 177
Select the patterns and their positions ............................................... 178
Add a new pattern ................................................................................ 179
Delete a pattern .................................................................................... 179
Change the pattern .............................................................................. 180
Change the pattern position ................................................................ 180
Simulate the LCD ...................................................................................... 180
Still in LCD simulation mode when exiting from HT-IDE ................ 180
In HT-LCDS environment .................................................................... 180
Stop the simulating .............................................................................. 181
HT-IDE User’s Guide
vi

Part IV Programs and Application Circuits ............ 183
Chapter 15 Input/Output Applications .................................... 185
Scanning Light ........................................................................................... 185
Circuit design ........................................................................................ 185
Program ................................................................................................. 186
Program description ............................................................................. 187
Traffic Light ................................................................................................ 188
Circuit design ........................................................................................ 188
Program ................................................................................................. 188
Program description ............................................................................. 191
Keyboard Scanner ...................................................................................... 192
Circuit design ........................................................................................ 192
Program ................................................................................................. 192
Program description ............................................................................. 195
LCM ............................................................................................................. 196
Circuit design ........................................................................................ 196
Program ................................................................................................. 197
Program description ............................................................................. 202
Using an I/O Port as a Serial Application ................................................ 203
Program ................................................................................................. 204
Program description ............................................................................. 207
Chapter 16 Interrupt and Timer/Counter Applications ....... 209
Electronic Piano ......................................................................................... 209
Circuit design ........................................................................................ 210
Program ................................................................................................. 210
Program description ............................................................................. 212
Clock ............................................................................................................ 212
Circuit design ........................................................................................ 213
Program ................................................................................................. 213
Program description ............................................................................. 218
Chapter 17 Parallel Port .............................................................. 219
ROM Emulator ........................................................................................... 219
Circuit design ........................................................................................ 220
Program ................................................................................................. 221
Program description ............................................................................. 223
Contents
vii

Part V Appendix .............................................................. 225
Appendix A Reserved Words Used By Assembler .................. 227
Registers ..................................................................................................... 227
Instruction Sets .......................................................................................... 227
Appendix B Cross Assembler Error Message ......................... 231
Appendix C Cross Linker Error Messages .............................. 235
Appendix D Cross Library Error Messages ............................ 241
Appendix E Holtek Cross C Compiler Error Messages ........ 243
Error Code .................................................................................................. 243
Warning Code ............................................................................................. 246
Fatal Code ................................................................................................... 248
HT-IDE User’s Guide
viii

Part I
Integrated Development
Environment
Part I Integrated Development Environment
1

HT-IDE User’s Guide
2

Chapter 1
Overview and Installation
The HT-IDE (Holtek Integrated Development Environment) is a high
performance integrated development environment designed around
Holtek’s series of 8-bit microcontroller (µC) chips. Incorporated within the
system is the hardware and software tools necessary for rapid and easy
development of ASIC (Application-Specific Integrated Circuit) applications
based on the Holtek range of 8-bit µCs.
The key component within the HT-IDE system is the HT-ICE or In-Circuit
Emulator, capable of emulating the Holtek 8-bitµC in real time, inaddition
to providing powerful debugging and trace features.
As for the software, the HT-IDE provides a friendly workbench to ease the
process of application program development, by integrating all of the
software tools, such as editor, macro assembler, linker, libraryand symbolic
debugger into a user friendly windows based environment.
In addition the HT-IDE provides a software simulator which is capable of
simulating the behaviour of Holtek’s 8-bit µC range without using the
HT-ICE. All fundamental functions of the HT-ICE hardware are valid for
the simulator.
1
Chapter 1 Overview and Installation
3

Introduction
Some of the special features provided by the HT-IDE include:
→Emulation
•Real-time program instruction emulation
•On-line or off-line (stand-alone) emulation
→Hardware
•Easy installation and usage
•Either internal or external oscillator
•Breakpoint mechanism
•Trace functions and trigger qualification supported by trace emulation
chip
•Printer port for connecting the HT-ICE to a host computer
•I/O interface card for connecting the user’s application board to the
HT-ICE
→Software
•Windows based software utilities
•Source program level debugger (symbolic debugger)
•Workbench for multiple source program files (more than one source
progam file in one application project)
•All tools areincluded for the development, debug, evaluation andgenera-
tion of the final application program code (mask ROM file)
•Library for the setting up of common procedures which can be linked at
a later date to other projects.
•Simulator can simulate and debug programs without connection to the
HT-ICE hardware
•µC VROM editor modifies and compresses the voice data in order to
generate a proper VROM (Voice ROM) size.
•LCD simulator simulates the behavior of the LCD panel.
HT-IDE User’s Guide
4

System Configuration
The HT-IDE system configuration is shown in Fig1-1, in which the host
computer is a PC/AT compatible machine, 386 or higher.
Fig 1-1
→The HT-IDE system contains the following hardware components
•The HT-ICE box contains 2 PCBs (printed circuit board) with 1 printer
port connector for connecting to the host machine, I/O signal connector
and one LED, Fig 1-2.
•I/O interface card for connecting the target board to the HT-ICE box
•Power adaptor, output 9V
•25-pin D-type printer cable
•OTP programmer, gang programmer (optional)
Fig 1-2
Chapter 1 Overview and Installation
5

→I/O interface card
The I/O interface card (Fig 1-3) is a PCB which is used to connect the
HT-IDE system to the user’s target board. It provides the following func-
tions:
•external clock source
•external signal trace input
•µC pin assignment
The external clock source has two modes, RC & crystal. For use with a
crystal clock, short positions 1 and 2 on Jumper JP1. Otherwise for an RC
clock short positions 2 and 3, and adjust the system frequency with VR1
(Fig 1-3). Refer to the Tools/Mask Option Menu for the choice of the clock
source and system frequency.
Fig 1-3
The 4 external signal trace inputs, marked as ET0 to ET3 at jumper
location JP3, exist to help the user trace and digitize signals and analyse
their behavior. Refer to the chapters on Breakpoint and Trace the Applica-
tion Program for more information.
TheµC pin assignments in location U2, U3 are defined in the same manner
as the pin assignment of the HT48CX0 series according to the Holtek 8-bit
µC databook. The VME connector at location CON1 is used to connect the
I/O interface card to the HT-ICE.
HT-IDE User’s Guide
6

Installation
System requirement
The HT-IDE system requires the host computer to have the following basic
system configuration:
•PC/AT compatible machine, 386 or higher
•VGA color monitor
•4M bytes RAM, 8M bytes recommended
•One 3.5" floppy disk drive
•Approximately 5M bytes HDD free space
•One printer port and mouse
•MS-DOS 5.0 or greater
•MS-Windows 3.1 or Windows 95
Note MS, MS-DOS are registered trademarks and Windows, Windows 95 are
trademarks of Microsoft Corporation.
If the LCD simulator or C compiler is to be used, the HT-IDE should be
installed under Windows 95.
Hardware installation
•Step 1
Plug the power adapter into the power connector of the HT-ICE
•Step 2
Connect the target board to the HT-ICE by using the I/O interface card
or flat cable
•Step 3
Connect the HT-ICE to the host machine using the printer cable
The LED on the HT-ICE should now be lit, if not there is an error and your
dealer should be contacted.
Caution Exercise care when using the power adapter. Do not use a power adapter
whose output voltage is not 9V, otherwise the HT-ICE may be damaged. It
is strongly recommended that only the power adapter supplied by Holtek
be used. First plug the power adapter tothe powerconnectorof theHT-ICE.
Chapter 1 Overview and Installation
7

Software installation
•Step 1
Insert the HT-IDE Setup diskette into the appropriate floppy drive
•Step 2
–For Windows 3.1
Run Windows and select Program Manager
Select drive A or drive B
–For Windows 95
Click “My Computer”
Double click drive A or drive B
•Step 3
Double click SETUP.EXE, the following figure (Fig 1-4) is displayed.
–Press the <Continue> button to start setting up the HT-IDE. Then go
to step 4.
–Press the <Exit> button to exit from the setup procedure. A dialog box
will request confirmation that an Exit command is the correct one.
–Press the <Help> button to get user help.
Fig 1-4
•Step 4
Type in the destination directory name for the HT-IDE files. The setup
program will copy all files into this destination directory (Fig 1-5).
–Press the <Continue> button to go to step 5.
–Press the <Back> button to go to step 3, Fig 1-4 is displayed again.
–Press the <Exit> button to exit from the setup procedure. A dialog box
will request confirmation of this command.
–Press the Help button to get user help.
HT-IDE User’s Guide
8

Fig 1-5
•Step 5
Select the appropriate parallel port, LPT1, LPT2 or LPT3, where the
HT-ICE will be connected to (Fig 1-6). Once selected, ensure that the
printer cable is connected to the corresponding port on the PC host. To
change the port after initial installation, the Debug command within the
Option menu can be used for this function, making it unnecessary to
re-install the program.
•Step 6
Thefileswillnowbecopiedfromthefloppydrivetothedestinationdirectory,
the progress of which will be displayed on a percentage indicator.
There are 4 subdirectories, BIN, INCLUDE, LIB and SAMPLE, which
are created under the destination directory during the install process. All
execution files and description files used by the HT-IDE are copied into
the subdirectory BIN. The included source files in the INCLUDE subdi-
rectory provided by Holtek, may also contain the user’s source program
files while assembling. The files in subdirectory LIB are library files
provided by Holtek, and they may be used when HLINK links all object
files into a task file. The SAMPLE subdirectory contains sample pro-
grams.
If using diskettes to setup the HT-IDE, follow the screen setup instruc-
tions to change the appropriate diskette in order to complete the Instal-
lation.
Successful completion of the setup process is indicated by the message
dialogue window shown in Fig 1-7 and the creation of an HT-IDE group.
Within this group is placed an HT-IDE icon, which can be double-clicked
to run the system.
Chapter 1 Overview and Installation
9

Fig 1-6
Fig 1-7
HT-IDE User’s Guide
10
Table of contents
Other Holtek Motherboard manuals