Holtek HT46R47 Handbook

Holtek HT46R47 Handbook

A/d type mcu
Hide thumbs Also See for HT46R47:
Table of Contents

Advertisement

HT46R47, HT46R22,
HT46R23, HT46R24
Copyright Ó 2003 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 photo-
copying, recording, or otherwise without the prior written permission of HOLTEK SEMICONDUCTOR INC.
A/D Type MCU
Handbook
October 2004

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the HT46R47 and is the answer not in the manual?

Questions and answers

Summary of Contents for Holtek HT46R47

  • Page 1 Handbook October 2004 Copyright Ó 2003 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 photo-...
  • Page 2: Table Of Contents

    Contents Contents Part I Microcontroller Profile ..............1 Chapter 1 Hardware Structure ..................3 Introduction ........................3 Features ......................... 4 Technology Features ....................4 Kernel Features ....................... 4 Peripheral Features ....................4 Selection Table ......................5 Block Diagram ....................... 6 Pin Assignment ......................
  • Page 3 A/D Type MCU Special Function Registers ..................25 Indirect Addressing Registers - IAR, IAR0, IAR1 ..........25 Memory Pointers - MP, MP0, MP1 ............... 25 Bank Pointer - BP ....................26 Accumulator - ACC ....................26 Program Counter Low Register - PCL ..............26 Look-up Table Registers - TBLP, TBLH ..............
  • Page 4 Contents C Bus Communication ..................56 Interrupts ........................60 External Interrupt ....................63 Timer/Event Counter Interrupt ................63 A/D Interrupt ......................64 C Interrupt ......................64 Interrupt Priority ..................... 64 Programming Considerations ................65 Reset and Initialization ....................65 Reset ........................65 Oscillator ........................
  • Page 5 Step 1 - Create a New Project ................129 Step 2 - Add Source Program Files to the Project ..........129 Step 3 - Build the Project ..................129 Step 4 - Programming the OTP Device .............. 129 Step 5 - Transmit Code to Holtek ............... 130...
  • Page 6 Contents Appendix ....................131 Appendix A Device Characteristic Graphics .............. 133 Appendix B Package Information ................143...
  • Page 7 A/D Type MCU...
  • Page 8 By compiling all relevant data together in one handbook, we hope users of the Holtek range of A/D Type microcontroller devices will have at their fingertips a useful, complete and simple means to ef- ficiently implement their microcontroller applications.
  • Page 9 A/D Type MCU viii...
  • Page 10: Part I Microcontroller Profile

    Part I Microcontroller Profile P a r t I Microcontroller Profile...
  • Page 11 A/D Type MCU...
  • Page 12: Chapter 1 Hardware Structure

    I/O pin count, RAM and ROM capacity, timer number and size, A/D channels, PWM outputs, etc. The HT46R47, HT46R22, HT46R23 and HT46R24 are OTP devices offering the advantages of easy and effective program updates, using the Holtek range of development and programming tools.
  • Page 13: Features

    · Temperature Range: Operating Temperature -40°C to 85°C (Industrial Grade) Storage Temperature -50°C to 125°C Kernel Features · Program Memory: 2K´14 OTP/Mask ROM (HT46R47/HT46C47, HT46R22/HT46C22) 4K´15 OTP/Mask ROM (HT46R23/HT46C23) 8K´16 OTP/Mask ROM (HT46R24/HT46C24) · Data Memory: 64´8 SRAM (HT46R47/HT46C47, HT46R22/HT46C22) 192´8 SRAM (HT46R23/HT46C23)
  • Page 14: Selection Table

    Chapter 1 Hardware Structure · HALT and Wake-up Feature for Power Saving Operation · PFD Output · I C Interface (excluding HT46R47/HT46C47) · On-chip Crystal and RC Oscillator · Low Voltage Reset (LVR) Feature for Brown-out Protection · Programming Interface with Code Protection ·...
  • Page 15: Block Diagram

    The following block diagram illustrates the main functional blocks of the A/D Type microcontroller series of devices. Note This block diagram represents the OTP devices, for the mask device there is no Device Pro- gramming Circuitry. The HT46R47/HT46C47 does not contain an I C interface. The Bank Pointer only exists in the HT46R24/HT46C24.
  • Page 16: Pin Assignment

    Chapter 1 Hardware Structure Pin Assignment H T 4 6 R 4 7 / H T 4 6 C 4 7 H T 4 6 R 2 2 / H T 4 6 C 2 2 H T 4 6 R 2 3 / H T 4 6 C 2 3 2 4 S K D I P - A / S O P - A 1 8 D I P - A / S O P - A 2 4 S K D I P - A / S O P - A...
  • Page 17: Pin Description

    A/D Type MCU Pin Description HT46R47/HT46C47 Configuration Pin Name I/O Description Option Bidirectional 8-bit input/output port. Each individual bit on this PA0~PA2 port can be configured as a wake-up input by a configuration PA3/PFD Pull-high option. Software instructions determine if the pin is a CMOS...
  • Page 18 Chapter 1 Hardware Structure HT46R22/HT46C22 Configuration Pin Name Description Option Bidirectional 8-bit input/output port. Each individual bit on this port can be configured as a wake-up input by a configu- PA0~PA2 Pull-high ration option. Software instructions determine if the pin is a PA3/PFD Wake-up CMOS output or Schmitt Trigger input.
  • Page 19 A/D Type MCU HT46R23/HT46C23 Configuration Pin Name Description Option Bidirectional 8-bit input/output port. Each individual bit on this PA0~PA2 port can be configured as a wake-up input by a configuration Pull-high PA3/PFD option. Software instructions determine if the pin is a CMOS Wake-up PA4/TMR output or Schmitt Trigger input.
  • Page 20 Chapter 1 Hardware Structure HT46R24/HT46C24 Configuration Pin Name Description Option Bidirectional 8-bit input/output port. Each individual bit on this port can be configured as a wake-up input by a configu- PA0~PA2 Pull-high ration option. Software instructions determine if the pin is a PA3/PFD Wake-up CMOS output or Schmitt Trigger input.
  • Page 21: Absolute Maximum Ratings

    A/D Type MCU Note 1. Each pin on PA can be programmed through a configuration option to have a wake-up function. 2. Individual pins on PA and PB can be selected to have pull-high resistors. However, individual pins on Port C, Port D and Port F cannot be selected to have pull-high resistors. If the pull-high configuration is chosen for a particular PC, PD or PF port, then all input pins on the corresponding port will have pull-high resistors connected.
  • Page 22 Chapter 1 Hardware Structure Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions Input Low Voltage for I/O Ports, ¾ ¾ ¾ 0.3V TMR, TMR0, TMR1, INT Input High Voltage for I/O Ports, ¾ ¾ ¾ 0.7V TMR, TMR0, TMR1, INT ¾...
  • Page 23: Characteristics

    A/D Type MCU A.C. Characteristics Ta=25°C Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions ¾ ¾ 2.2V~5.5V 4000 kHz System Clock ¾ ¾ 3.3V~5.5V 8000 kHz ¾ ¾ 2.2V~5.5V 4000 kHz Timer I/P Frequency TIMER (TMR) ¾ ¾ 3.3V~5.5V 8000 kHz ¾...
  • Page 24: System Architecture

    Chapter 1 Hardware Structure System Architecture A key factor in the high performance features of the Holtek range of A/D Type microcontrollers is at- tributed to the internal system architecture. The range of devices take advantage of the usual fea- tures found within RISC microcontrollers providing increased speed of operation and enhanced performance.
  • Page 25: Program Counter

    A/D Type MCU For instructions involving branches, such as jump or call instructions, two machine cycles are re- quired to complete instruction execution. An extra cycle is required as the program takes one cy- cle to first obtain the actual jump or call address and then another cycle to actually execute the branch.
  • Page 26 6. For the HT46R23/HT46C23, since its Program Counter is 12 bits wide, the b12 column in the table is not applicable. 7. For the HT46R47/HT46C47, HT46R22/HT46C22, since its Program Counter is 11 bits wide, the b11 and b12 columns in the table are not applicable.
  • Page 27: Stack

    Note 1. For the HT46R47/HT46C47 and HT46R22/HT46C22, N=6, i.e. 6 levels of stack available. 2. For the HT46R23/HT46C23, N=8, i.e. 8 levels of stack available. 3. For the HT46R24/HT46C24, N=16, i.e. 16 levels of stack available.
  • Page 28: Program Memory

    Chapter 1 Hardware Structure Program Memory The Program Memory is the location where the user code or program is stored. For microcontrollers, two types of Program Memory are usually supplied. The first type is the One- Time Programmable (OTP) Memory where users can program their application code into the de- vice.
  • Page 29: Special Vectors

    · Location 010H With the exception of the HT46R47/HT46C47 and HT46R24/HT46C24 devices, this internal vector is used by the I C bus interface. When the I...
  • Page 30: Table Program Example

    ORG statement. The value at this ORG statement is ²700² hex which re- fers to the start address of the last page within the 2K Program Memory of the HT46R47 microcontroller. The table pointer is setup here to have an initial value of 06 hex.
  • Page 31: Data Memory

    3. For the HT46R24/HT46C24, the Table address location is 13 bits, i.e. from b12~b0. 4. For the HT46R23/HT46C23, the Table address location is 12 bits, i.e. from b11~b0. 5. For the HT46R47/HT46C47 and HT46R22/HT46C22, the Table address location is 11 bits, i.e. from b10~b0.
  • Page 32: General Purpose Data Memory

    Chapter 1 Hardware Structure Most of the Data Memory bits can be directly manipulated using the ²SET [m].i² and ²CLR [m].i² Note with the exception of a few dedicated bits. The Data Memory can also be accessed through the memory pointer register MP. General Purpose Data Memory All microcontroller programs require an area of read/write memory where temporary data can be stored and retrieved for use later.
  • Page 33: Special Purpose Data Memory

    A/D Type MCU Special Purpose Data Memory This area of Data Memory is where registers, necessary for the correct operation of the microcontroller, are stored. Most of the registers are both readable and writable but some are pro- tected and are readable only, the details of which are located under the relevant Special Function Register section.
  • Page 34: Special Function Registers

    Memory Pointer. Note For the HT46R47/HT46C47 and HT46R22/HT46C22 devices, bit 7 of the memory pointers are not implemented. However, it must be noted that when the memory pointers in these devices are read, a value of ²1²...
  • Page 35: Bank Pointer - Bp

    A/D Type MCU start: mov a,04h ; setup size of block mov block,a mov a,offset adres1 ; Accumulator loaded with first RAM address mov mp,a ; setup memory pointer with first RAM address loop: clr IAR ; clear the data at address defined by mp inc mp ;...
  • Page 36: Look-Up Table Registers - Tblp, Tblh

    Chapter 1 Hardware Structure Look-up Table Registers - TBLP, TBLH These two special function registers are used to control operation of the look-up table which is stored in the Program Memory. TBLP is the table pointer and indicates the location where the table is located.
  • Page 37: Interrupt Control Registers - Intc, Intc0, Intc1

    C bus in addition to the external interrupt pin INT. For the HT46R47/HT46C47 devices, only one 8-bit interrupt control register, known as INTC, is required to control all its interrupt functions, while the additional features of the other devices require two in- terrupt control registers, INTC0 and INTC1.
  • Page 38: Pulse Width Modulator Registers - Pwm, Pwm0, Pwm1, Pwm2, Pwm3

    ADSR. Input/Output Ports Holtek microcontrollers offer considerable flexibility on their I/O ports. With the input or output des- ignation of every pin fully under user program control, pull-high options for all pins and wake up op- tions on certain pins, the user is provided with an I/O structure to meet the needs of a wide range of application possibilities.
  • Page 39: Pull-High Resistors

    A/D Type MCU Pull-high Resistors Many product applications require pull-high resistors for their switch inputs usually requiring the use of an external resistor. To eliminate the need for these external resistors, all I/O pins, when con- figured as an input have the capability of being connected to an internal pull-high resistor. These pull-high resistors are selectable via configuration option and are implemented using a weak PMOS transistor.
  • Page 40 Each device in the A/D series contains a PFD output, pin-shared with PA3, and one or more PWM outputs, pin-shared with pins PD0~PD3. The number of PWM outputs depends upon which de- vice is chosen. With the exception of the HT46R47/HT46C47 devices, there are two pins associ- ated with an internal I C Bus, which are pin-shared with I/O pins PA6 and PA7.
  • Page 41 A/D Type MCU PA3/PFD and PD0/PWM0~PD3/PWM3 Input/Output Ports PA4/PA5 Input/Output Ports...
  • Page 42 Chapter 1 Hardware Structure PA6/SDA, PA7/SCL Input/Output Ports PB Input/Output Ports...
  • Page 43: Programming Considerations

    A/D Type MCU Programming Considerations Within the user program, one of the first things to consider is port initialization. After a reset, all of the I/O data and port control registers will be set high. This means that all I/O pins will default to an input state, the level of which depends on the other connected circuitry and whether pull-high op- tions have been selected.
  • Page 44: Configuring The Timer/Event Counter Input Clock Source

    8 - B i t T i m e r / E v e n t C o u n t e r ¸ P F D T M R i n p u t 8-bit Timer/Event Counter Structure - HT46R47/HT46C47 and HT46R22/HT46C22 TMR...
  • Page 45: Timer Registers - Tmr, Tmrl/Tmrh, Tmr0L/Tmr0H, Tmr1L/Tmr1H

    A/D Type MCU ¸ 16-bit Timer/Event Counter Structure - HT46R23/HT46C23 TMR ¸ 16-bit Timer/Event Counter Structure - HT46R24/HT46C24 TMR0 ¸ 16-bit Timer/Event Counter Structure - HT46R24/HT46C24 TMR1 Timer Registers - TMR, TMRL/TMRH, TMR0L/TMR0H, TMR1L/TMR1H The timer register is a special function register located in the special purpose Data Memory and is the place where the actual timer value is stored.
  • Page 46: Timer Control Registers - Tmrc, Tmr0C, Tmr1C

    Timer Control Registers - TMRC, TMR0C, TMR1C The flexible features of the Holtek microcontroller Timer/Event Counters enable them to operate in three different modes, the options of which are determined by the contents of their respective con- trol register.
  • Page 47 A/D Type MCU used, provides the basic on/off control of the respective timer. Setting the bit high allows the coun- ter to run, clearing the bit stops the counter. For timers that have prescalers, bits 0~2 of the Timer Control Register determine the division ratio of the input clock prescaler. The prescaler bit settings have no effect if an external clock source is used.
  • Page 48: Configuring The Timer Mode

    Chapter 1 Hardware Structure The HT46R24/HT46C24 devices have two internal timers, TMR0 and TMR1, and therefore re- quire an additional timer control register TMR1C. T i m e r / E v e n t C o u n t e r C o n t r o l R e g i s t e r T M R 1 C Configuring the Timer Mode In this mode, the timer can be utilized to measure fixed time intervals, providing an internal inter-...
  • Page 49: Configuring The Pulse Width Measurement Mode

    A/D Type MCU If TE, T0E or T1E is high, the counter will increment each time the external timer pin receives a high to low transition. As in the case of the other two modes, when the counter is full, the timer will overflow and generate an internal interrupt signal.
  • Page 50: Programmable Frequency Divider - Pfd

    Chapter 1 Hardware Structure Pulse Width Measurement Mode Timing Chart Programmable Frequency Divider - PFD The PFD output is pin-shared with the I/O pin PA3. The function is selected via configuration op- tion, however, if not selected, the pin can operate as a normal I/O pin. Note that for the HT46R24/ HT46C24 devices, which have two internal timers, the timer source for the PFD can be chosen, via configuration option, to come from either one of the two timers.
  • Page 51: Prescaler

    7+1 mode or 6+2 mode respectively. With the exception of the HT46R47/HT46C47 devices, which have a fixed 6+2 mode, each device can choose which mode to use by selecting the appropriate configuration option. When a mode config- uration option is chosen, it applies to all PWM outputs on that device.
  • Page 52: 6+2 Pwm Mode

    Chapter 1 Hardware Structure For all devices, the PWM clock source is the system clock f Device Channels PWM Mode Output Pin PWM Register Name HT46R47/HT46C47 HT46R22/HT46C22 6+2 or 7+1 HT46R23/HT46C23 6+2 or 7+1 PWM0 (24-pin package) HT46R23/HT46C23 6+2 or 7+1...
  • Page 53: 7+1 Pwm Mode

    A/D Type MCU The following diagram illustrates the waveforms associated with the 6+2 mode of PWM operation. It is important to note how the single PWM cycle is subdivided into 4 individual modulation cycles, numbered from 0~3 and how the AC value is related to the PWM value. 6+2 PWM Mode P W M R e g i s t e r...
  • Page 54: Pwm Output Control

    Chapter 1 Hardware Structure The following diagram illustrates the waveforms associated with the 7+1 mode of PWM operation. It is important to note how the single PWM cycle is subdivided into 2 individual modulation cycles, numbered 0 and 1 and how the AC value is related to the PWM value. 7+1 PWM Mode P W M R e g i s t e r...
  • Page 55: Analog To Digital Converter

    Each of the devices in the Holtek A/D series of microcontrollers contains either a 4-channel or 8-channel analog to digital converter which can directly interface to external analog signals such as that from sensors or other control signals and convert these signals directly into either a 9-bit or 10-bit digital value.
  • Page 56: A/D Converter Control Register - Adcr

    HT46R47/HT46C47 devices, which have only four analog input channels, bit ACS2 is not used and should be kept at a ²0² value. For the HT46R47/HT46C47 devices, if ACS2 is set to ²1² the function of ACS2~ACS0 will be undefined.
  • Page 57 A/D Type MCU A D C R R e g i s t e r ( e x c l u d i n g H T 4 6 R 4 7 / H T 4 6 C 4 7 ) ®...
  • Page 58: A/D Converter Clock Source Register - Acsr

    Chapter 1 Hardware Structure rupt control register, and if the interrupts are enabled, an appropriate internal interrupt signal will be generated. This A/D internal interrupt signal will direct the program flow to the associated A/D in- ternal interrupt address for processing. If the A/D internal interrupt is disabled, the microcontroller can be used to poll the EOCB bit in the ADCR register to check whether it has been cleared as an alternative method of detecting the end of an A/D conversion cycle.
  • Page 59: Summary Of A/D Conversion Steps

    A/D Type MCU input in the PBC port control register to enable the A/D input, when the PCR2~PCR0 bits enable an A/D input, the status of the port control register will be overridden. The VDD power supply pin is used as the A/D converter reference voltage, and as such analog inputs must not be allowed to ex- ceed this value.
  • Page 60 Chapter 1 Hardware Structure The following timing diagram shows graphically the various stages involved in an analog to digital conversion process and its associated timing. A/D Conversion Timing The setting up and operation of the A/D converter function is fully under the control of the applica- tion program as there are no configuration options associated with the A/D converter.
  • Page 61: A/D Transfer Function

    A/D Transfer Function As the HT46R47/HT46C47 and HT46R22/HT46C22 devices each contain a 9-bit A/D converter, their full-scale converted digitized value is equal to 1FFH. Since the full-scale analog input value is equal to the VDD voltage, this gives a single bit analog input value of V /512.
  • Page 62 The A/D Converter has a maximum of ±1 LSB Integral Non-Linearity Error which describes the de- parture from the ideal linear transfer function. For the HT46R47/HT46C47 and HT46R22/HT46C22, their 9-bit resolution A/D Converter is achieved with 8-bit accuracy while for the HT46R23/HT46C23...
  • Page 63: I 2 C Bus Serial Interface

    Both master and slave can transmit and receive data, however, it is the master device that has overall control of the bus. For the Holtek microcontrollers, which only operate in slave mode, there are two methods of transferring data on the I C bus, the slave transmit mode and the slave receive mode.
  • Page 64: I 2 C Bus Slave Address Register - Hadr

    Chapter 1 Hardware Structure C Bus Slave Address Register - HADR The HADR register is the location where the slave address of the microcontroller is stored. Bits 1~7 of the HADR register define the microcontroller slave address. Bit 0 is not implemented. When a master device, which is connected to the I C bus, sends out an address which matches the slave address in the HADR register, the microcontroller slave device will be selected.
  • Page 65: I 2 C Bus Communication

    A/D Type MCU will clear the HAAS bit. Also, if the transmitted address on the bus and the slave address of the de- vice do not match, then the HAAS bit will be reset to ²0². Bit 5, known as HBB, will be set to ²1² if the I C bus is busy, which will occur when a START signal is detected.
  • Page 66 Chapter 1 Hardware Structure been transmitted, the following bit, which is the 8th bit, is the read/write bit whose value will be placed in the SRW bit. This bit will be checked by the microcontroller to determine whether to go into transmit or receive mode.
  • Page 67 A/D Type MCU matching slave address or from the completion of a data byte transfer. When a slave address is matched, the device must be placed in either the transmit mode and then write data to the HDR register, or in the receive mode where it must implement a dummy read from the HDR register to release the SCL line.
  • Page 68 Chapter 1 Hardware Structure ® Data Byte The transmitted data is 8-bits wide and is transmitted after the slave device has acknowledged re- ceipt of its slave address. The order of serial bit transmission is the MSB first and the LSB last. Af- ter receipt of 8-bits of data, the receiver must transmit an acknowledge signal, level ²0², before it can receive the next data byte.
  • Page 69: Interrupts

    C interface all utilize the internal interrupt function for their operation. For the HT46R47/HT46C47 devices, which do not contain an internal I C interface and contain only a single timer, one 8-bit interrupt control register, known as INTC, is sufficient to control all the required operations.
  • Page 70 Chapter 1 Hardware Structure I N T C R e g i s t e r H T 4 6 R 4 7 / H T 4 6 C 4 7 I N T C 0 R e g i s t e r H T 4 6 R 2 2 / H T 4 6 C 2 2 H T 4 6 R 2 3 / H T 4 6 C 2 3 I N T C 1 R e g i s t e r...
  • Page 71 A/D Type MCU The external interrupt has the capability of waking up the processor when in the HALT mode. As an interrupt is serviced, a control transfer occurs by pushing the Program Counter onto the stack, followed by a branch to a subroutine at a specified location in the Program Memory. Only the Pro- gram Counter is pushed onto the stack.
  • Page 72: External Interrupt

    In the figure, the T1F interrupt request flag and the ET1I interrupt enable bit refer to the HT46R24/ HT46C24 devices, which have two timers. For the HT46R47/HT46C47, HT46R22/HT46C22 and HT46R23/HT46C23, which only have one timer, the Timer/Event Counter 0 represents the single timer, known as TMR and has interrupt request flag known as TF and enable bit known as ETI.
  • Page 73: A/D Interrupt

    ADF is set, a situation that will occur when an A/D conversion process has completed. In the case of the HT46R47/HT46C47 devices, this is bit 6 of the INTC register, while for the HT46R22/HT46C22 and HT46R23/HT46C23 devices, this is bit 6 of the INTC0 register.
  • Page 74: Programming Considerations

    Chapter 1 Hardware Structure HT46R47 HT46R22 HT46R23 HT46R24 Interrupt Source HT46C47 HT46C22 HT46C23 HT46C24 Priority Priority Priority Priority TMR/TMR0 Overflow TMR1 Overflow A/D Converter Interrupt C Bus Interrupt Note Only the HT46R24/HT46C24 devices have two internal timers, known as TMR0 and TMR1. The other devices in the series have only one internal timer, which is known as TMR.
  • Page 75 A/D Type MCU lowed to return high. Another type of reset is when the Watchdog Timer overflows and resets the microcontroller. All types of reset operations result in different register conditions being setup. Another reset exists in the form of a Low Voltage Reset, LVR, where a full reset, similar to the RES reset is implemented in situations where the power supply voltage falls below a certain threshold.
  • Page 76 Chapter 1 Hardware Structure ® Low Voltage Reset - LVR The microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device. If the supply voltage of the device drops to within a range of 0.9V~V such as might occur when changing the battery, the LVR will automatically reset the device internally.
  • Page 77 To ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. The following table de- scribes how each type of reset affects each of the microcontroller internal registers. HT46R47/HT46C47 Reset RES or LVR...
  • Page 78 Chapter 1 Hardware Structure HT46R22/HT46C22 Reset RES or LVR WDT Time-out WDT Time-out Register (Power On) Reset (Normal Operation) (HALT) - x x x x x x x - u u u u u u u - u u u u u u u - u u u u u u u x x x x x x x x u u u u u u u u...
  • Page 79 A/D Type MCU HT46R23/HT46C23 Reset RES or LVR WDT Time-out WDT Time-out Register (Power On) Reset (Normal Operation) (HALT) x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u x x x x x x x x u u u u u u u u...
  • Page 80 Chapter 1 Hardware Structure HT46R24/HT46C24 Reset RES or LVR WDT Time-out WDT Time-out Register (Power On) Reset (Normal Operation) (HALT) x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u x x x x x x x x...
  • Page 81: Oscillator

    A/D Type MCU Oscillator Various oscillator options offer the user a wide range of functions according to their various applica- tion requirements. Two types of system clocks can be selected while various clock source options for the Watchdog Timer are provided for maximum flexibility. All oscillator options are selected through the configuration options.
  • Page 82: System Rc Oscillator

    Chapter 1 Hardware Structure System RC Oscillator Using the external RC network as an oscillator requires that a resistor, with a value between 30kW and 750kW, is connected between OSC1 and GND. The generated system clock divided by 4 will be provided on OSC2 as an output which can be used for external synchronization purposes.
  • Page 83: Watchdog Timer

    A/D Type MCU When the system enters the HALT mode the system oscillator will be stopped to reduce power con- sumption. However, it is important to remember that if the internal WDT oscillator is enabled this will keep running and result in a small amount of power being consumed. In addition if the A/D con- verter is used, even though the system oscillator has been stopped there will still be some power consumption associated with the A/D circuitry.
  • Page 84 Chapter 1 Hardware Structure counter to give longer watchdog time-outs. In the case of the HT46R47/HT46C47 devices, this divi- sion ratio is fixed by an internal counter which gives a 2 fixed division ratio. In the case of the other devices, the division ratio can be varied by selecting different configuration options to give a to 2 division ratio range.
  • Page 85: Configuration Options

    (Number of ports is device dependent. Pull-high bit or port is also device dependent.) PD0~PD3: PWM function selection. Number of PWM channels are device dependent. PWM mode selection: (7+1) or (6+2) mode (excluding HT46R47/HT46C47, which is fixed at (6+2) mode) OSC type selection: RC or crystal PA3 PFD function: enable or disable...
  • Page 86: Application Circuits

    Chapter 1 Hardware Structure Application Circuits S e e B e l o w H T 4 6 R 4 7 / H T 4 6 C 4 7 R C S y s t e m O s c i l l a t o r C r y s t a l S y s t e m O s c i l l a t o r O S C C i r c u i t...
  • Page 87 A/D Type MCU S e e B e l o w H T 4 6 R 2 2 / H T 4 6 C 2 2 R C S y s t e m O s c i l l a t o r C r y s t a l S y s t e m O s c i l l a t o r O S C C i r c u i t...
  • Page 88 Chapter 1 Hardware Structure S e e B e l o w H T 4 6 R 2 3 / H T 4 6 C 2 3 R C S y s t e m O s c i l l a t o r C r y s t a l S y s t e m O s c i l l a t o r O S C C i r c u i t...
  • Page 89 A/D Type MCU S e e B e l o w H T 4 6 R 2 4 / H T 4 6 C 2 4 R C S y s t e m O s c i l l a t o r C r y s t a l S y s t e m O s c i l l a t o r O S C C i r c u i t...
  • Page 90: Part Ii Programming Language

    Part II Programming Language P a r t I I Programming Language...
  • Page 91 A/D Type MCU...
  • Page 92: Chapter 2 Instruction Set Introduction

    In the case of Holtek microcontrollers, a comprehensive and flexible set of over 60 instructions is provided to en- able programmers to implement their application with the minimum of programming overheads.
  • Page 93: Moving And Transferring Data

    The standard logical operations such as AND, OR, XOR and CPL all have their own instruction within the Holtek microcontroller instruction set. As with the case of most instructions involving data manipulation, data must pass through the Accumulator which may involve additional pro- gramming steps.
  • Page 94: Other Operations

    To overcome this problem, Holtek microcontrollers allow an area of Program Memory to be setup as a table where data can be directly stored. A set of easy to use instructions provides the means by which this fixed data can be referenced and retrieved from the Program Memory.
  • Page 95 A/D Type MCU Mnemonic Description Cycles Flag Affected Logic Operation AND A,[m] Logical AND Data Memory to ACC OR A,[m] Logical OR Data Memory to ACC XOR A,[m] Logical XOR Data Memory to ACC Note ANDM A,[m] Logical AND ACC to Data Memory Note ORM A,[m] Logical OR ACC to Data Memory...
  • Page 96 Chapter 2 Instruction Set Introduction Mnemonic Description Cycles Flag Affected Branch JMP addr Jump unconditionally None Note SZ [m] Skip if Data Memory is zero None note SZA [m] Skip if Data Memory is zero with data movement to ACC None Note SZ [m].i...
  • Page 97 A/D Type MCU...
  • Page 98: Chapter 3 Instruction Definition

    Chapter 3 Instruction Definition C h a p t e r 3 Instruction Definition ADC A,[m] Add Data Memory to ACC with Carry Description The contents of the specified Data Memory, Accumulator and the carry flag are added. The result is stored in the Accumulator. ACC ¬...
  • Page 99 A/D Type MCU AND A,[m] Logical AND Data Memory to ACC Description Data in the Accumulator and the specified Data Memory perform a bitwise logical AND op- eration. The result is stored in the Accumulator. ACC ¬ ACC ²AND² [m] Operation Affected flag(s) AND A,x...
  • Page 100 Chapter 3 Instruction Definition CLR WDT Clear Watchdog Timer Description The TO, PDF flags and the WDT are all cleared. Operation WDT cleared TO ¬ 0 PDF ¬ 0 Affected flag(s) TO, PDF CLR WDT1 Pre-clear Watchdog Timer Description The TO, PDF flags and the WDT are all cleared. Note that this instruction works in conjunc- tion with CLR WDT2 and must be executed alternately with CLR WDT2 to have effect.
  • Page 101 A/D Type MCU DAA [m] Decimal-Adjust ACC for addition with result in Data Memory Description Convert the contents of the Accumulator value to a BCD ( Binary Coded Decimal) value re- sulting from the previous addition of two BCD variables. If the low nibble is greater than 9 or if AC flag is set, then a value of 6 will be added to the low nibble.
  • Page 102 Chapter 3 Instruction Definition INCA [m] Increment Data Memory with result in ACC Description Data in the specified Data Memory is incremented by 1. The result is stored in the Accumu- lator. The contents of the Data Memory remain unchanged. ACC ¬...
  • Page 103 A/D Type MCU OR A,x Logical OR immediate data to ACC Description Data in the Accumulator and the specified immediate data perform a bitwise logical OR op- eration. The result is stored in the Accumulator. ACC ¬ ACC ²OR² x Operation Affected flag(s) ORM A,[m]...
  • Page 104 Chapter 3 Instruction Definition RLA [m] Rotate Data Memory left with result in ACC Description The contents of the specified Data Memory are rotated left by 1 bit with bit 7 rotated into bit 0. The rotated result is stored in the Accumulator and the contents of the Data Memory re- main unchanged.
  • Page 105 A/D Type MCU RRC [m] Rotate Data Memory right through Carry Description The contents of the specified Data Memory and the carry flag are rotated right by 1 bit. Bit 0 replaces the Carry bit and the original carry flag is rotated into bit 7. [m].i ¬...
  • Page 106 Chapter 3 Instruction Definition SDZA [m] Skip if decrement Data Memory is zero with result in ACC Description The contents of the specified Data Memory are first decremented by 1. If the result is 0, the following instruction is skipped. The result is stored in the Accumulator but the specified Data Memory contents remain unchanged.
  • Page 107 A/D Type MCU SNZ [m].i Skip if bit i of Data Memory is not 0 Description If bit i of the specified Data Memory is not 0, the following instruction is skipped. As this re- quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction.
  • Page 108 Chapter 3 Instruction Definition SZ [m] Skip if Data Memory is 0 Description If the contents of the specified Data Memory is 0, the following instruction is skipped. As this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction.
  • Page 109 A/D Type MCU XOR A,[m] Logical XOR Data Memory to ACC Description Data in the Accumulator and the specified Data Memory perform a bitwise logical XOR op- eration. The result is stored in the Accumulator. ACC ¬ ACC ²XOR² [m] Operation Affected flag(s) XORM A,[m]...
  • Page 110: Chapter 4 Assembly Language And Cross Assembler

    Cross Assembler Assembly-Language programs are written as source files. They can be assembled into object files by the Holtek Cross Assembler. Object files are combined by the Cross Linker to generate a task file. A source program is made up of statements and look up tables, giving directions to the Cross As- sembler at assembly time or to the processor at run time.
  • Page 111: Statement Syntax

    A/D Type MCU Example of Convention Description of Convention Three dots following an item signify that more items with the same form may be entered. For example, the directive PUB- LIC has the following form: Repeating elements... PUBLIC name1 [,name2 [,...]] In the above form, the three dots following name2 indicate that many names can be entered as long as each is pre- ceded by a comma.
  • Page 112: Comment

    Chapter 4 Assembly Language and Cross Assembler Comment Comments are the descriptions of codes. They are used for documentation only and are ignored by the Cross Assembler. Any text following a semicolon is considered a comment. Assembly Directives Directives give direction to the Cross Assembler, specifying the manner in which the Cross Assem- bler generates object code at assembly time.
  • Page 113: File Control Directives

    A/D Type MCU File Control Directives ® Syntax INCLUDE file-name INCLUDE ²file-name² · Description This directive inserts source codes from the source file given by file-name into the current source file during assembly. Cross Assembler supports at most 7 nesting levels. ·...
  • Page 114: Program Directives

    Chapter 4 Assembly Language and Cross Assembler ® Syntax .LISTINCLUDE .NOLISTINCLUDE · Description The directive .LISTINCLUDE inserts the contents of all included files into the program listing. The directive .NOLISTINCLUDE suppresses the addition of included files. The default is .NOLISTINCLUDE. ®...
  • Page 115 A/D Type MCU For DATA sections, the byte address is in one byte units (8 bits/byte). BYTE aligns the section at any byte address, WORD aligns the section at any even address, PARA aligns the section at any address which is a multiple of 16, and PAGE aligns the section at any address which is a multiple of 256.
  • Page 116 Chapter 4 Assembly Language and Cross Assembler ® Syntax ORG expression · Description This directive sets the location counter to expression. The subsequent code and data offsets begin at the new offset specified by expression. The code or data offset is relative to the be- ginning of the section where the directive ORG is defined.
  • Page 117: Data Definition Directives

    A/D Type MCU ® Syntax PROC name ENDP name · Description The PROC and ENDP directives mark a block of code which can be called or jumped to from other modules. The PROC creates a label name which stands for the address of the first instruction of a procedure.
  • Page 118 Chapter 4 Assembly Language and Cross Assembler ® Syntax [name] DB value1 [,value2 [, ...]] [name] DW value1 [,value2 [, ...]] [name] DBIT [name] DB repeated-count DUP(?) [name] DW repeated-count DUP(?) · Description These directives reserve the number of bytes/words specified by the repeated-count or reserve bytes/words only.
  • Page 119: Macro Directives

    A/D Type MCU Macro Directives Macro directives enable a block of source statements to be named, and then that name to be re-used in the source file to represent the statements. During assembly, the Cross Assembler auto- matically replaces each occurrence of the macro name with the statements in the macro definition. A macro can be defined at any place in the source file as long as the definition precedes the first source line that calls this macro.
  • Page 120 Chapter 4 Assembly Language and Cross Assembler The following source program refers to the macro Delay ... T . A S M S a m p l e p r o g r a m f o r M A C R O . .
  • Page 121: Assembly Instructions

    A/D Type MCU Assembly Instructions The syntax of an instruction has the following form: [name:] mnemonic [operand1[,operand2]] [;comment] where ® label name name: ® instruction name (keywords) mnemonic ® registers operand1 memory address ® registers operand2 memory address immediate value Name A name is made up of letters, digits, and special characters, and is used as a label.
  • Page 122 Chapter 4 Assembly Language and Cross Assembler The values of these shift bit operators are all constant values. The expression is shifted right SHR or left SHL by the number of bits specified by count. If bits are shifted out of position, the corresponding bits that are shifted in are zero-filled.
  • Page 123: Miscellaneous

    A/D Type MCU Example 2: mov A, BANK var mov BP,A mov A, OFFSET var mov MP1,A mov A,IAR1 · Operator precedence Precedence Operators 1 (Highest) ( ), [ ] +, - (unary), LOW, MID, HIGH, OFFSET, BANK *, /, %, SHL, SHR +, - (binary) >...
  • Page 124: Reserved Assembly Language Words

    Chapter 4 Assembly Language and Cross Assembler Reserved Assembly Language Words The following tables list all reserved words used by the assembly language. · Reserved Names (directives, operators) INCLUDE LABEL OFFSET ELSE .LIST .LISTINCLUDE ENDIF .LISTMACRO PAGE ENDM LOCAL PARA ENDP PROC MACRO...
  • Page 125: Cross Assembler Options

    A/D Type MCU Cross Assembler Options The Cross Assembler options can be set via the Options menu Project command in HT-IDE3000. The Cross Assembler Options is located on the center part of the Project Option dialog box. The symbols could be defined in the Define Symbol edit box. ®...
  • Page 126: Summary Of Assembly

    Chapter 4 Assembly Language and Cross Assembler · Summary l l l l ® line number (4 digits, right alignment) oooo ® offset of code (4 digits) hhhh ® two 4-digits for opcode E ® external reference C ® statement from included file R ®...
  • Page 127 A/D Type MCU ® Example of assembly listing file F i l e : S A M P L E . A S M H o l t e k C r o s s - A s s e m b l e r V e r s i o n 2 .
  • Page 128: Part Iii Development Tools

    Part III Development Tools P a r t I I I Development Tools...
  • Page 129 A/D Type MCU...
  • Page 130: Chapter 5 Mcu Programming Tools

    To ease the process of application development, the importance and availability of supporting tools for microcontrollers cannot be underestimated. To support its range of MCUs, Holtek is fully committed to the development and release of easy to use and fully functional tools for its full range of devices.
  • Page 131: Holtek In-Circuit Emulator - Ht-Ice

    Central to the system is the in-circuit hardware emulator, capable of emulating all of Holtek¢s 8-bit devices in real-time, while also providing a range of powerful debugging and trace fa- cilities. Regarding software functions, the system incorporates a user-friendly Windows based workbench which integrates together functions such as program editor, Cross Assembler, Cross Linker and library manager.
  • Page 132: Otp Programmer

    The Holtek OTP programmers are supplied with a standard Textool chip socket. The OTP Adapter Card is used to connect the Holtek OTP programmers to the various sizes of available OTP chip packages that are unable to use this supplied socket.
  • Page 133: Ht-Ice Interface Card Settings

    ¾ ¾ HT46R47 JP6 consists of the I/O ports and other pins. The MCU pin assignment in location U2, U3 and U4 are defined so as to match the datasheet pin assignment for the A/D series of MCUs. The interface...
  • Page 134: Installation

    Exercise care when using the power adapter. Do not use a power adapter whose output voltage is not 16V, 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 to the power connector of the HT-ICE.
  • Page 135 A/D Type MCU Click <HT-IDE3000> button and the following dialog will be shown. Click <HT-IDE3000> or <Service Pack> as you want. Here¢s an Example of installing HT-IDE3000 Click <HT-IDE3000> button. · Step 2 Press the <Next> button to continue setup or press <Cancel> button to abort.
  • Page 136 Chapter 5 MCU Programming Tools · Step 3 The following dialog will be shown to ask the user to enter a directory name. · Step 4 Specify the path you want to install the HT-IDE3000 and click <Next> button. · Step 5 Setup will copy all files to the specified directory.
  • Page 137 (EXE), dynamic link libraries (DLL) and configuration files (CFG, FMT) for all supported MCU. The INCLUDE subdirectory contains all the include files (.H, .INC) provided by Holtek. The LIB subdirectory contains the library files (.LIB) provided by Holtek. The SAMPLE subdirectory con- tains some sample programs.
  • Page 138: Chapter 6 Quick Start

    Chapter 6 Quick Start C h a p t e r 6 Quick Start This chapter gives a brief description of using HT-IDE3000 to develop an application project. Step 1 - Create a New Project · Click on Project menu and select New command ·...
  • Page 139: Step 5 - Transmit Code To Holtek

    Step 5 - Transmit Code to Holtek · Click on Project menu and select Print Option Table command · Send the .COD file and the Option Approval Sheet to Holtek The Programming and data flow is illustrated by the following diagram: .
  • Page 140: Appendix

    Appendix Appendix...
  • Page 141 A/D Type MCU...
  • Page 142: Appendix A Device Characteristic Graphics

    Appendix A Device Characteristic Graphics A p p e n d i x A Device Characteristic Graphics The following characteristic graphics depicts typical device behavior. The data presented here is a statistical summary of data gathered on units from different lots over a period of time. This is for in- formation only and the figures were not tested during manufacturing.
  • Page 143 A/D Type MCU Typical RC OSC vs. Temperature ° Typical RC Oscillator Frequency vs. V...
  • Page 144 Appendix A Device Characteristic Graphics vs. V ° ° ° ° vs. V ° ° ° °...
  • Page 145 A/D Type MCU vs. V ° ° ° ° vs. V ° ° ° °...
  • Page 146 Appendix A Device Characteristic Graphics Typical R vs. V ° ° ° ° Typical V vs. V in -40°C to +85°C...
  • Page 147 A/D Type MCU Typical I vs. V Watchdog Enable ° ° ° ° Typical t vs. V WDTOSC ° ° ° °...
  • Page 148 Appendix A Device Characteristic Graphics Typical I vs. Frequency (External Clock, Ta=-40°C) Typical I vs. Frequency (External Clock, Ta=0°C)
  • Page 149 A/D Type MCU Typical I vs. Frequency (External Clock, Ta=+25°C) Typical I vs. Frequency (External Clock, Ta=+85°C)
  • Page 150 Appendix A Device Characteristic Graphics Typical V vs. Temperature °...
  • Page 151 A/D Type MCU...
  • Page 152: Appendix B Package Information

    Appendix B Package Information A p p e n d i x B Package Information...
  • Page 153 A/D Type MCU 18-pin DIP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 15°...
  • Page 154 Appendix B Package Information 18-pin SOP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ ¾ ¾ ¾ C¢ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 10°...
  • Page 155 A/D Type MCU 24-pin SKDIP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ 1235 1265 ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 15°...
  • Page 156 Appendix B Package Information 24-pin SOP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ ¾ ¾ ¾ C¢ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 10°...
  • Page 157 A/D Type MCU 28-pin SKDIP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ 1375 1395 ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 15°...
  • Page 158 Appendix B Package Information 28-pin SOP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ ¾ ¾ ¾ C¢ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 10°...
  • Page 159 A/D Type MCU 48-pin SSOP (300mil) Outline Dimensions Dimensions in mil Symbol Min. Nom. Max. ¾ ¾ ¾ ¾ C¢ ¾ ¾ ¾ ¾ ¾ ¾ ¾ 0° 8°...
  • Page 160 Copyright Ó 2004 by HOLTEK SEMICONDUCTOR INC. The information appearing in this handbook 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...
  • Page 161 A/D Type MCU...
  • Page 162 Amendments...

This manual is also suitable for:

Ht46r22Ht46r23Ht46r24

Table of Contents

Save PDF