Holtek HT45F6530 Manual

Ac voltage regulator flash mcu
Table of Contents

Advertisement

Quick Links

AC Voltage Regulator Flash MCU
HT45F6530
Revision: V1.00
Date: August 29, 2018

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Holtek HT45F6530

  • Page 1 AC Voltage Regulator Flash MCU HT45F6530 Revision: V1.00 Date: August 29, 2018...
  • Page 2: Table Of Contents

    HT45F6530 AC Voltage Regulator Flash MCU Table of Contents Features ......................6 CPU Features ......................... 6 Peripheral Features ......................... 6 General Description ..................7 Block Diagram ....................8 Pin Assignment ....................8 Pin Description ....................9 Absolute Maximum Ratings ................11 D.C.
  • Page 3 HT45F6530 AC Voltage Regulator Flash MCU Data Memory ....................27 Structure ..........................27 General Purpose Data Memory .................... 27 Special Purpose Data Memory ..................... 28 Special Function Register Description ............29 Indirect Addressing Registers – IAR0, IAR1 ................. 29 Memory Pointers – MP0, MP1 ....................29 Bank Pointer –...
  • Page 4 HT45F6530 AC Voltage Regulator Flash MCU I/O Pin Structures ........................58 Programming Considerations ....................59 Timer Module – TM ..................59 Introduction ........................... 59 TM Operation ........................59 TM Clock Source ........................60 TM Interrupts ......................... 60 TM External Pins ........................60 Programming Considerations ....................
  • Page 5 HT45F6530 AC Voltage Regulator Flash MCU Application Description ................100 Introduction ......................... 100 Functional Description ......................100 Hardware Block Diagram ....................101 Hardware Circuit Diagram ....................101 Instruction Set ....................102 Introduction ......................... 102 Instruction Timing ........................ 102 Moving and Transferring Data ..................... 102 Arithmetic Operations ......................
  • Page 6: Features

    HT45F6530 AC Voltage Regulator Flash MCU Features CPU Features • Operating voltage =8MHz: 2.2V~5.5V ♦ • Up to 0.5μs instruction cycle with 8MHz system clock at V • Power down and wake-up functions to reduce power consumption • Oscillator types Internal High Speed 8MHz RC –...
  • Page 7: General Description

    AC Voltage Regulator Flash MCU General Description The HT45F6530 device is a Flash Memory A/D type 8-bit high performance RISC architecture microcontroller, specifically designed for AC Automatic Voltage Regulator applications. Aimed at relay type AVR product required measurement circuits, the device can accurately measure input and output voltages, detect zero crossing points and the relay action delay time.
  • Page 8: Block Diagram

    2. The OCDSDA and OCDSCK pins are supplied as OCDS dedicated pins and as such only available for the HT45V6530 device which is the OCDS EV chip for the HT45F6530 device. 3. For less pin-count package types there will be unbonded pins which should be properly configured to avoid unwanted current consumption resulting from floating input conditions.
  • Page 9: Pin Description

    HT45F6530 AC Voltage Regulator Flash MCU Pin Description With the exception of the power pins, all pins on the device can be referenced by their Port name, e.g. PA0, PA1 etc., which refer to the digital I/O function of the pins. However these Port pins are also shared with other function such as the Analog to Digital Converter, Timer Module pins etc.
  • Page 10 HT45F6530 AC Voltage Regulator Flash MCU Pin Name Function Description PAPU General purpose I/O. Register enabled pull-up and PAWU CMOS wake-up PA7/AN0 PAS1 PAS1 — A/D Converter external input channel PBPU CMOS General purpose I/O. Register enabled pull-up PBS0 PB0/BUF_OUT1 BUF_OUT1 PBS0 —...
  • Page 11: Absolute Maximum Ratings

    HT45F6530 AC Voltage Regulator Flash MCU Pin Name Function Description — — Positive power supply — — Negative power supply, ground Legend: I/T: Input type; O/T: Output type; OPT: Optional by register option; PWR: Power; ST: Schmitt Trigger input; CMOS: CMOS output;...
  • Page 12: Standby Current Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU Standby Current Characteristics Ta=25˚C, unless otherwise specified Test Conditions Max. Symbol Standby Mode Min. Typ. Max. Unit @85˚C Conditions 2.2V — WDT off — μA — SLEEP Mode 2.2V — WDT on — μA —...
  • Page 13: Low Speed Internal Oscillator Characteristics - Lirc

    HT45F6530 AC Voltage Regulator Flash MCU Low Speed Internal Oscillator Characteristics – LIRC Ta=25˚C, unless otherwise specified Test Conditions Symbol Parameter Min. Typ. Max. Unit Temp. 25˚C 25.6 32.0 38.4 LIRC Frequency 25˚C 12.8 32.0 41.6 LIRC 2.2V~5.5V -40˚C~85˚C LIRC Start Up Time —...
  • Page 14: Input/Output Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU Input/Output Characteristics Ta=25˚C Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions — Input Low Voltage for I/O Ports — — — 0.2V — Input High Voltage for I/O Ports — — 0.8V —...
  • Page 15: Lvr/Lvd Electrical Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU LVR/LVD Electrical Characteristics Ta=25˚C Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions Low Voltage Reset Voltage — LVR enable, voltage select 2.1V LVD enable, voltage select 2.0V LVD enable, voltage select 2.2V LVD enable, voltage select 2.4V LVD enable, voltage select 2.7V...
  • Page 16: A/D Converter Electrical Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU A/D Converter Electrical Characteristics Ta=-40˚C~85˚C, unless otherwise specified Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions A/D Converter Operating Voltage — — — A/D Converter Input Voltage — — — A/D Converter Reference Voltage —...
  • Page 17: Over Current Protection Electrical Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU Over Current Protection Electrical Characteristics D/A Converter Electrical Characteristics Ta=-40˚C~85˚C, unless otherwise specified Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions Operating Voltage — — — Code=000H — +0.2 Output Voltage Range —...
  • Page 18 HT45F6530 AC Voltage Regulator Flash MCU Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions =1MΩ, C =60pF, LOAD LOAD — OPnBW[1:0]=00 =1MΩ, C =60pF, LOAD LOAD — OPnBW[1:0]=01 Gain Bandwidth =1MΩ, C =60pF, LOAD LOAD — OPnBW[1:0]=10 =1MΩ, C...
  • Page 19: Comparator Electrical Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions OPnBW[1:0]=00, 01 — -120 =5KΩ to V LOAD Maximum Output Voltage Range — OPnBW[1:0]=10, 11 — =5KΩ to V LOAD 5.1Ω, LOAD= ±1.2 ±12 —...
  • Page 20: Power-On Reset Characteristics

    HT45F6530 AC Voltage Regulator Flash MCU Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions 3V With 100mV overdrive — μs CNVTn[1:0]=00B — 3V With 100mV overdrive — μs CNVTn[1:0]=01B — 3V With 100mV overdrive — μs CNVTn[1:0]=10B — 3V With 100mV overdrive —...
  • Page 21: System Architecture

    AC Voltage Regulator Flash MCU System Architecture A key factor in the high-performance features of the Holtek range of microcontrollers is attributed to their internal system architecture. The device takes advantage of the usual features found within RISC microcontrollers providing increased speed of operation and Periodic performance. The...
  • Page 22: Program Counter

    HT45F6530 AC Voltage Regulator Flash MCU Fetch Inst. 1 Execute Inst. 1 MOV A,[12H] Fetch Inst. 2 Execute Inst. 2 CALL DELAY Fetch Inst. 3 Flush Pipeline CPL [12H] Fetch Inst. 6 Execute Inst. 6 Fetch Inst. 7 6 DELAY: NOP...
  • Page 23: Arithmetic And Logic Unit - Alu

    HT45F6530 AC Voltage Regulator Flash MCU Program Counter Top of Stack Stack Level 1 Stack Stack Level 2 Pointer Program Memory Stack Level 3 Stack Level 4 Bottom of Stack Arithmetic and Logic Unit – ALU The arithmetic-logic unit or ALU is a critical area of the microcontroller that carries out arithmetic and logic operations of the instruction set.
  • Page 24: Special Vectors

    HT45F6530 AC Voltage Regulator Flash MCU 0000H Initialisation Vector 0004H Interrupt Vectors 002CH n00H Look-up Table nFFH 07FFH 15 bits Program Memory Structure Special Vectors Within the Program Memory, certain locations are reserved for the reset and interrupts. The location 0000H is reserved for use by the device reset for program initialisation.
  • Page 25: In Circuit Programming - Icp

    The provision of Flash type Program Memory provides the user with a means of convenient and easy upgrades and modifications to their programs on the same device. As an additional convenience, Holtek has provided a means of programming the microcontroller in- circuit using a 4-pin interface. This provides manufacturers with the possibility of manufacturing their circuit boards complete with a programmed or un-programmed microcontroller, and then programming or upgrading the program at a later stage.
  • Page 26: On-Chip Debug Support - Ocds

    There is an EV chip named HT45V6530 which is used to emulate the real MCU device named HT45F6530. The EV chip device also provides the “On-Chip Debug” function to debug the real MCU device during development process. The EV chip and real MCU device, HT45V6530 and HT45F6530, are almost functional compatible except the “On-Chip Debug”...
  • Page 27: Data Memory

    HT45F6530 AC Voltage Regulator Flash MCU Data Memory The Data Memory is a volatile area of 8-bit wide RAM internal memory and is the location where temporary information is stored. Structure Divided into two types, the first of these is an area of RAM, known as the Special Function Data Memory.
  • Page 28: Special Purpose Data Memory

    HT45F6530 AC Voltage Regulator Flash 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 writeable but some are protected and are readable only, the details of which are located under the relevant Special Function Register section.
  • Page 29: Special Function Register Description

    HT45F6530 AC Voltage Regulator Flash MCU Special Function Register Description Most of the Special Function Register details will be described in the relevant functional section; however several registers require a separate description in this section. Indirect Addressing Registers – IAR0, IAR1 The Indirect Addressing Registers, IAR0 and IAR1, although having their locations in normal RAM register space, do not actually physically exist as normal registers.
  • Page 30: Bank Pointer - Bp

    HT45F6530 AC Voltage Regulator Flash MCU Bank Pointer – BP For this device, the Data Memory is divided into two banks, Bank 0 and Bank 1. Selecting the required Data Memory area is achieved using the Bank Pointer. Bit 0 of the Bank Pointer is used to select Data Memory Banks 0~1.
  • Page 31: Status Register - Status

    HT45F6530 AC Voltage Regulator Flash MCU Status Register – STATUS This 8-bit register contains the zero flag (Z), carry flag (C), auxiliary carry flag (AC), overflow flag (OV), power down flag (PDF), and watchdog time-out flag (TO). These arithmetic/logical operation and system management flags are used to record the status and operation of the microcontroller.
  • Page 32 HT45F6530 AC Voltage Regulator Flash MCU • STATUS Register Name — — — — — — “x”: unknown Bit 7~6 Unimplemented, read as “0” Bit 5 TO: Watchdog Time-out flag 0: After power up or executing the “CLR WDT” or “HALT” instruction 1: A watchdog time-out occurred.
  • Page 33: Eeprom Data Memory

    HT45F6530 AC Voltage Regulator Flash MCU EEPROM Data Memory This device contains an area of internal EEPROM Data Memory. EEPROM is by its nature a non- volatile form of re-programmable memory, with data retention even when its power supply is removed.
  • Page 34: Reading Data From The Eeprom

    HT45F6530 AC Voltage Regulator Flash MCU • EEC Register Name — — — — WREN RDEN — — — — — — — — Bit 7~4 Unimplemented, read as “0” WREN: Data EEPROM Write Enable Bit 3 0: Disable 1: Enable This is the Data EEPROM Write Enable Bit which must be set high before Data EEPROM write operations are carried out.
  • Page 35: Writing Data To The Eeprom

    HT45F6530 AC Voltage Regulator Flash MCU Writing Data to the EEPROM To write data to the EEPROM, the EEPROM address of the data to be written must first be placed in the EEA register and the data placed in the EED register. Then the write enable bit, WREN, in the EEC register must first be set high to enable the write function.
  • Page 36 HT45F6530 AC Voltage Regulator Flash MCU Programming Examples Reading data from the EEPROM – polling method MOV A, EEPROM_ADRES ; user defined address MOV EEA, A MOV A, 040H ; setup memory pointer MP1 MOV MP1, A ; MP1 points to EEC register MOV A, 01H ; setup Bank Pointer MOV BP, A SET IAR1.1 ; set RDEN bit, enable read operations SET IAR1.0 ; start Read Cycle - set RD bit BACK: SZ IAR1.0 ; check for read cycle end JMP BACK CLR IAR1 ; disable EEPROM read if no more read operations are required CLR BP MOV A, EED ; move read data to register MOV READ_DATA, A Note: For each read operation, the address register should be re-specified followed by setting the RD bit high to activate a read cycle even if the target address is consecutive.
  • Page 37: Oscillators

    HT45F6530 AC Voltage Regulator Flash MCU Oscillators Various oscillator options offer the user a wide range of functions according to their various application requirements. The flexible features of the oscillator functions ensure that the best optimisation can be achieved in terms of speed and power saving. Oscillator selections and operation are selected through registers.
  • Page 38: Internal High Speed Rc Oscillator - Hirc

    As Holtek has provided this device with both high and low speed clock sources and the means to switch between them dynamically, the user can optimise the operation of their microcontroller to achieve the best performance/power ratio.
  • Page 39: System Operation Modes

    HT45F6530 AC Voltage Regulator Flash MCU High Speed Oscillator HIRCEN HIRC Prescaler IDLE0 SLEEP Low Speed Oscillator CKS2~CKS0 LIRC LIRC IDLE2 SLEEP Time Base 0 Prescaler Time Base 1 TB1[2:0] TB0[2:0] CLKSEL[1:0] LIRC Device Clock Configurations Note: When the system clock source f...
  • Page 40: Control Register

    HT45F6530 AC Voltage Regulator Flash MCU FAST Mode As the name suggests this is one of the main operating modes where the microcontroller has all of its functions operational and where the system clock is provided by the high speed oscillator. This mode operates allowing the microcontroller to operate normally with a clock source will come from the high speed oscillator HIRC.
  • Page 41 HT45F6530 AC Voltage Regulator Flash MCU • SCC Register Name CKS2 CKS1 CKS0 — — — FHIDEN FSIDEN — — — — — — Bit 7~5 CKS2~CKS0: System clock selection 000: f 001: f 010: f 011: f 100: f...
  • Page 42: Operating Mode Switching

    HT45F6530 AC Voltage Regulator Flash MCU Operating Mode Switching The device can switch between operating modes dynamically allowing the user to select the best performance/power ratio for the present task in hand. In this way microcontroller operations that do not require high performance can be executed using slower clocks thus requiring less operating current and prolonging battery life in portable applications.
  • Page 43 HT45F6530 AC Voltage Regulator Flash MCU FAST Mode CKS2~CKS0 = 111 SLOW Mode FHIDEN=0, FSIDEN=0 HALT instruction is executed SLEEP Mode FHIDEN=0, FSIDEN=1 HALT instruction is executed IDLE0 Mode FHIDEN=1, FSIDEN=1 HALT instruction is executed IDLE1 Mode FHIDEN=1, FSIDEN=0 HALT instruction is executed...
  • Page 44 HT45F6530 AC Voltage Regulator Flash MCU Entering the SLEEP Mode There is only one way for the device to enter the SLEEP Mode and that is to execute the “HALT” instruction in the application program with both the FHIDEN and FSIDEN bit in SCC register equal to “0”.
  • Page 45: Standby Current Considerations

    HT45F6530 AC Voltage Regulator Flash MCU • The Data Memory contents and registers will maintain their present condition. • The I/O ports will maintain their present conditions. • In the status register, the Power Down flag PDF will be set, and WDT timeout flag TO will be cleared.
  • Page 46: Watchdog Timer

    HT45F6530 AC Voltage Regulator Flash MCU or when a stack level becomes free. The other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. If an interrupt request flag is set high before entering the SLEEP or IDLE Mode, the wake-up function of the related interrupt will be disabled.
  • Page 47: Watchdog Timer Operation

    HT45F6530 AC Voltage Regulator Flash MCU • RSTFC Register Name — — — — — LVRF — — — — — — — — — — — — — “x”: unknown Bit 7~3 Unimplemented, read as “0” Bit 2 LVRF: LVR function reset flag...
  • Page 48: Reset And Initialisation

    HT45F6530 AC Voltage Regulator Flash MCU WDTC Register WE4~WE0 bits Reset MCU “CLR WDT” Instruction “HALT” Instruction LIRC LIRC LIRC 8-stage Divider WDT Prescaler WS2~WS0 8-to-1 MUX WDT Time-out LIRC LIRC Watchdog Timer Reset and Initialisation A reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters.
  • Page 49 HT45F6530 AC Voltage Regulator Flash MCU Low Voltage Reset – LVR The microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device. The LVR function is always enabled during normal operation with a specific LVR voltage .
  • Page 50: Reset Initial Conditions

    HT45F6530 AC Voltage Regulator Flash MCU Watchdog Time-out Reset during SLEEP or IDLE Mode The Watchdog time-out Reset during SLEEP or IDLE Mode is a little different from other kinds of reset. Most of the conditions remain unchanged except that the Program Counter and the Stack Pointer will be cleared to “0”...
  • Page 51 HT45F6530 AC Voltage Regulator Flash MCU LVR Reset WDT Time-out WDT Time-out Register Power On Reset (Normal Operation) (Normal Operation) (IDLE/SLEEP) STATUS - - 0 0 x x x x - - u u u u u u - - 1 u u u u u...
  • Page 52 HT45F6530 AC Voltage Regulator Flash MCU LVR Reset WDT Time-out WDT Time-out Register Power On Reset (Normal Operation) (Normal Operation) (IDLE/SLEEP) INTC0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0...
  • Page 53: Input/Output Ports

    AC Voltage Regulator Flash MCU Input/Output Ports Holtek microcontrollers offer considerable flexibility on their I/O ports. With the input or output designation of every pin fully under user program control, pull-high selections for all ports and wake-up selections on certain pins, the user is provided with an I/O structure to meet the needs of a wide range of application possibilities.
  • Page 54: Port A Wake-Up

    HT45F6530 AC Voltage Regulator Flash MCU Port A Wake-up The HALT instruction forces the microcontroller into the SLEEP or IDLE Mode which preserves power, a feature that is important for battery and other low-power applications. Various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the Port A pins from high to low.
  • Page 55 HT45F6530 AC Voltage Regulator Flash MCU Pin-shared Function Selection Registers The limited number of supplied pins in a package can impose restrictions on the amount of functions a certain device can contain. However by allowing the same pins to share several different functions and providing a means of function selection, a wide range of different functions can be incorporated into even relatively small package sizes.
  • Page 56 HT45F6530 AC Voltage Regulator Flash MCU PAS01~PAS00: PA0 Pin-Shared function selection Bit 1~0 00: PA0/INT0 01: CTP0 10: PA0/INT0 11: VR1EXT • PAS1 Register Name PAS17 PAS16 PAS15 PAS14 PAS13 PAS12 PAS11 PAS10 PAS17~PAS16: PA7 Pin-Shared function selection Bit 7~6...
  • Page 57 HT45F6530 AC Voltage Regulator Flash MCU PBS01~PBS00: PB0 Pin-Shared function selection Bit 1~0 00: PB0 01: PB0 10: PB0 11: BUF_OUT1 • PBS1 Register Name PBS17 PBS16 PBS15 PBS14 PBS13 PBS12 PBS11 PBS10 PBS17~PBS16: PB7 Pin-Shared function selection Bit 7~6...
  • Page 58: I/O Pin Structures

    HT45F6530 AC Voltage Regulator Flash MCU PCS01~PCS00: PC0 Pin-Shared function selection Bit 1~0 00: PC0/CTCK0 01: PC0/CTCK0 10: PC0/CTCK0 11: CMP0O • PCS1 Register Name — — — — PCS13 PCS12 PCS11 PCS10 — — — — — — —...
  • Page 59: Programming Considerations

    HT45F6530 AC Voltage Regulator Flash MCU Programming Considerations Within the user program, one of the first things to consider is port initialisation. 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 selections have been chosen.
  • Page 60: Tm Clock Source

    HT45F6530 AC Voltage Regulator Flash MCU TM Clock Source The clock source which drives the main counter in each TM can originate from various sources. The selection of the required clock source is implemented using the CTnCK2~CTnCK0 bits in the CTMn control registers, where n stands for the TM serial number.
  • Page 61 HT45F6530 AC Voltage Regulator Flash MCU this register pair is carried out in a specific way described above, it is recommended to use the “MOV” instruction to access the CCRA low byte register, named CTMnAL, in the following access procedures. Accessing the CCRA low byte register without following these access procedures will result in unpredictable values.
  • Page 62: Compact Type Tm - Ctm

    HT45F6530 AC Voltage Regulator Flash MCU Compact Type TM – CTM The Compact Type TM contains three operating modes, which are Compare Match Output, Timer/ Event Counter and PWM Output modes. The Compact TM can also be controlled with an external input pin and can drive two external output pins.
  • Page 63 HT45F6530 AC Voltage Regulator Flash MCU Register Name CTMnC0 CTnPAU CTnCK2 CTnCK1 CTnCK0 CTnON CTnRP2 CTnRP1 CTnRP0 CTMnC1 CTnM1 CTnM0 CTnIO1 CTnIO0 CTnOC CTnPOL CTnDPX CTnCCLR CTMnDL CTMnDH — — — — — — CTMnAL CTMnAH — — — —...
  • Page 64 HT45F6530 AC Voltage Regulator Flash MCU CTnRP2~CTnRP0: CTMn CCRP 3-bit register, compared with the CTMn counter Bit 2~0 bit 9~bit 7 Comparator P match period= 0: 1024 CTMn clocks 1~7: (1~7)×128 CTMn clocks These three bits are used to setup the value on the internal CCRP 3-bit register, which are then compared with the internal counter’s highest three bits.
  • Page 65 HT45F6530 AC Voltage Regulator Flash MCU In the PWM Output Mode, the CTnIO1 and CTnIO0 bits determine how the CTMn output pin changes state when a certain compare match condition occurs. The PWM output function is modified by changing these two bits. It is necessary to only change the values of the CTnIO1 and CTnIO0 bits only after the CTMn has been switched off.
  • Page 66: Compact Type Tm Operation Modes

    HT45F6530 AC Voltage Regulator Flash MCU • CTMnDH Register Name — — — — — — — — — — — — — — — — — — Bit 7~2 Unimplemented, read as “0” D9~D8: CTMn Counter High Byte Register bit 1~bit 0...
  • Page 67 HT45F6530 AC Voltage Regulator Flash MCU request flag, generated from a compare match occurs from Comparator P, will have no effect on the CTMn output pin. The way in which the CTMn output pin changes state are determined by the condition of the CTnIO1 and CTnIO0 bits in the CTMnC1 register. The CTMn output pin can be selected using the CTnIO1 and CTnIO0 bits to go high, to go low or to toggle from its present condition when a compare match occurs from Comparator A.
  • Page 68 HT45F6530 AC Voltage Regulator Flash MCU Counter Value CTnCCLR = 1; CTnM [1:0] = 00 CCRA = 0 CCRA > 0 Counter cleared by CCRA value Counter overflow 0x3FF CCRA=0 Resume CCRA Pause Stop Counter Restart CCRP Time CTnON CTnPAU...
  • Page 69 HT45F6530 AC Voltage Regulator Flash MCU Timer/Counter Mode To select this mode, bits CTnM1 and CTnM0 in the CTMnC1 register should be set to 11 respectively. The Timer/Counter Mode operates in an identical way to the Compare Match Output Mode generating the same interrupt flags. The exception is that in the Timer/Counter Mode the CTMn output pin is not used.
  • Page 70 HT45F6530 AC Voltage Regulator Flash MCU Counter Value CTnDPX = 0; CTnM [1:0] = 10 Counter cleared by CCRP Counter Reset when CTnON returns high CCRP Counter Stop if Pause Resume CTnON bit low CCRA Time CTnON CTnPAU CTnPOL CCRA Int. flag CTMnAF CCRP Int.
  • Page 71 HT45F6530 AC Voltage Regulator Flash MCU Counter Value CTnDPX = 1; CTnM [1:0] = 10 Counter cleared by CCRA Counter Reset when CTnON returns high CCRA Counter Stop if Pause Resume CTnON bit low CCRP Time CTnON CTnPAU CTnPOL CCRP Int. flag CTMnPF CCRA Int.
  • Page 72: Analog To Digital Converter

    HT45F6530 AC Voltage Regulator Flash MCU Analog to Digital Converter The need to interface to real world analog signals is a common requirement for many electronic systems. However, to properly process these signals by a microcontroller, they must first be converted into digital signals by A/D converters.
  • Page 73: A/D Converter Register Description

    HT45F6530 AC Voltage Regulator Flash MCU A/D Converter Register Description Overall operation of the A/D converter is controlled using several registers. A read only register pair exists to store the A/D converter data 12-bit value. The remaining three registers are control registers which setup the operating and control function of the A/D converter.
  • Page 74 HT45F6530 AC Voltage Regulator Flash MCU • SADC0 Register Name START ADBZ ADCEN ADRFS SACS3 SACS2 SACS1 SACS0 Bit 7 START: Start the A/D conversion 0→1→0: Start This bit is used to initiate an A/D conversion process. The bit is normally low but if set high and then cleared low again, the A/D converter will initiate a conversion process.
  • Page 75 HT45F6530 AC Voltage Regulator Flash MCU • SADC1 Register Name SAINS3 SAINS2 SAINS1 SAINS0 — SACKS2 SACKS1 SACKS0 — — Bit 7~4 SAINS3~SAINS0: A/D converter input signal select 0000: External source – External analog channel input, ANn 0001: Internal source – Internal A/D converter power supply voltage V 0010: Internal source –...
  • Page 76: A/D Converter Reference Voltage

    HT45F6530 AC Voltage Regulator Flash MCU SAVRS1~SAVRS0: A/D converter reference voltage select Bit 3~2 00: Internal A/D converter power, V 01: External VREF pin 1x: Internal PGA output voltage, V These bits are used to select the A/D converter reference voltage source. When the internal reference voltage source is selected, the reference voltage derived from the external VREF pin will automatically be switched off.
  • Page 77: A/D Converter Operation

    HT45F6530 AC Voltage Regulator Flash MCU A/D input as when the pin-shared function control bits enable an A/D input, the status of the port control register will be overridden. If the SAINS3~SAINS0 bits are set to “0000”, “0100”, or “1100~1111”, the external analog channel input is selected to be converted and the SACS3~SACS0 bits can determine which actual external channel is selected to be converted.
  • Page 78: Conversion Rate And Timing Diagram

    HT45F6530 AC Voltage Regulator Flash MCU than the maximum A/D clock period which may result in inaccurate A/D conversion values. Refer to the following table for examples, where values marked with an asterisk * show where special care must be taken, as the values may be exceeding the specified A/D Clock Period range.
  • Page 79: Summary Of A/D Conversion Steps

    HT45F6530 AC Voltage Regulator Flash MCU Summary of A/D Conversion Steps The following summarises the individual steps that should be executed in order to implement an A/D conversion process. • Step 1 Select the required A/D conversion clock by correctly programming bits SACKS2~SACKS0 in the SADC1 register.
  • Page 80: Programming Considerations

    HT45F6530 AC Voltage Regulator Flash MCU Programming Considerations During microcontroller operations where the A/D converter is not being used, the A/D internal circuitry can be switched off to reduce power consumption, by clearing bit ADCEN to 0 in the SADC0 register. When this happens, the internal A/D converter circuits will not consume power irrespective of what analog voltage is applied to their input lines.
  • Page 81 HT45F6530 AC Voltage Regulator Flash MCU mov a,0c0H ; setup PAS1 to configure pin AN0 mov PAS1 mov a,20h ; enable A/D converter, select default data format and connect AN0 ; channel to A/D converter mov SADC0,a start_conversion: clr START ; high pulse on start bit to initiate conversion set START ; reset A/D clr START ; start A/D polling_EOC: sz ADBZ ; poll the SADC0 register ADBZ bit to detect end of A/D conversion jmp polling_EOC ; continue polling mov a,SADOL ; read low byte conversion result value mov SADOL_buffer,a ; save result to user defined register mov a,SADOH ; read high byte conversion result value mov SADOH_buffer,a ; save result to user defined register jmp start_conversion ; start next A/D conversion Example: Using the interrupt method to detect the end of conversion clr ADE ;...
  • Page 82: Over Current Protection - Ocp

    HT45F6530 AC Voltage Regulator Flash MCU Over Current Protection – OCP The device includes two over current protection functions which provide a protection mechanism for applications. Each OCP function consists of one fully integrated Operational Amplifier and one Comparator as well as one 12-bit R2R D/A Converter with buffer. The Operational Amplifier can be used for signal amplification according to specific user requirements.
  • Page 83: Over Current Protection Registers

    HT45F6530 AC Voltage Regulator Flash MCU OnOFM OPnEN OPnOUT OPAnP OPAnO To A/D converter OPAnN OPnBW[1:0] OnOFM OnRSP S0 CnPOL CMPnO x: Don't care CMPnEN CMPnP CMPnO CNVTn[1:0] OCPn Interrupt CMPnN shot DACnVRS CnOFM CnRSP S3 VRnEXT x: Don't care...
  • Page 84 HT45F6530 AC Voltage Regulator Flash MCU Register Name DAnH — — — — DAnL DACnC DACnEN DACnVRS — — — — OPnC OPnOUT OPnEN — — — — OPnBW1 OPnBW0 OPnVOS OnOFM OnRSP OnOF5 OnOF4 OnOF3 OnOF2 OnOF1 OnOF0 CMPnC —...
  • Page 85 HT45F6530 AC Voltage Regulator Flash MCU When the switch S7 is on by setting this bit high, the operational amplifier n output signal will be internally connected to the comparator n positive input. Therefore the CMPnP pin function should be first switched off by properly configuring the relevant pin-shared control bits to avoid signal confliction.
  • Page 86 HT45F6530 AC Voltage Regulator Flash MCU OnOF5~OnOF0: OCP Operational Amplifier n input offset voltage calibration control Bit 5~0 bits These bits are used to calibrate the input offset according to the selected reference input when the OCP Operational Amplifier n is in the offset calibration mode.
  • Page 87: Offset Calibration Procedure

    HT45F6530 AC Voltage Regulator Flash MCU This bit is used to select the OCP Comparator n operating mode. If the bit is zero the OCP Comparator n will operate normally. The OCP Comparator n will enter the offset calibration mode if this bit is set high. Refer to the “Comparator Input Offset Calibration”...
  • Page 88: Low Voltage Detector - Lvd

    HT45F6530 AC Voltage Regulator Flash MCU Comparator Input Offset Calibration Step 1. Set CnOFM=1 and CnRSP=1, the OCP Comparator n will now operate in the comparator input offset calibration mode, S3 and S5 on. To make sure V as minimize as possible after calibration, the input reference voltage in calibration should be the same as input DC operating voltage in normal operation.
  • Page 89: Lvd Operation

    HT45F6530 AC Voltage Regulator Flash MCU LVDO: LVD Output Flag Bit 5 0: No Low Voltage Detect 1: Low Voltage Detect LVDEN: Low Voltage Detector Control Bit 4 0: Disable 1: Enable Bit 3 VBGEN: Bandgap Buffer Control 0: Disable...
  • Page 90: Interrupts

    HT45F6530 AC Voltage Regulator Flash MCU Interrupts Interrupts are an important part of any microcontroller system. When an external event or an internal function such as a Timer Module or an A/D converter requires microcontroller attention, their corresponding interrupt will enforce a temporary suspension of the main program allowing the microcontroller to direct attention to their respective needs.
  • Page 91 HT45F6530 AC Voltage Regulator Flash MCU • INTEG Register Name — — — — INT1S1 INT1S0 INT0S1 INT0S0 — — — — — — — — Bit 7~4 Unimplemented, read as “0” INT1S1~INT1S0: Interrupt edge control for INT1 pin Bit 3~2...
  • Page 92 HT45F6530 AC Voltage Regulator Flash MCU • INTC1 Register Name TB1F TB0F MF1F MF0F TB1E TB0E MF1E MF0E Bit 7 TB1F: Time Base 1 request flag 0: No request 1: Interrupt request Bit 6 TB0F: Time Base 0 request flag...
  • Page 93 HT45F6530 AC Voltage Regulator Flash MCU INT1E: INT1 interrupt control Bit 2 0: Disable 1: Enable DEE: Data EEPROM interrupt control Bit 1 0: Disable 1: Enable Bit 0 ADE: A/D Converter interrupt control 0: Disable 1: Enable • MFI0 Register Name —...
  • Page 94: Interrupt Operation

    HT45F6530 AC Voltage Regulator Flash MCU Interrupt Operation When the conditions for an interrupt event occur, such as a TM Comparator P or Comparator A match or A/D conversion completion etc., the relevant interrupt request flag will be set. Whether the request flag actually generates a program jump to the relevant interrupt vector is determined by the condition of the interrupt enable bit.
  • Page 95: Over Current Protection Interrupts

    HT45F6530 AC Voltage Regulator Flash MCU EMI auto disabled in ISR Legend Interrupt Request Enable Master Vector Priority Request Flag, no auto reset in ISR Name Flags Bits Enable High Request Flag, auto reset in ISR OCP0 Pin OCP0F OCP0E...
  • Page 96: Multi-Function Interrupts

    HT45F6530 AC Voltage Regulator Flash MCU automatically cleared to disable other interrupts. Note that any pull-high resistor selections on the external interrupt pins will remain valid even if the pin is used as an external interrupt input. The INTEG register is used to select the type of active edge that will trigger the external interrupt.
  • Page 97 HT45F6530 AC Voltage Regulator Flash MCU • PSCR Register Name — — — — — — CLKSEL1 CLKSEL0 — — — — — — — — — — — — Bit 7~2 Unimplemented, read as “0” CLKSEL1~CLKSEL0: Prescaler clock source selection...
  • Page 98: A/D Converter Interrupt

    HT45F6530 AC Voltage Regulator Flash MCU A/D Converter Interrupt An A/D Converter Interrupt request will take place when the A/D Converter Interrupt request flag, ADF, is set, which occurs when the A/D conversion process finishes. To allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, EMI, and A/D Interrupt enable bit, ADE, must first be set.
  • Page 99: Interrupt Wake-Up Function

    HT45F6530 AC Voltage Regulator Flash MCU Interrupt Wake-up Function Each of the interrupt functions has the capability of waking up the microcontroller when in the SLEEP or IDLE Mode. A wake-up is generated when an interrupt request flag changes from low to high and is independent of whether the interrupt is enabled or not.
  • Page 100: Application Description

    AC zero crossing points to avoid relay damage. This Holtek AVR dedicated MCU provides full control signals for all of the above functions, the details of which are described in the following sections.
  • Page 101: Hardware Block Diagram

    Cxxxxxx-A1:耳機收納盒demo 方塊圖原始頁面 HT45F6530 AC Voltage Regulator Flash MCU Analog/Power Wireless ASIC/Memory Non Holtek/Others Hardware Block Diagram Transformer Zero Cross V Sense Relay Array Micro Controller Tact Switch (MCU) Thermistor Note: 1. The AC input is converted into AC 12V through a transformer after which the converted voltage is rectified and regulated to provide an operating voltage for the relays and the MCU.
  • Page 102: Instruction Set

    In the case of Holtek microcontroller, a comprehensive and flexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of programming overheads.
  • Page 103: Logical And Rotate Operation

    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 programming steps.
  • Page 104: Instruction Set Summary

    HT45F6530 AC Voltage Regulator Flash MCU Instruction Set Summary The following table depicts a summary of the instruction set categorised according to function and can be consulted as a basic instruction reference using the following listed conventions. Table Conventions x: Bits immediate data...
  • Page 105 HT45F6530 AC Voltage Regulator Flash MCU Mnemonic Description Cycles Flag Affected Data Move MOV A,[m] Move Data Memory to ACC None MOV [m],A Move ACC to Data Memory Note None MOV A,x Move immediate data to ACC None Bit Operation CLR [m].i...
  • Page 106: Instruction Definition

    HT45F6530 AC Voltage Regulator Flash MCU Instruction Definition Add Data Memory to ACC with Carry ADC A,[m] Description The contents of the specified Data Memory, Accumulator and the carry flag are added. The result is stored in the Accumulator. Operation ACC ←...
  • Page 107 HT45F6530 AC Voltage Regulator Flash MCU CALL addr Subroutine call Description Unconditionally calls a subroutine at the specified address. The Program Counter then increments by 1 to obtain the address of the next instruction which is then pushed onto the stack.
  • Page 108 HT45F6530 AC Voltage Regulator Flash MCU CPLA [m] Complement Data Memory with result in ACC Description Each bit of the specified Data Memory is logically complemented (1′s complement). Bits which previously contained a 1 are changed to 0 and vice versa. The complemented result is stored in the Accumulator and the contents of the Data Memory remain unchanged.
  • Page 109 HT45F6530 AC Voltage Regulator Flash MCU JMP addr Jump unconditionally Description The contents of the Program Counter are replaced with the specified address. Program execution then continues from this new address. As this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction.
  • Page 110 HT45F6530 AC Voltage Regulator Flash MCU RET A,x Return from subroutine and load immediate data to ACC Description The Program Counter is restored from the stack and the Accumulator loaded with the specified immediate data. Program execution continues at the restored address.
  • Page 111 HT45F6530 AC Voltage Regulator Flash MCU RRA [m] Rotate Data Memory right with result in ACC Description Data in the specified Data Memory is rotated right by 1 bit with bit 0 rotated into bit 7. The rotated result is stored in the Accumulator and the contents of the Data Memory remain unchanged.
  • Page 112 HT45F6530 AC Voltage Regulator Flash MCU 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 113 HT45F6530 AC Voltage Regulator Flash MCU SUBM A,[m] Subtract Data Memory from ACC with result in Data Memory Description The specified Data Memory is subtracted from the contents of the Accumulator. The result is stored in the Data Memory. Note that if the result of subtraction is negative, the C flag will be cleared to 0, otherwise if the result is positive or zero, the C flag will be set to 1.
  • Page 114 HT45F6530 AC Voltage Regulator Flash MCU TABRD [m] Read table (specific page) to TBLH and Data Memory Description The low byte of the program code (specific page) addressed by the table pointer pair (TBHP and TBLP) is moved to the specified Data Memory and the high byte moved to TBLH.
  • Page 115: Package Information

    HT45F6530 AC Voltage Regulator Flash MCU Package Information Note that the package information provided here is for consultation purposes only. As this information may be updated at regular intervals users are reminded to consult the Holtek website the latest version of the Package/Carton Information.
  • Page 116: 20-Pin Nsop (150Mil) Outline Dimensions

    HT45F6530 AC Voltage Regulator Flash MCU 20-pin NSOP (150mil) Outline Dimensions Dimensions in inch Symbol Min. Nom. Max. 0.228 0.236 0.244 0.146 0.154 0.161 0.009 — 0.012 C’ 0.382 0.390 0.398 — — 0.069 — 0.032 BSC — 0.002 —...
  • Page 117: 24-Pin Sop (300Mil) Outline Dimensions

    HT45F6530 AC Voltage Regulator Flash MCU 24-pin SOP (300mil) Outline Dimensions " Dimensions in inch Symbol Min. Nom. Max. — 0.406 BSC — — 0.295 BSC — 0.012 — 0.020 C’ — 0.606 BSC — — — 0.104 — 0.050 BSC —...
  • Page 118: 24-Pin Ssop (150Mil) Outline Dimensions

    HT45F6530 AC Voltage Regulator Flash MCU 24-pin SSOP (150mil) Outline Dimensions " Dimensions in inch Symbol Min. Nom. Max. — 0.236 BSC — — 0.154 BSC — 0.008 — 0.012 C’ — 0.341 BSC — — — 0.069 — 0.025 BSC —...
  • Page 119 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.

Table of Contents