Page 2
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.
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 ....................
Page 4
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 ............
Page 5
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 ....................
Page 6
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 ....................
Page 7
Contents 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 ............
Page 8
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...
Page 9
Contents 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 ................
Page 10
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 ....................
Emulator, capable of emulating the Holtek 8-bit µC in real time, in addition 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, library and symbolic debugger into a user friendly windows based environment.
HT-IDE User’s Guide 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 •...
Chapter 1 Overview and Installation 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.
Page 16
→ 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 •...
• 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 •...
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 –...
Page 19
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 2 Quick Start C h a p t e r 2 Quick Start This chapter gives a quick method of using the HT-IDE to develop an application project. → Step 1 • Enter the HT-IDE For windows 3.1 C:WIN <Enter>...
Page 22
Step 5 Change the HT-IDE working mode The HT-IDE is now in the simulation mode. If the HT-ICE is connected to the host machine and powered on, the emulation mode can be selected. Otherwise, skip this Step and jump to the next step.
Page 23
Step 7 Debugging and modifying the source program files. Finally, a correct ROM file (with extension name .cod) is generated which is sent to Holtek for IC production. The µC mask option data can also be printed out. Note If the ROM file (.cod) is required, please check if the item has been selected.
C h a p t e r 3 HT-IDE Menu – File/Edit/View/Tools/Options This chapter describes some of the menus and commands of the HT-IDE. Other menus are described in the Project, Debug and Window chapters. Start the HT-IDE System • For windows 3.1 After running Windows 3.1 double click the "Holtek HT-IDE"...
Page 26
HT-ICE begins to function. Fig 3-3 • If this is the first time to enter the HT-IDE (i.e. no recorded projects) or if the last project to exit from the HT-IDE was in simulation mode, then Fig 3-4 is displayed for confirmation.
Chapter 3 HT-IDE Menu – File/Edit/View/Tools/Options A tool bar, below the menu bar (Fig 3-5), contains icons that correspond to, and assist the user with more convenient execution of frequently used menu commands. When the cursor is placed on a toolbar icon, the corre- sponding command name will be displayed alongside.
• Print Setup Print data to the printer • Recent Files List the most recently opened and closed four files • Exit Exit from HT-IDE and return to Windows Edit Menu • Undo Cancel the previous editing operation • Redo Cancel the previous Undo operation •...
Chapter 3 HT-IDE Menu – File/Edit/View/Tools/Options View Menu The View menu provides the following commands to control the window screen of the HT-IDE. (refer to Fig 3-6) • Line Move the cursor to the specified line (specified by line number) of the active file •...
Internal clock source If an internal clock source is used, the system application frequency has to be specified. The HT-IDE system will calculate a frequency which can be supported by the HT-ICE, one which will be the most approximate value to the specified system frequency.
Chapter 3 HT-IDE Menu – File/Edit/View/Tools/Options frequency along with the calculated frequency will be displayed. Confirma- tion will then be required to confirm the use of the calculated frequency or to specify another system frequency. Otherwise an external clock source is the only option.
OTP ICs. Refer to the chapter on usage of the HT48RX0 OTP programmer. The function of this command is the same as the pro- gram-item icon Prgw48 in the HT-IDE group. Library manager The Library Manager command, in Fig 3-9, supports the library functions.
Chapter 3 HT-IDE Menu – File/Edit/View/Tools/Options Chapter 12 gives more details about these functions. Fig 3-9 VROM editor The VROM, editor, in Fig 3-10 provides the following functions for µC voice • Select the voice resource files of format .WAV or .PCM •...
Project command The Project command sets the default parameters used by the Build command of the Project menu (chapter 4 HT-IDE menu - Project). During development, the project options may be changed due to the applications needs. According to the options setting, the HT-IDE will generate a proper task file for these options when issuing the Build command of the Project menu.
Page 35
Chapter 3 HT-IDE Menu – File/Edit/View/Tools/Options Note Before issuing the Build command, ensure that the project options are set correctly. Fig 3-12 Fig 3-13...
Page 36
HT-ICE. • Generate .COD file Check this box to generate the .COD file. This file will be sent to Holtek for manufacturing the masked ROM ICs, after the program emulation and debugging tasks are completed. The OTP programmer also needs this file.
HLINK is generated. Debug command This command sets the options used by the Debug menu (Chapter 5 HT-IDE menu - Debug ). The dialog box (Fig 3-14) lists all the Debug options with check boxes. By selecting the options and pressing the OK button, the Debug menu can then obtain these options during the debugging process.
Page 38
Selects the HT-IDE working mode as either simulation or emulation mode. If the HT-ICE is connected to the host machine and powered on, the HT-IDE can be selected to be either in emulation or simulation mode. Otherwise, simulation mode is the only option.
(Fig 3-15) Fig 3-15 • Executable files path The search path referred to by the HT-IDE when the executable files are called. • Include files path The search path referred to by the HASM to search for the included files.
HT-IDE User’s Guide Color command This command sets the foreground and backgroud colors for the specified line. From the available options (Fig 3-17), Text Selection is used for the Edit menu, Current line, Breakpoint Line, Trace Line and Stack Line are for the Debug menu and Error line is for the HASM output.
The HT-IDE provides an example Project, which will assist first time users in quickly familiasing themselves with project development. It should be noted that from the standpoint of the HT-IDE system, a working unit is a project with each user application described by a unique project.
Fig 4-2 Open and Close a Project The HT-IDE can work with only one project at a time, which is the opening project, at any time. If a project is to be worked upon, the project should first be opened, by using the Open command of the Project menu (Fig 4-1).
Chapter 4 HT-IDE Menu – Project Manage the Source Files of a Project Use the Edit command to add or remove source program files from the opened project. The order, from top to bottom, of each source file in the list box, is the order of the input files to the HLINK Cross Linker.
• Load the task file into the HT-ICE if it is powered-on • Display the source program of the execution entry point on the active window (the HT-IDE refers to the source files, the task file and the debugging file for emulation)
• Click either the Rebuild All command of the Project menu or the Rebuild all button on the toolbar (Fig 4-1) to start building a project Once the project task has been built successfully, emulation and debug of the application program can begin (refer to the HT-IDE menu - Debug chapter). Assemble/Compile...
If the opened file has an .asm file extension name, the HASM Cross Assembler will execute the assembly process. If the file has a .C extension then the Holtek C compiler will compile the program. If no errors are detected, an object file with extension .OBJ is generated and stored in the directory which is specified in the Output Files Path (refer to Options menu, Directories command).
(refer to the chapter on Build a project’s task files) the first execution line of the source program is displayed and highlighted in the active window (Fig 5-1). The HT-IDE is now ready to accept and execute the debug commands.
• Power-on reset (POR) by plugging in the power adapter or pressing the reset button on the HT-ICE • Reset from the target board • Software reset command in the HT-IDE Debug menu (Fig 5-2) • Software power-on reset command in the HT-IDE Debug menu (Fig 5-2) Fig 5-2...
(Fig 5-1). At this point, emulation of the application program can begin by using the HT-IDE debug commands. Note During emulation of an application program, the corresponding project has to be open.
The execution results of some instructions in the above section may be viewed and checked. It is also possible to view the execution results one instruction at a time, i.e., in a step-by-step manner. The HT-IDE provides two step modes, namely manual mode and automatic mode.
Breakpoint features The following are the main features of the HT-IDE breakpoint mechanism: • At most 3 breakpoints with equal priority can take effect at any instant • Any breakpoint will be recorded in the breakpoints list box after it is set, however this breakpoint may not be immediately effective.
Chapter 5 HT-IDE Menu – Debug • Breakpoints of address or data, in binary form with don’t-care bits, are permitted. • When an instruction is set to be an effective breakpoint, the HT-ICE will stop at this instruction, but will not execute it, i.e. this instruction will become the next one to be executed.
Page 54
HT-IDE User’s Guide • Line number with or without source file name, the format is: [source_file_name!].line_number where the source_file_name is a name of the optional source file. If there is no file name, the current active file is assumed. The exclamation point ! is necessary only when a source file name is specified.
Chapter 5 HT-IDE Menu – Debug → Format of breakpoints list box The Breakpoints list box contains all the breakpoints that have been added, including effective breakpoints and non-effective breakpoints. The Add button should be used to add new breakpoints to the list box, and the Delete button to remove breakpoints from the list box.
Page 56
HT-IDE User’s Guide → To add a breakpoint • Choose the Breakpoint command from the Debug menu (or press the hot key Ctrl+B) A breakpoint dialog box is displayed (Fig 5-3) • Designate the descriptive items of the breakpoint Set Space, Location items...
It also provides a method to record a specified count of the trace records before or after a trigger point. Note When the HT-IDE starts emulating (refer to the section on Emulation of the Application Programs), the trace mechanism will begin to record the executing instructions and relative information automatically, but not vice versa.
Page 58
HT-IDE User’s Guide The available Trace Modes are • Normal Sets the trace scope to all application programs and is the default mode. • Trace Main Sets the trace scope to all application programs except the interrupt service routine programs.
Chapter 5 HT-IDE Menu – Debug Condition A and Condition B specify the trigger conditions. The format of condition A or B is the same as that of the breakpoint. The Loop Count specifies the number of occurrences of the specified condi- tion A.
Page 60
HT-IDE User’s Guide Fig 5-4 → To set the trigger mode • Choose the Trace command from the Debug Menu A Trace dialog box is displayed as in Fig 5-4. • Choose a trigger mode from the Trigger Mode pull-down list box •...
Page 61
Chapter 5 HT-IDE Menu – Debug Fig 5-5 → To add a trace qualify condition • Choose the Trace command from the Debug Menu A Trace dialog box is displayed as in Fig 5-4 • Press the Qualify radio button •...
HT-IDE User’s Guide → To enable (disable) a trace qualify condition • Choose the Trace command from the Debug Menu A Trace dialog box is displayed as in Fig 5-4 • Choose the disabled (enabled) qualifer line to be enabled (disabled) from the Qualify list box •...
Page 63
Chapter 5 HT-IDE Menu – Debug • Sequence number (No) For any of the trigger modes, the sequence number of a trigger point is +0. The trace records before and after the trigger point are numbered using negative and positive line numbers respectively. If all the fields of the Trace Record Fields (in the Debug Option of Option menu) are selected, the result is as shown in Fig 5-6.
Page 64
HT-IDE User’s Guide Note To set the trace record fields use the Debug sub-menu of the Options menu. To view the trace record fields use Trace List command of the Window menu. → Clear the trace buffer The trace buffer can be cleared by issuing the Reset Trace command.
HT-ICE resources. These resources include program code memory (ROM), program data memory (RAM), registers, trace list, stack and output messages of some utilities within the HT-IDE. In addition to the view function, some commands such as Register, Watch and RAM, can also directly modify their contents.
:[address]= data contents Note that both address and data are displayed in hexadecimal format. The symbols and their corresponding data will be saved by the HT-IDE and displayed the next time the Watch command is used. The symbols can be deleted from the Watch window by pressing the delete key.
Page 67
Chapter 6 HT-IDE Menu – Window • RAM This command displays the contents of the program data memory space, i.e. the RAM. The register area of the RAM is not included, as these are displayed by using the Register command. These contents may be directly modified for debugging purpose.
Page 68
HT-IDE User’s Guide • Stack This command displays the contents of the stack buffer. (Fig 6-4) The maximum stack level of the µC for the current project is displayed on this window (in Fig 6-4, the maximum stack level of HT48100 is 2). The growth of the stack is numbered from 0.
µC. The output is not in hexadecimal format but rather disassembled instructions. After the Build command of the Project menu is issued, and if the HT-IDE finds the occurrence of one of the following two situations, the disassembled instructions of the ROM code in the Program window will be displayed.
In the latter case, the working mode is in simulation. Even if the working mode of a project is in emulation, it can be changed to be in simulation. Also, the working mode of the HT-IDE is in simulation when the following situations occur.
Page 72
HT-IDE User’s Guide Fig 7-1 When changing the working mode to simulation, the button [Sim. Option] at the right side is also enabled. The function of this button is to set the simulation options which will direct the simulation how to obtain the input port signals and how to display the port output signals.
(refer to chapter 5, Fig 5-3) and the Trace command in the Debug menu (refer to chapter 5, Fig 5-5) are invalid while in simulation. Input Ports In the HT-IDE simulator, two methods for port input are provided. One is From the PAD window, the other is From file. From PAD window Fig 7-3 shows the Sim.
HT-IDE User’s Guide From file Another method is to set the input signal levels in a file, known as the signal file. The simulator will obtain an input signal level one by one from the signal file when it executes a read from port instruction. For each port set to be an input type, there are at the most 1024 input signal levels.
Chapter 7 Simulation Output Ports The output signals of a port can be viewed by issuing the Sim. Result command in the Window menu. Fig 7-4 displays the output/input signal of all ports if the ports are of output/input type. Each line denotes a record and consists of the following items.
Introduction The OTP (One Time Programmable) programmer is a programming tool designed for the Holtek 8-bit OTP chips. The programmer can operate in either on-line or in stand alone mode. The connection between the PC host and the OTP programmer should first be setup in the on-line mode. In the on-line mode the Windows based software utility within the HT-IDE is necessary for control of the OTP programmer.
PC ports. • A standard RS232 cable with 25 pin connector for communication be- tween the PC and the OTP programmer • The PRGW48 software utility, contained within the HT-IDE, to control the OTP programmer Installation of the OTP Programmer •...
If the .COD file is found to be not the most recent one, the OTP programmer command stops the programming jobs and exits to the HT-IDE. In such a situation, a new .COD file should be generated by selecting the Mask Option command in the Tools menu and then the Build...
Page 80
HT-IDE User’s Guide When double-clicking the Prgw48 icon in the HT-IDE group, Fig 8-2 is displayed. This window is divided into: • The menubar, consisting of four menus, File, Command, View and Help • The toolbar, containing only one tool: the Open command of the File menu •...
OTP chip or loaded from the .COD file using a Read command. → Exit Exit from the OTP utility and return to the HT-IDE. Command menu The command menu consists of the commands that control the OTP pro- grammer. Fig. 8-3 displays the commands of the command menu.
Page 82
HT-IDE User’s Guide → Connect Connect the OTP programmer to the PC host through the serial port. The serial port name is displayed on the status bar if the connection is successful. → Download Download the contents of the PC buffer to the buffer in the OTP programmer.
Chapter 8 Using the OTP Programmer → Fuse Blow out the security bit. This command protects the OTP chip from reading. View menu The View menu consists of the following commands (Fig 8-4) Fig 8-4 • Option Display the options data of the opened file or the OTP chip •...
HT-IDE User’s Guide There are four function keys in the OTP programmer which can be used in the stand alone mode. In addition, there are three states, Power on, System reset and Primary function state. The four functions, Program, Read, Verify and Blank Check are supported in the Primary function state with some Primary functions having subfunctions.
Page 85
Chapter 8 Using the OTP Programmer → Primary function - Program When entering this function, the following two subfunctions are displayed for selection. • Subfunction 1 LCM display – FUSE IT: NO YES Valid keys – a) ESC: return to the previous state; Primary function state b) Arrow keys: select NO or YES c) ENT: enter the next subfunction, subfunction 2, of the Program function...
Page 86
HT-IDE User’s Guide • Status 2 LCM display – PRG: PASS (or PRG:FAIL) Valid keys – ENT: program the next OTP chip Description – The message “PRG:PASS” is displayed if the OTP chip has been pro- grammed successfully. The message “PRG:FAIL” is displayed if the OTP chip is unable to be written to, due to some internal fault inside the OTP chip.
Page 87
Chapter 8 Using the OTP Programmer • Status 6 LCM display – CHIP MISMATCHED Valid keys – ESC: return to the Primary function state ENT: program the next OTP chip Description – This message warns that the OTP chip in the TEXTOOL is of a different type from the programmed data file.
Page 88
HT-IDE User’s Guide • Status 3 LCM display – CHIP IS LOCKED Valid keys – ESC: return to the Primary function state ENT: read from the next OTP chip Description – This message warns that the OTP chip in the textool has already been protected.
Page 89
Chapter 8 Using the OTP Programmer • Status 2 LCM display – VER: PASS (or VER: FAIL) Valid keys – ESC: return to the Primary function state ENT: verify the next OTP chip Description – The message “VER: PASS” is displayed if the data in the OTP chip is the same as that in the programmer buffer.
Page 90
HT-IDE User’s Guide • Status 6 LCM display – CHIP MISMATCHED Valid keys – ESC: return to the Primary function state ENT: verify the next OTP chip Description – This message warns that the OTP chip in the textool is of a different type from the programmed data file.
OTP chip, which should be placed in the TEXTOOL of the OTP program- mer. The other is from the PC file, using the HT-IDE or PRGW48 utility. In the latter method, the Exit command in the File menu must be executed after the PC source file has been read.
Holtek C Language Introduction The Holtek C compiler is based on ANSI C. Due to the architecture of the Holtek microcomputer, only a subset of ANSI C is supported. This chapter describes the C programming language supported by the Holtek C compiler.
One line can contain more than one statement. Compound statements are one or more statements contained within a pair of braces and can be used as a single statement. Some statements and preprocessor directives are required in the Holtek C source files. The following is a shell: void main() /* user application source code */ The main function is defined within the user application source code.
• Only the first 31 characters are significant • Upper case and lower case letters are different • Reserved words cannot be used Reserved words The following are the reserved words supported by the Holtek C complier. They must be in lower case. auto bits...
HT-IDE User’s Guide The following are the data types, sizes and range Data Type Size (bits) Range char –128~127 unsigned char 0~255 –128~127 unsigned 0~255 short int –128~127 unsigned short int 0~255 long –32768~32767 unsigned long 0~65535 Declaration Variables must be declared before being used as this defines the data type and the size of the variable.
The memory location must be in the general purpose data memory. The offset of it starts from 0×20. All variables implemented by the Holtek C compiler are static unless they are declared as external variables. Note that both static and external variables will not be initialized to zero by default.
These values are limited within the range 0 to 255. Although variables of the enum type may be declared, the Holtek C compiler will not check whether what was stored in such a variable is a valid value for the enumeration.
Chapter 9 Holtek C Language Arithmetic operators There are five arithmetic operators, addition – subtraction multiplication division modulus (the remainder of division, always positive or zero) The modulus operator %, can only be used with integral data types. Relational operators The relational operators compare two values and return either a TRUE or FALSE result based on the comparison.
HT-IDE User’s Guide Bitwise operators There are six operators for manipulating bit-by-bit operations. The shift operators >> and << perform the right and left shifts of the left operand by the number of bit positions given by the right operand, which must be positive.
Chapter 9 Holtek C Language Conditional operators The conditional operator ?: is a shortcut for executing a statement between two selectable statements according to the result of the expression. <expr> ? <statement1> : <statement2> If <expr> evaluates to a nonzero value, <statement1> is executed. Other- wise, <satement2>...
HT-IDE User’s Guide Operators Description Associativity add (binary) left to right – subtract (binary) << shift left left to right >> shift right < less than left to right <= less than or equal to > greater than >= greater than or equal to...
Chapter 9 Holtek C Language Program Control Flow The statements in this section are used to control the flow of execution in a program. The use of relational and logical operators with these control statements and how to execute loops are also described.
Page 106
HT-IDE User’s Guide • Example for (i=0;i<10;i++) a[i]=b[i]; // copy elements from an array to another array → while statement • Syntax ( condition-expression ) while statement ; • Description The while statement is another kind of loop. When the condition-ex- pression is nonzero, the while loop executes a statement or block of statements.
Page 107
Chapter 9 Holtek C Language The continue statement orders the program to skip to the end of the loop and begins the next iteration of the loop. In the while and do-while loops, the continue statement forces the condition-expression to be executed imme- diately.
HT-IDE User’s Guide The switch variable is tested against a list of constants. When a match is found, the statements with that constant are executed until a break statement is encountered. If no break statement exists, execution flows through the rest of the statements until the end of the switch routine. If no match is found, the statements associated with the default case are executed.
Chapter 9 Holtek C Language Modern form return-type function-name ( var-type arg1 , var-type arg2 , ...) In both forms, the return-type is the data type of the function returned value. If functions do not return values, then return-type must be declared as void.
HT-IDE User’s Guide therefore no value should be in the return statement. When a return statement is encountered, the function returns immediately to the calling routine. Any statements after the return statement are not executed. Pointers and Arrays Pointers A pointer is a variable that contains the address of another variable. For example, if a pointer variable, namely varpoint, contains the address of a variable var, then varpoint points to var.
Chapter 9 Holtek C Language Structures and Unions → Structures • Syntax struct-name struct data-type member1 ; data-type member2 ; data-type membern ; } [ variable-list ]; • Description A structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling.
HT-IDE User’s Guide → Unions union-name union data-type member1 ; data-type member2 ; data-type memberm ; } [ variable-list ]; • Description Unions are a group of variables of differing types that share the same memory space. A union is similar to a structure, but its memory usage is very different.
Page 113
Chapter 9 Holtek C Language • Description The #define directive defines string constants that are substituted into a source line before the source line is evaluated. The main purpose is to improve source code readability and maintainability. If the replaced-text requires more than one line, the backslash (\) is used to indicate multiple lines.
Page 114
HT-IDE User’s Guide → Conditional inclusion : #ifdef • Syntax symbol #ifdef source codes #else source codes ] endif • Description The #ifdef directive is similar to the #if directive, except that instead of evaluating the expression, it checks if the specified symbol has been defined or not.
Page 115
Chapter 9 Holtek C Language → Conditional inclusion: #elif • Syntax expression1 source codes expression2 #elif source codes #else source codes ] #endif • Description The #elif directive is accompanied with the #if directive. It provides other compilation conditions in addition to the usual two. If the expression1 is nonzero, then the source code that exists below the #if statement will be compiled.
Page 116
HT-IDE User’s Guide • Example #if defined DEBUG_MODE #define TOTAL_COUNT 50 #endif → #undef • Syntax symbol #undef • Description The #undef directive causes the symbol’s preprocessor definition to be erased. Once defined, a preprocessor symbol remains defined and in scope until the end of the compilation unit or until it is undefined using an #undef directive.
Page 117
Chapter 9 Holtek C Language • Description The #asm and #endasm are the inline assembly preprocessor directives. The #asm directive inserts Holtek’s assembly instruction(s) after this directive (or within the directive #asm and directive #endasm) into the output file directly.
The Holtek C compiler supports multiple source files with only one source file containing the main() routine. C source files may be compiled one by one and all the object files linked to an execution file. The Holtek C compiler can compile all source files and link them all together.
Chapter 9 Holtek C Language Input/Output ports system calls The Holtek C language provides the following system calls for accessing the input/output ports. These system calls are implemented without ’call’ in- structions to reduce the number of stacks used. →...
//clear bit 4 of port C control register Reset and interrupts The Holtek C language provides a means for implementing reset and interrupts vectors through the preprocessor directive #pragma. The direc- tive #pragma vector is used to declare the name and address of the reset and other interrupt vectors.
@ 0 25; /* declare the flag in the offset 0x25 of RAM */ Constants Holtek C supports binary constants. Any string that begins with 0b or 0B will be treadted as a binary constant. For example: 0b101= 5 0b1110= 14 Functions Avoid using reentrant and recursive code.
[project...], put the library name in the [libraries] field. Stack Because the Holtek HT48CX0 microcontrollers have from 2 to 8 stacks the programmer needs to consider the function call depth to avoid stack over- flow. The multiply, divide and modulus of the Holtek C language are implemented by "call"...
Holtek C Compiler Command arguments The following are the arguments of the Holtek C compiler. These argu- ments are generated and passed to the compiler by the HT-IDE according to the project environment. • /? or /h These arguments display the help messages on the screen.
Page 124
HT-IDE User’s Guide • Example 1: void maxmin (long val) _maxmin ← the function name maxmin0 ← the name of val argment Assume we want to call maxmin (10) extern _maxmin: near extern maxmin0: byte ; it is ok to declare “byte” although ;...
Cross Assembler Assembly-Language programs are written as source files. They can be assembled into object files by the Holtek Cross Assembler (HASM). Object files are combined by the Cross Linker (HLINK) to generate a task file. A source program is made up of statements, giving directions to the assembler at assembly time or to the processor at run time.
HT-IDE User’s Guide Example of convention Description of convention Braces and vertical bars stand for a choice between two or more items. Braces enclose the {choice1 | choice2} choices whereas vertical bars separate the choices. Only one item can be chosen.
Chapter 10 Assembly Language and Cross Assembler Operation The operation defines the statement action of which two types exist, directives and instructions. Directives give directions to the assembler, specifying the manner in which the assembler is to generate the object code at assembly time.
HT-IDE User’s Guide • Example IF debugcase ACC1 equ 5 extern username: byte ENDIF In this example, the value of the variable ACC1 is set to 5 and the username is declared as an external variable if the symbol debugcase is evaluated as true i.e.
Page 129
Chapter 10 Assembly Language and Cross Assembler → Syntax size PAGE • Description This directive specifies the number of the lines of the program listing file. The page size must be within the range from 10 to 255, the default page size is 60.
HT-IDE User’s Guide → Syntax ’text-string’ MESSAGE • Description The directive MESSAGE directs the assembler to display the text-string on the screen. The characters in the text-string must be enclosed by a pair of single quotation marks. Program directives →...
Page 131
Chapter 10 Assembly Language and Cross Assembler For the CODE section, the byte address is in a one instruction unit (14 bits for HT48100). BYTE aligns the section at any instruction address, WORD aligns the section at any even instruction address, PARA aligns the section at any instruction address which is a multiple of 16, and PAGE aligns the section at any instruction address with a multiple of 256.
Page 132
HT-IDE User’s Guide → Syntax banknum section-name [, section-name ,...] ROMBANK • Description This directive declares which sections are allocated to the specified ROM bank. The banknum specifies the ROM bank, ranging from 0 to the maximum bank number of the destination microcontroller, according to the directive .CHIP.
Page 133
Chapter 10 Assembly Language and Cross Assembler • Example PUBLIC start, setflag EXTERN tmpbuf:byte CODE .SECTION ’CODE’ start: mov a, 55h call setflag ..setflag proc mov tmpbuf, a setflag endp In this example, both the label ’start’ and the procedure ’setflag’ are declared as public variables.
HT-IDE User’s Guide • Example table1: DC 0128h, 025CH In this example, the HASM reserves two units of ROM space and also stores 0128H and 025CH into these two ROM units. Data definition directives An assembly language program consists of one or more statements and comments.
Chapter 10 Assembly Language and Cross Assembler In this example, the HASM reserves byte location 0 for tbuf, location 1 for chksum, bit 0 of location 3 for flag1, location 4 for sbuf and bit 1 of location 3 for cflag. →...
Page 136
HT-IDE User’s Guide The LOCAL directive defines symbols available only in the defined macro. The dummy-name is a temporary name that is replaced by an unique name when the macro is expanded. The HASM creates a new actual name for dummy-name each time the macro is expanded.
Page 137
17, is 0000. Line 24 is expanded to 11 lines and forms the macro body. In addition the formal parameters, tmp1 and tmp2, are replaced with the actual parameters, BCnt and SCnt, respectively. File: t.asm Holtek Cross-Assembler Version 2.10 Page 1 0000 ;...
HT-IDE User’s Guide 24 0007 1780 R1 sdz BCnt 24 0008 2802 1 jmp ??0000 25 0009 0 Errors Assembly Instructions The syntax of an instruction has the following form: [name:] Mnemonic [operand1[,operand2]] [;comment] where → label name name: → instruction name (keywords) Mnemonic →...
Page 139
Chapter 10 Assembly Language and Cross Assembler assembly time. They can contain constants, symbols, or any combination of constants and symbols that are separated by arithmetic operators. Operators specify the operations to be performed while combining the operands of an expression. The assembler provides many operators to combine and evaluate operands.
HT-IDE User’s Guide the LOW/HIGH operator will take the values of the low/high byte of the program count of this label. • Operator precedence Precedence Operators 1 (Highest) ( ), [] +, – (unary), LOW, MID, HIGH, OFFSET *, /, %, SHL, SHR +, –...
Chapter 10 Assembly Language and Cross Assembler ;; local labe jmp Label1 jmp $0 Label3: Reserved assembly language words The following table lists all reserved words used by the assembly language. • Reserved Names (directives, operators) DBIT .NOLISTMACRO IFNDEF ELSE INCLUDE OFFSET .LIST...
HT-IDE User’s Guide Assembler Options The HASM options can be set via the Options menu Project command. The Assembler Options is located on the center part of the Project Option dialog box, as shown in Fig 3-13. The symbols could be defined in the define symbol edit box. The syntax is symbol1[=value1] [, symbol2[=value2] [, ...]]...
Page 143
If any errors occur during assembly, each error message and error number will appear directly below the statement where the error occurred. → Example of assembly listing file File: sample.asm Holtek Cross-Assembler Version 2.04 Page 1 0000 .chip ht48100 2 0000...
Finally, the HLINK copies both the program codes and other information to the task file. It is this task file that is loaded by the HT-IDE Holtek Integrated Development Environment, into the Holtek HT-ICE In-Circuit Emulator, for debugging.
The contents of the map file are as follows. Holtek (R) Cross Linker Version 3.20 Copyright (C) HOLTEK Microelectronics INC. 1997-1998. All rights reserved. Input Object File: C:\SAMPLE\T2.OBJ Input Object File: C:\SAMPLE\T1.OBJ...
HT-IDE debugging program. This information includes source file names, symbol names and line num- ber as defined in the source files. The HT-IDE will refer to the symbolic debugging function information. This file should not be deleted unless the debugging procedure is completed, otherwise the HT-IDE will be unable to support the symbolic debugging function.
Chapter 12 Library Manager C h a p t e r 1 2 Library Manager What the Library Manager Does The Library Manager HLIBW, provides functions to process the library files. The library files are utilized in the creation of the output file by the Cross Linker.
Chapter 12 Library Manager Create a new library file Press Open button, Fig 12-3 is displayed Type in a new library file name and press the OK button, Fig 12-4 is displayed for confirmation. If the Yes button is chosen, a new library file will be created but will not contain any program modules.
HT-IDE User’s Guide Add a program module into a library file Select an object module from the “Object in Directory” box, and press the [ADD] button to add this object module into this library file. Delete a program module from a library file Select an object module from the “Object In Library”...
Part III Utilities P a r t I I I Utilities To assist in understanding the general concepts of microcontroller circuit and program design some examples are provided here for consultation. Working carefully through the examples, simultaneously looking at both the code and the explanation should give a good introduction to some useful microcontroller programming techniques.
Introduction The HT827XX series of processors are 8-bit high performance microcontrollers with voice synthesizers and tone generators. Holtek provides a HT-VDS827 utility software package that compresses speech source files, with formats such as .WAV, .PCM or ADPCM files, in order to save voice ROM space. An uncompressed binary file can also be loaded as an LCD pattern file.
Page 156
• For Windows 3.1 C:win <Enter> – Double click the icon "Holtek HT-IDE" – Double click the icon ’HT-IDE,’ the HT-IDE environment is displayed – Press the [OK] button when the dialog box "Simulator is connected" is – displayed • For Windows 95 Click the Start button, select Programs, then select Holtek HT-IDE –...
Page 157
• Double click the file ’t.asm’ created on the previous step. → Step 7 Change the HT-IDE working mode. The HT-IDE shall be working in emulation mode. • Select the Options menu, Debug command • Click the Emulation radio button in the Mode box →...
HT-IDE User’s Guide The program code has now been downloaded into the HT-IDE and the voice ROM is ready. The program can now be executed. The first track added into the voice ROM can now be heard. It is now replayed by the µC Voice System.
Page 159
Chapter 13 µ C VROM Editor (HT-VDS827) Resources Used Maximum Possible Decompression Sampling Combined ROM, ROM, last Algorithm Rate Algorithms total page ADPCM3, 3-bit ADPCM 8.0kHz PCM6, PCM8 3-bit ADPCM, ADPCM3, 11.0kHz QUICK PCM6, PCM8 ADPCM4, 4-bit ADPCM 7.5kHz PCM6, PCM8 4-bit ADPCM, ADPCM4, 11.0kHz...
Page 160
HT-IDE User’s Guide AdpcmISR ; 8 Specify ISR begin: speech 0, 12H, 1 ; 10 [22H] ; 11 Turn on the volume ; 12 ; 13 The file ’voice.inc’ is included at line 3 and the ISR is specified at line 8. The symbol AdpcmISR is predefined in the file ’voice.inc.’...
Page 161
Note applications should be designed by following the same style as mentioned in the HT-IDE User’s Guide. This relocatable style programming is based on the section concept. Trying to specify the absolute address without following this style might result in a RAM conflict and cause run-time errors.
Page 162
HT-IDE User’s Guide • The speech macro Generally, the speech macro is used to play edited sound tracks. It is defined in the included file, "voice.inc." The syntax of the speech is ... speech TrackNumber, SamplingRate, VoiceDown where, TrackNumber is the number of the sound edited, beginning with 0. Refer to the .NUM file for a listing of all voice resources.
Page 163
Chapter 13 µ C VROM Editor (HT-VDS827) ..speech 1, ,1 ..The parameter VoiceDown could also be left empty. If it is non-empty, no matter what symbol it has, the voice down mode is enabled. Otherwise, if it is left empty, the voice down mode is disabled. Enabling the voice down mode will cause the register DAH and DAL to be set to zero and thus reduce power consumption after the sound track is performed.
Page 164
HT-IDE User’s Guide • The pause flag The pause flag is a one-bit flag used to pause the playing. If it is set, the performance is stopped temporarily until it is reset. The following pro- gram use port A bit 0 to toggle pause mode when playing.
Chapter 13 µ C VROM Editor (HT-VDS827) ; Example of stop playing by setting the stop flag ; In this example, bit 0 of port A is configured as input,pull- ; high and a switch button is connected between pa.0 and VSS. pa equ [12h] acc equ...
Page 166
HT-IDE User’s Guide • Pause A one-bit flag used to pause playing. Usage, pause pause pause pause For example, to pause play until bit 0 of port A is turned low ... pause pa.0 waiting pause ..• Speech A macro used to play the sound tracks.
Chapter 13 µ C VROM Editor (HT-VDS827) • Stop A one bit flag used to stop playing. Usage, stop stop stop stop For example, to stop playing when bit 0 of port A is low ... Waiting: pa.0 waiting stop ..
VPJ project file, which contains the voice source file and other informa- tion. • VOC file is for downloading, which must be returned to Holtek. • NUM text file, which contains the starting address of the voice file and the compression method used. This file can be used for error checking.
Page 169
Chapter 13 µ C VROM Editor (HT-VDS827) If none of the body types meet the requirements, select Ext. VROM com- mand from the Body Type Selection Box, and fill the desired VROM size in the dialog box as shown below. →...
Page 170
HT-IDE User’s Guide → Step 4 Different settings of silence tolerance and length of silence lead to different compression results. Changing the length of silence and the silence toler- ance changes the compressed file length and the free ROM size, because silence has a concise compression format.
Page 171
Chapter 13 µ C VROM Editor (HT-VDS827) → Step 5 Select the working drive and directory from the right sub-window of the main window, then choose the file type of the source voice code. Three kinds of Voice files are supported: wave file (*.WAV) 16-bit PCM files (*.PCM) 8-bit PCM files (*.PCM)
Page 172
HT-IDE User’s Guide → Step 9 A voice or a data file may be edited by selecting the desired file first, and then pressing the button . The HT-VDS827 will auto-detect the file type and open the files with either the HT-Voice Editor or the HT-Binary Editor.
Chapter 13 µ C VROM Editor (HT-VDS827) Play with sample rate HT-VDS827 compression tool also provides an on-line play function if a sound card is installed. To listen to the sound of the compressed voice file, select a compressed file in the sound list box and press the button Press the button to stop.
HT-IDE User’s Guide → Print... Print the result including the file name, the starting address, and the compression methods used. Window menu The Window menu consists of Tile, Cascade, Arrange Icons, and Close All commands. → Tile Tile all opened files on the screen.
Chapter 13 µ C VROM Editor (HT-VDS827) New/Record command → Step 1 To create a new voice file, select the New command from the File menu. → Step 2 To record, select the Record command from the Function menu, or press the button (if a sound card and microphone are installed), a Record Function Dialog screen appears: Fill out the dialog box: File Name, Sample Rate, and other options.
HT-IDE User’s Guide Play command sample rate → Step 1 Before playing, it is necessary to record or open a file. Select the Play command in the Function menu, or press the button to listen to the recorded sound. Press the button to stop.
Chapter 13 µ C VROM Editor (HT-VDS827) Open command → Step 1 To open a voice file, select the Open command in the File menu. → Step 2 - Cut/Copy/Paste Select a range first, and then cut/copy the range by selecting the cut/copy command from the Edit menu, or press the button.
Page 178
HT-IDE User’s Guide ReSample will add/delete data points to suit the sampling rate we type in. If you decrease the sampling rate, the timbre will not as good as original voice, but the file size will be decreased. → Step 5 - Change Format...
Chapter 13 µ C VROM Editor (HT-VDS827) → Step 7 - Amplify Mark a range first or choose the Amplify command from the Edit menu and define the range in the Amplify Dialog window, and then type in the magnitude desired for the selected range to be amplified. →...
HT-IDE User’s Guide Type in the full path, file name, and file type: Wave Files .WAV or PCM File .PCM. Other commands → Short Menu or Full Menu/File Short menu / Full menu switch command. → Exit/File Close the application.
Chapter 13 µ C VROM Editor (HT-VDS827) Creating a new file To create a new file, select the New command from the File menu, or press button. Then begin to input data (Hex) in the editing area. Opening a file To open a file, select the Open command from the File menu, or press the button.
Page 182
HT-IDE User’s Guide → Fill To fill a range with data (in Hex), select the Fill command in the Edit menu, or press the button. A Fill dialogue box appears: Type in the Start Address, End Address and data in Hex, and then press the Ok button.
Chapter 13 µ C VROM Editor (HT-VDS827) Saving → Save To save a file, select the Save command from the File menu, or press the button. A Save File dialogue box appears. If the file name is not specified, a Save As.. dialogue box will appear. Type in the Start Address and End Address to be saved and then press the Ok button.
HT-IDE User’s Guide Other commands → Short Menu or Full Menu/File Short menu / Full menu switch command. → Exit/File Close the system. → About HT-Binary Editor*/File Show information about the system. → Tile or Arrange/Window Tile (called Arrange in short menu) all opened files on the screen.
Chapter 14 LCD Simulator C h a p t e r 1 4 LCD Simulator Introduction The LCD simulator HT-LCDS provides a mechanism to simulate the output of the LCD driver. According to the designed patterns and the control programs, the HT-LCDS displays the patterns on the screen in real time. It facilitates the development process even if the required LCD panel is unavailable.
If the HT-LCDS was in simulation mode while exiting the previous time from the HT-IDE, the HT-LCDS will be automatically invoked in simula- tion mode the next time the HT-IDE is used. In this situation, the HT-LCDS refers to the panel file with the same name as the project name.
Chapter 14 LCD Simulator Fig 14-3 Set up the LCD Panel File The following two steps are used to setup a panel file: • Set the panel configurations. This data includes the segment and common number of the LCD driver as well as the width and height size of the panel in pixels.
HT-IDE User’s Guide The panel configuration items are: • µC controller. Selects the micro controller of the current project. • COM and SEG. Select the number of the COMMON and SEGMENT of the LCD driver respectively. The default number of the LCD driver for this micro controller is displayed.
Chapter 14 LCD Simulator The following are the methods used to add/delete/modify the patterns and their positions: Add a new pattern • Select the COM/SEG position on the grid as in Fig 14-2 and double click the mouse. The Pattern Information dialog box, in Fig 14-6, is displayed. All the bitmap files in the project’s directory are listed in the Pattern List box.
If the HT-LCDS was in simulation mode the last time the HT-IDE was exited, it will return to this mode the next time HT-IDE is run. The HT-LCDS will reference the panel file with the same name as the project name.
Chapter 14 LCD Simulator When the HT-LCDS begins simulation, Fig 14-7 is displayed and the most recent LCD datum displayed on the panel screen. Stop the simulating Click the X box on Fig 14-7, to stop the HT-LCDS simulation and exit. Fig 14-7...
Part IV Programs and Application Circuits P a r t I V Programs and Application Circuits To assist in understanding the general concepts of microcontroller circuit and program design some examples are provided here for consultation. Working carefully through the examples, simultaneously looking at both the code and the explanation should give a good introduction to some useful microcontroller programming techniques.
Chapter 15 Input/Output Applications C h a p t e r 1 5 Input/Output Applications Using the HT48CX0 series of microcontrollers for I/O applications is very simple using the port I/O registers to control the input/output data. The possibility of single bit manipulation further enhances control of input and output data giving increased flexibility.
Chapter 15 Input/Output Applications call delay ;(3) ;delay for a while ;;shift lamp state left through lamp ;(4) ;;carry flag (fill LSB 1) ;if all LEDs have been lit? llamp ;(5) ;;no. continue shift left loop lamp ;(6) ;;yes. restore lamp state rlamp: ;shift lamp right loop a,lamp...
HT-IDE User’s Guide Traffic Light This application uses red, green and yellow LEDs to simulate a crossroads traffic light function. Initially R1 and G2 are illuminated. After a delay the green light flashes followed by the yellow light. After another delay R2 and G1 are illuminated.
Page 199
Chapter 15 Input/Output Applications ;timer/event 0 interrupt subroutine reti ;for safeguard ;timer/event 1 interrupt subroutine reti ;for safeguard start: intc ;initialize registers tmrc ;to guarantee performance ;(interrupts) ;(ports) ;(input mode) main: ;(1) pac,a ;set port A to output port pa,a ;zero port A (all light on) loop: ;light loop...
Page 200
HT-IDE User’s Guide tabrdl rglight ;load light state a,rglight ;;output light state to port A pa,a call delays ;delay for a ’little’ while tblp flash ;if flash light over? flash2 ;no. flash again tabrdl rglight ;(yes. go ahead) load light state a,rglight ;;output light state to port A...
Chapter 15 Input/Output Applications delays endp 300h ;TABLE ; RYG 0EBh ;1110 1011 G R 0FBh ;1111 1011 O R 0EBh ;1110 1011 G R 0FBh ;1111 1011 O R 0EBh ;1110 1011 G R 0FBh ;1111 1011 O R 0EBh ;1110 1011 G R 0FBh...
HT-IDE User’s Guide Keyboard Scanner This unit uses a 4×4 keyboard matrix, giving a total of 16 keys with each key representing a single hexadecimal value as shown in the diagram. The microcontroller program scans the keyboard matrix to detect which key was pressed and after detection displays on the LED display the corre- sponding hex code.
Page 203
Chapter 15 Input/Output Applications count1 db ? ;delay loop counter mask db ? ;mask register matrix db ? ;key matrix register ;------------------------------------------------------------ code .section at 0 ’code’ ;== program section == start ;external interrupt subroutine reti ;for safeguard ;timer/event 0 interrupt subroutine reti ;for safeguard ;timer/event 1 interrupt subroutine...
Page 204
HT-IDE User’s Guide get_key ;yes. get input info a,0f7h ;(2) ;no. scan fourth row matrix,a ;hold scan code pac,a ;output pa.3 0 (latch) a,pa ;read input state ;;complement input state a,0f0h ;if any input? get_key ;yes. get input info keyloop ;repeat from keyloop...
HT-IDE User’s Guide rows and then at the columns and making the appropriate steps through the table values. In section (10) the table read instruction is used to determine the displayed value of the individual key, which is then placed on Port B which illuminates the corresponding LEDs.
HT-IDE User’s Guide LCM_CTRL.E ;low (trigger) endif ;== delay == delay: ;=delay for a while= dtmp,a drep: dtmp2 ;count down dtmp2 drep dtmp ;count down dtmp drep end ;module Program description The program begins by calling in include files and by defining the LCM to be on Port B.
Below are the steps taken and other points to be noted. • Create a new file called DFSERIPT.INC in the directory \HT-IDE\IN- CLUDE\Here must be included ... Baudrateconst XXX. This value XXX can be taken from a table or –...
Page 216
HT-IDE User’s Guide baudrate equ baudrateconst ;replace baudrate with baudrateconst txpin ;replace txpin with tx rxpin ;replace rxpin with rx sdata .section ’data’ count db ? ;serial bit counter txreg db ? ;transmit data register rcreg db ? ;receive data register...
When the interrupt function ends the code returns to running the main program. The Holtek HT48X00 microcontroller series timer/counter possess either 16 bit or 8 bit counters. All are count up types. The values are first converted into 2’s complement and then the 16 or 8 bit value loaded into the...
HT-IDE User’s Guide thus generate the required frequency on a corresponding pin and create the desired note. By adding a suitable amplifier and speaker the system is complete. The important points of the software is to use the timer/counter as a counter to control the output frequency. This frequency has to be calculated.
Page 221
Chapter 16 Interrupt and timer applications ;timer/event 0 interrupt subroutine ;(6) ;generate square wave reti ;end timer0 ISR ;timer/event 1 interrupt subroutine reti ;for safeguard start: intc ;initialize registers tmr0c ;to guarantee performance tmr0h ;(interrupts) tmr0l tmr1c tmr1 ;(ports) ;(input mode) main: ;(1) ;set port A to input port...
Chapter 16 Interrupt and timer applications This application depends upon the system clock frequency as a basis for its timing. The application shown here uses a 400kHz system clock which will generate a 100kHz timer/counter clock due to the internal divide by four operation.
Page 224
HT-IDE User’s Guide second db ? ;hold second minl db ? ;hold minute low byte minh db ? ;hold minute high byte hourl db ? ;hold hour low byte hourh db ? ;hold hour high byte count1 db ? ;delay counter...
Page 225
Chapter 16 Interrupt and timer applications tmr0h,a ;(high byte) tmr0c.4 ;start timer0 loop: ;(3) ;zero table index tblp,a a,minl ;load display data disp,a ;(’low’ minute) call show_clock ;show displaying up (4th 7-segment) tblp a,minh ;load displaying data disp,a ;(’high’ minute) call show_clock ;show displaying up (3rd 7-segment)
HT-IDE User’s Guide minl ;minl+1 a,minl a,0ah ;if over 10 minutes? ;no. return minl ;yes. minl=0 minh minh=0 a,minh a,06h ;if over 60 minutes? ;no. return minh ;yes. minh=0 (don’t care hour) ;return inc_min endp Program description The program begins (1) by defining A as outputs, achieved by setting the control register PAC to 00.
Chapter 17 Parallel Port C h a p t e r 1 7 Parallel Port This section describes a parallel port application. The speed of parallel ports is higher than serial ports as there are more lines involved in the data transfer.
HT-IDE User’s Guide Circuit design I/O lines PA0~PA7, PB0~PB7 and PC0~PC3 are defined as outputs. Port A is defined as the low order bits while Port B is defined as the high order bits. Port C is for the control lines. To use in a practical application it is necessary to connect both the address and data lines of the SRAM to the ROM socket of the application.
Chapter 17 Parallel Port The program has to follow the parallel port conventions and timing dia- gram. For this reason the timing specification of the PC printer port can be consulted to achieve the correct operation. Program #include ht48300.inc ;------------------------------------------------------------ data .section ’data’...
Page 232
HT-IDE User’s Guide a,20h ; timer overflow register “XOR” ; with 20h ; check over 20h timer_nov ; if not over 20h , jump timer_nov a,00001011b reti ;(4) ; return from ISR timer_nov: ; timer_nov reti ; return ISR start: ;...
Chapter 17 Parallel Port a,10h ; setup delay time call delays ;(8) ; call delays subroutine a,00000011b ; move acc=00000011, ; (BUSY=0, ACK=0, OE=1, WR=1) pc,a ; output acc to port C ; setup delay time call delays ; call delays subroutine a,00000111b ;...
Page 234
HT-IDE User’s Guide be outputs and clears the high and low order bytes. In (3) the control bits are initially set as follows BUSY=0, ACK=1, OE=0, WR=1 by placing these values on Port C. ACC is then cleared and the program waits for an interrupt to appear.
Appendix A Reserved Words Used By Assembler A p p e n d i x A Reserved Words Used By Assembler Registers The following list describes the registers used by the assembler Register Name Memory Address Instruction Sets Instruction Description A,[m] add the data memory and carry to the accumulator ADCM...
Page 238
HT-IDE User’s Guide CLR WDT clear the watch-dog timer CLR WDT1 clear the watch dog timer (except 48050) CLR WDT2 clear the watch dog timer (except 48050) complement the data memory CPLA complement the data memory, store the result to the...
Page 239
Appendix A Reserved Words Used By Assembler rotate data memory right rotate data memory right, save the result to the accmulator rotate data memory right with a carry RRCA rotate data memory right with carry, save the result to the accumulator A,[m] subtract the data memory and carry from the accumulator...
Page 240
HT-IDE User’s Guide A,[m] logical XOR the accumulator with the data memory logical XOR immediate data to the accumulator XORM A,[m] logical XOR the accumulator with the data memory...
Appendix B Cross Assembler Error Message A p p e n d i x B Cross Assembler Error Message A0005 Undefined symbol The specified symbol is not defined in this file. A0010 Unexpected symbol The symbol is redundant. A0011 Symbol already defined elsewhere Re-defined symbol.
Page 242
HT-IDE User’s Guide A0019 Redefined EQU The symbol to the left of the directive EQU has been previously defined. A0020 Multiple section definition The name of the section is the same as previously defined section. The section name must be unique in a source file.
Page 243
Appendix B Cross Assembler Error Message A0035 RAM-space limit exceeded The total memory size of data sections exceeds the allowed RAM size. A0036 ROM-space limit exceeded The total memory size of code sections exceeds the allowed ROM size. A0037 DC could be used in code section only This directive can not be used in the data section.
Page 244
HT-IDE User’s Guide A0051 Section Undefined in ROMBANK directive The directive ROMBANK contains an undefined section name. A4001 Incorrect command line option The command line option is illegal. A4002 Redefined symbol The specified symbol is defined already. A4003 No source file name No source file name in the command line.
Appendix C Cross Linker Error Messages A p p e n d i x C Cross Linker Error Messages L1001 No object files specified No object file is specified in the command line or the batch file. Check the command line HLINK syntax, refer to chapter 10. L1002 Object file ’filename.obj’...
Page 246
Please refer to chapter 10, section 10.2 for correct syntax. L1009 Illegal object file ’filename.obj’ The format of the specified object file (filename.obj) is incorrect Check if this object file has been generated by Holtek’s Cross Assembler. L1010 Cannot close object file ’filename.obj’...
Page 247
Appendix C Cross Linker Error Messages L1019 Cannot open the debug file ’debugname.dbg’ HLINK failed to open the debug file debugname.dbg Check the PC file system and working directory or contact dealer. L1020 Cannot open the task file ’taskname.tsk’ HLINK failed to open the task file taskname.tsk Check the PC file system and working directory or contact dealer.
Page 248
Illegal class type for section ’sec-name’ in the file ’filename.obj’ HLINK found that the class name of section (sec-name) in the file (filename.obj) is illegal (neither CODE nor DATA) Check if the file (filename.obj) is generated by Holtek Cross Assembler (HASM). Otherwise, contact dealer. L1035 Internal error when section ’sec-name’...
Page 249
Appendix C Cross Linker Error Messages L1040 Bank number exceeds 8 HLINK found a bank number larger than or equal to 8, maximum is 7 Modify the directive ROMBANK in the source program L1041 Can’t find SECDEF in BNKDEF HLINK failed to find the SECDEF record for a bank member, internal error Contact dealer L1042...
Appendix D Cross Library Error Messages A p p e n d i x D Cross Library Error Messages U0001 No library file name U0002 Library file does not exist U0003 Library file exists already U0004 The contents of the library file will be discarded if operation is executed U0005 Can’t open the library file...
Page 252
HT-IDE User’s Guide U0016 Not enough memory The user system has not enough memory for HLIB U0017 Bad object file The file to be added to the library file has a bad object format. It may not be generated by HASM or a disk error...
Appendix E Holtek Cross C Compiler Error Message A p p e n d i x E Holtek Cross C Compiler Error Messages Error Code C1000 Unterminated conditional in #include C1001 Unterminated #if/#ifdef/#ifndef C1002 Unidentifiable control line C1003 Could not find include file filename C1004 Illegal operator * or &...
Page 254
HT-IDE User’s Guide C1026 Unterminated string or char const C1027 Undefined expression value C1028 Bad ?: in #if/#endif C1029 Unknown operator in #if C1030 Bad number number in #if/#elsif C1031 Empty character constant C1032 Syntax error C1033 Internal Error in #if/#elsif...
Page 255
Appendix E Holtek Cross C Compiler Error Message C2035 undefined static type identifier C2036 undefined label identifier C2037 expecting an enumerator identifier C2038 overflow in value for enumeration constant identifier C2039 unknown enumeration identifier C2040 type error in argument number to identifier; found type1 expected...
HT-IDE User’s Guide C2076 invalid octal constant identifier C2077 missing character C2078 identifier literal too long C2079 missing ’ C2080 illegal character character C2081 identifier1 is a preprocessing number but an invalid identifier2 constant C2082 invalid floating constant identifier C2083 ill-formed hexadecimal escape sequence...
Page 257
Appendix E Holtek Cross C Compiler Error Message C3005 EOF inside comment C3006 Wide char constant value undefined C3007 Unknown preprocessor control control C3008 Undefined escape in character constant C3009 Multibyte character constant undefined C3010 Character constant taken as not signed...
HT-IDE User’s Guide C4034 more than 509 characters in a string literal C4035 string/character literal contains non-portable characters C4036 excess characters in multibyte character literal token ignored C4037 overflow in constant token C4039 overflow in hexadecimal escape sequence C4040 overflow in octal escape sequence...
Need help?
Do you have a question about the HT-IDE and is the answer not in the manual?
Questions and answers