The HT45F6530 device is a Flash Memory A/D type 8-bit high performance RISC architecture
microcontroller, specically 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. These and other
calibration parameters can be stored using the internal true EEPROM. In being able to implement all
the important AVR functions the device is able to reduce the external component requirements and
reduce the product PCB area.
Offering users the convenience of Flash Memory multi-programming features, this device also
includes a wide range of functions and features. Other memory includes an area of RAM Data
Memory as well as an area of true EEPROM memory for storage of non-volatile data such as serial
numbers, calibration data etc.
Analog features include a multi-channel A/D converter function. Multiple extremely exible Timer
Modules provide timing, pulse generation and PWM generation functions. Protective features such
as an internal Watchdog Timer, Low Voltage Reset and Low Voltage Detector coupled with excellent
noise immunity and ESD protection ensure that reliable operation is maintained in hostile electrical
environments.
The device also includes fully integrated high and low speed oscillators which require no external
components for their implementation. The ability to operate and switch dynamically between a range
of operating modes using different clock sources gives users the ability to optimise microcontroller
operation and minimise power consumption.
Two over current protection circuits integrated in the device can be used to monitor the voltage
changes between input and output AC. Each OCP circuit contains an independent 12-bit D/A
converter, operational amplier and comparator. The input and output voltages can be respectively
measured by internally connecting to the 12-bit A/D converter. By using the internal comparator
and D/A converter an AC zero crossing interrupt trigger function can be implemented. By using
the internal timer a relay action delay time can be implemented. For more detailed application
development information, refer to the application description section or the Power Bank application
solutions on the Holtek website.
The inclusion of exible I/O programming features, Time-Base functions along with many other
features ensure that the device will nd excellent use in applications such as AC voltage regulators
in addition to many others.
Block Diagram
HT45F6530
AC Voltage Regulator Flash MCU
INT0~
INT1
Pin-Shared
With Port A
VDD
: Bus Entry: Pin-Shared Node
Interrupt
Controller
Reset
Circuit
Time
Bases
V
DD
VssVSS
Pin Assignment
ROM
2K × 15
EEPROM
32 × 8
Watchdog
Timer
LIRC
32kHz
HIRC
8MHz
HT8 MCU Core
SYSCLK
Clock System
RAM
128 × 8
Stack
4-Level
LVD/LVR
Bus
M
U
X
PB6/CMP1P
PC2/OPA1P
PC3/OPA1N
PC4/OPA0P
PC5/OPA0N
PC1/BUF_OUT0
PB0/BUF_OUT1
PB7/CMP1O/CTCK1
PA2/CTP1/VR0EXT/OCDSCK/ICPCK
PA0/CTP0/VR1EXT/INT0/OCDSDA/ICPDA
Timers
I/O
Digital Peripherals
PGA
+
CMP
_
Analog Peripherals
1
2
3
4
5
6
7
8
9
10
20 NSOP-A
M
U
X
20
19
18
17
16
15
14
13
12
11
12-bit
ADC
Analog to Digital
Converter
2 Over Current
Protection Circuits
HT45F6530/HT45V6530
Pin-Shared
Function
1.04V
V
DD
V
DD
VDD/2
V
/4
DD
V
R
VR/2
V
/4
R
+
OPA
_
12-bit
DAC
PB3/CMP0P
PB2/OPA0O
PB1/OPA1O
VDD
VSS
PA7/AN0
PA6/AN1
PA5/AN2
PA4/AN3/INT1
PA1/AN5/VREF
Port A
Driver
Port B
Driver
Port C
Driver
Pin-Shared
With Port A
Pin-Shared
With Port C
VREFI
VREF
AN0~
AN5
OPA0P~
OPA1P
OPA0N~
OPA1N
PA0~PA7
PB0~PB7
PC0~PC5
PB6/CMP1P
PB5/CMP1N/CTP1B
PC2/OPA1P
PC3/OPA1N
PC4/OPA0P
PC5/OPA0N
PC1/BUF_OUT0
PB0/BUF_OUT1
PB7/CMP1O/CTCK1
PC0/CMP0O/CTCK0
PA2/CTP1/VR0EXT/OCDSCK/ICPCK
PA0/CTP0/VR1EXT/INT0/OCDSDA/ICPDAPA1/AN5/VREF
1
2
3
4
5
6
7
8
9
10
11
12
HT45F6530/HT45V6530
24 SOP-A/24 SSOP-A
PB3/CMP0P
24
PB4/CMP0N/CTP0B
23
PB2/OPA0O
22
PB1/OPA1O
21
VDD
20
VSS
19
PA7/AN0
18
PA6/AN1
17
PA5/AN2
16
PA4/AN3/INT1
15
PA3/AN4/VREFI
14
13
Note: 1. If the pin-shared pin functions have multiple outputs simultaneously, the desired pin-shared
function is determined by the corresponding software control bits.
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
congured to avoid unwanted current consumption resulting from oating input conditions.
Refer to the “Standby Current Considerations” and “Input/Output Ports” sections.
OPT: Optional by register option; PWR: Power;
ST: Schmitt Trigger input; CMOS: CMOS output;
AN: Analog signal.
Absolute Maximum Ratings
Supply Voltage ...................................................................................................VSS-0.3V to VSS+6.0V
Input Voltage .....................................................................................................VSS-0.3V to VDD+0.3V
Storage Temperature ......................................................................................................-50˚C to 125˚C
Operating Temperature ....................................................................................................-40˚C to 85˚C
IOH Total ......................................................................................................................................-80mA
IOL Total ....................................................................................................................................... 80mA
Total Power Dissipation ........................................................................................................... 500mW
Note: These are stress ratings only. Stresses exceeding the range specified under “Absolute
Maximum Ratings” may cause substantial damage to the device. Functional operation of the
device at other conditions beyond those listed in the specication is not implied and prolonged
exposure to extreme conditions may affect device reliability.
D.C. Characteristics
For data in the following tables, note that factors such as oscillator type, operating voltage, operating
frequency, pin load conditions, temperature and program instruction type, etc., can all exert an
inuence on the measured values.
Operating Voltage Characteristics
Ta=-40˚C~85˚C
SymbolParameterTest ConditionsMin.Typ.Max.Unit
V
DD
Operating Voltage – HIRCf
Operating Voltage – LIRCf
Operating Current Characteristics
SymbolOperating Mode
SLOW Mode – LIRC
I
DD
FAST Mode – HIRC
Note: When using the characteristic table data, the following notes should be taken into consideration:
1. Any digital inputs are setup in a non-oating condition.
2. All measurements are taken under conditions of no load and with all peripherals in an off state.
3. There are no DC current paths.
4. All Operating Current values are measured using a continuous NOP instruction program loop.
V
2.2V
2.2V
=8MHz2.2—5.5V
SYS=fHIRC
=32kHz2.2—5.5V
SYS=fLIRC
Test Conditions
f
SYS
f
SYS
Conditions
=32kHz
=8MHz
DD
5V—3050
5V—1.62.4
Min.Typ.Max.Unit
—816
—0.61.0
Ta=25˚C
μA3V—1020
mA3V—0.81.2
HT45F6530
AC Voltage Regulator Flash MCU
Standby Current Characteristics
Ta=25˚C, unless otherwise specied
SymbolStandby Mode
SLEEP Mode
I
STB
IDLE0 Mode – LIRC
IDLE1 Mode – HIRC
V
2.2V
2.2V
2.2V
2.2V
Note: When using the characteristic table data, the following notes should be taken into consideration:
1. Any digital inputs are setup in a non-oating condition.
2. All measurements are taken under conditions of no load and with all peripherals in an off state.
3. There are no DC current paths.
4. All Standby Current values are taken after a HALT instruction execution thus stopping all instruction
execution.
Test Conditions
SUB
SUB
on
on, f
Conditions
=8MHz
SYS
DD
WDT off
5V—0.51.01.2
WDT on
5V—3.05.06.0
f
5V—5.01012
f
5V—600800960
Min. Typ.Max.
—0.20.60.7
—1.22.42.9
—2.44.04.8
—288400480
@85˚C
Max.
Unit
μA3V—0.20.81.0
μA3V—1.53.03.6
μA3V—3.05.06.0
μA3V—360500600
A.C. Characteristics
For data in the following tables, note that factors such as oscillator type, operating voltage, operating
frequency and temperature etc., can all exert an inuence on the measured values.
High Speed Internal Oscillator – HIRC – Frequency Accuracy
During the program writing operation the writer will trim the HIRC oscillator at a user selected
HIRC frequency and user selected voltage of either 3V or 5V.
SymbolParameter
f
HIRC
8MHz Writer Trimmed HIRC Frequency
Note: 1. The 3V/5V values for VDD are provided as these are the xed voltage at which the HIRC frequency is
trimmed by the writer.
2. The row below the 3V/5V trim voltage row is provided to show the values for the full VDD range operating
voltage. It is recommended that the trim voltage is xed at 3V for application voltage ranges from 2.2V
to 3.6V and xed at 5V for application voltage ranges from 3.3V to 5.5V.
3. The minimum and maximum tolerance values provided in the table are only for the frequency at which
the writer trims the HIRC oscillator.
address of the last page within the 2K Program Memory of the microcontroller. The table pointer low
byte register is setup here to have an initial value of “06H”. This will ensure that the rst data read
from the data table will be at the Program Memory address “0706H” or 6 locations after the start of
the last page. Note that the value for the table pointer is referenced to the rst address of the present
page if the “TABRDC [m]” instruction is being used. The high byte of the table data which in this
case is equal to zero will be transferred to the TBLH register automatically when the “TABRDL [m]”
instruction is executed.
Because the TBLH register is a read-only register and cannot be restored, care should be taken
to ensure its protection if both the main routine and Interrupt Service Routine use table read
instructions. If using the table read instructions, the Interrupt Service Routines may change the
value of the TBLH and subsequently cause errors if used again by the main routine. As a rule it is
recommended that simultaneous use of the table read instructions should be avoided. However, in
situations where simultaneous use cannot be avoided, the interrupts should be disabled prior to the
execution of any main routine table-read instructions. Note that all table related instructions require
two instruction cycles to complete their operation.
Table Read Program Example
tempreg1 db ? ; temporary register #1
tempreg2 db ? ; temporary register #2
:
mov a,06h ; initialize table pointer - note that this address is referenced
mov tblp,a ; to the last page or present page
:
tabrdl tempreg1 ; transfers value in table referenced by table pointer to tempreg1
; data at program memory address “0706H” transferred to
; tempreg1 and TBLH
dec tblp ; reduce value of table pointer by one
tabrdl tempreg2 ; transfers value in table referenced by table pointer to tempreg2
; data at program memory address “0705H” transferred to
; tempreg2 and TBLH
; in this example the data “1AH” is transferred to
; tempreg1 and data “0FH” to register tempreg2
; the value “00H” will be transferred to the high byte
; register TBLH
:
org 0700h ; sets initial address of last page
dc 00Ah, 00Bh, 00Ch, 00Dh, 00Eh, 00Fh, 01Ah, 01Bh
:
In Circuit Programming – ICP
The provision of Flash type Program Memory provides the user with a means of convenient and
easy upgrades and modications 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. This enables product manufacturers to easily
keep their manufactured products supplied with the latest program releases without removal and re-
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. By incorporating this kind of data memory, a whole new host of application possibilities
are made available to the designer. The availability of EEPROM storage allows information such
as product identication numbers, calibration values, specic user data, system setup data or other
product information to be stored directly within the product microcontroller. The process of reading
and writing data to the EEPROM memory has been reduced to a very trivial affair.
EEPROM Data Memory Structure
The EEPROM Data Memory capacity is 32×8 bits for the device. Unlike the Program Memory and
RAM Data Memory, the EEPROM Data Memory is not directly mapped into memory space and
is therefore not directly addressable in the same way as the other types of memory. Read and Write
operations to the EEPROM are carried out in single byte operations using an address and a data
register in Bank 0 and a single control register in Bank 1.
EEPROM Registers
Three registers control the overall operation of the internal EEPROM Data Memory. These are the
address registers, EEA, the data register, EED and a single control register, EEC. As both the EEA
and EED registers are located in Bank 0, they can be directly accessed in the same way as any other
Special Function Register. The EEC register however, being located in Bank1, cannot be directly
addressed directly and can only be read from or written to indirectly using the MP1 Memory Pointer
and Indirect Addressing Register, IAR1. Because the EEC control register is located at address 40H
in Bank 1, the MP1 Memory Pointer must rst be set to the value 40H and the Bank Pointer register,
BP, set to the value, 01H, before any operations on the EEC register are executed.
Register
Name
EEA———EEA4EEA3EEA2EEA1EEA0
EEDD7D6D5D4D3D2D1D0
EEC————WRENWRRDENRD
76543210
Bit
EEPROM Register List
• EEA Register
Bit76543210
Name———EEA4EEA3EEA2EEA1EEA0
R/W———R/WR/WR/WR/WR/W
POR———00000
Bit 7~5 Unimplemented, read as “0”
Bit 4~0 EEA4~EEA0: Data EEPROM address bit 4~bit 0
• EED Register
Bit76543210
NameD7D6D5D4D3D2D1D0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR00000000
Bit 7~0 D7~D0: Data EEPROM data bit 7~bit 0
HT45F6530
AC Voltage Regulator Flash MCU
• EEC Register
Bit76543210
Name————WRENWRRDENRD
R/W————R/WR/WR/WR/W
POR————0000
Bit 7~4 Unimplemented, read as “0”
Bit 3 WREN: Data EEPROM Write Enable
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. Clearing this bit to zero will inhibit Data
EEPROM write operations.
Bit 2 WR: EEPROM Write Control
0: Write cycle has nished
1: Activate a write cycle
This is the Data EEPROM Write Control Bit and when set high by the application
program will activate a write cycle. This bit will be automatically reset to zero by the
hardware after the write cycle has nished. Setting this bit high will have no effect if
the WREN has not rst been set high.
Bit 1 RDEN: Data EEPROM Read Enable
0: Disable
1: Enable
This is the Data EEPROM Read Enable Bit which must be set high before Data
EEPROM read operations are carried out. Clearing this bit to zero will inhibit Data
EEPROM read operations.
Bit 0 RD: EEPROM Read Control
0: Read cycle has nished
1: Activate a read cycle
This is the Data EEPROM Read Control Bit and when set high by the application
program will activate a read cycle. This bit will be automatically reset to zero by the
hardware after the read cycle has nished. Setting this bit high will have no effect if
the RDEN has not rst been set high.
Note: 1. The WREN, WR, RDEN and RD cannot be set high at the same time in one instruction. The
WR and RD cannot be set high at the same time.
2. Ensure that the f
3. Ensure that the write operation is totally complete before changing the EEC register content.
clock is stable before executing the write operation.
SUB
Reading Data from the EEPROM
To read data from the EEPROM, the read enable bit, RDEN, in the EEC register must rst be set
high to enable the read function. The EEPROM address of the data to be read must then be placed
in the EEA register. If the RD bit in the EEC register is now set high, a read cycle will be initiated.
Setting the RD bit high will not initiate a read operation if the RDEN bit has not been set. When
the read cycle terminates, the RD bit will be automatically cleared to zero, after which the data can
be read from the EED register. The data will remain in the EED register until another read or write
operation is executed. The application program can poll the RD bit to determine when the data is
These three bits are used to select which clock is used as the system clock source. In
addition to the system clock source directly derived from fH or f
of the high speed system oscillator can also be chosen as the system clock source.
Bit 4~2 Unimplemented, read as “0”
Bit 1 FHIDEN: High frequency oscillator control when CPU is switched off
0: Disable
1: Enable
This bit is used to control whether the high speed oscillator is activated or stopped
when the CPU is switched off by executing an “HALT” instruction.
Bit 0 FSIDEN: Low frequency oscillator control when CPU is switched off
0: Disable
1: Enable
This bit is used to control whether the low speed oscillator is activated or stopped
when the CPU is switched off by executing an “HALT” instruction.
, a divided version
SUB
• HIRCC Register
Bit76543210
Name——————HIRCFHIRCEN
R/W——————RR/W
POR——————01
Bit 7~2 Unimplemented, read as “0”
Bit 1 HIRCF: HIRC oscillator stable ag
0: HIRC unstable
1: HIRC stable
This bit is used to indicate whether the HIRC oscillator is stable or not. When the
HIRCEN bit is set to 1 to enable the HIRC oscillator, the HIRCF bit will first be
cleared to 0 and then set to 1 after the HIRC oscillator is stable.
Bit 0 HIRCEN: HIRC oscillator enable control
0: Disable
1: Enable
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.
In simple terms, Mode Switching between the FAST Mode and SLOW Mode is executed using the
CKS2~CKS0 bits in the SCC register while Mode Switching from the FAST/SLOW Modes to the
SLEEP/IDLE Modes is executed via the HALT instruction. When a HALT instruction is executed,
whether the device enters the IDLE Mode or the SLEEP Mode is determined by the condition of the
FHIDEN and FSIDEN bits in the SCC register.
HT45F6530
AC Voltage Regulator Flash MCU
SLEEP
HALT instruction executed
CPU stop
FHIDEN=0
FSIDEN=0
off
f
H
off
f
SUB
FAST
f
SYS=fH~fH
fHon
/64
CPU run
f
on
SYS
f
on
SUB
HALT instruction executed
IDLE2
CPU stop
FHIDEN=1
FSIDEN=0
on
f
H
off
f
SUB
SLOW
f
SYS=fSUB
f
on
SUB
CPU run
f
on
SYS
fHon/off
HALT instruction executed
IDLE1
CPU stop
FHIDEN=1
FSIDEN=1
on
f
H
on
f
SUB
HALT instruction executed
IDLE0
CPU stop
FHIDEN=0
FSIDEN=1
off
f
H
on
f
SUB
FAST Mode to SLOW Mode Switching
When running in the FAST Mode, which uses the high speed system oscillator, and therefore
consumes more power, the system clock can switch to run in the SLOW Mode by set the
CKS2~CKS0 bits to “111” in the SCC register. This will then use the low speed system oscillator
which will consume less power. Users may decide to do this for certain operations which do not
require high performance and can subsequently reduce power consumption.
The SLOW Mode is sourced from the LIRC oscillator and therefore requires this oscillator to be
• 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 ag PDF will be set, and WDT timeout ag TO will be
cleared.
• The WDT will be cleared and resume counting if the WDT function is enabled. If the WDT
function is disabled, the WDT will be cleared and stopped.
Standby Current Considerations
As the main reason for entering the SLEEP or IDLE Mode is to keep the current consumption of the
device to as low a value as possible, perhaps only in the order of several micro-amps except in the
IDLE1 and IDLE2 Mode, there are other considerations which must also be taken into account by
the circuit designer if the power consumption is to be minimised. Special attention must be made
to the I/O pins on the device. All high-impedance input pins must be connected to either a xed
high or low level as any oating input pins could create internal oscillations and result in increased
current consumption. This also applies to the device which has different package types, as there may
be unbonded pins. These must either be setup as outputs or if setup as inputs must have pull-high
resistors connected.
Care must also be taken with the loads, which are connected to I/O pins, which are setup as outputs.
These should be placed in a condition in which minimum current is drawn or connected only to
external circuits that do not draw current, such as other CMOS inputs. Also note that additional
standby current will also be required if the LIRC oscillator has enabled.
In the IDLE1 and IDLE2 Mode the high speed oscillator is on, if the peripheral function clock
source is derived from the high speed oscillator, the additional standby current will also be perhaps
in the order of several hundred micro-amps.
Wake-up
To minimise power consumption the device can enter the SLEEP or any IDLE Mode, where the
CPU will be switched off. However, when the device is woken up again, it will take a considerable
time for the original system oscillator to restart, stabilise and allow normal operation to resume.
After the system enters the SLEEP or IDLE Mode, it can be woken up from one of various sources
listed as follows:
• An external falling edge on Port A
• A system interrupt
• A WDT overow
When the device executes the “HALT” instruction, the PDF ag will be set to 1. The PDF ag will
be cleared to 0 if the device experiences a system power-up or executes the clear Watchdog Timer
instruction. If the system is woken up by a WDT overow, a Watchdog Timer reset will be initiated
and the TO ag will be set to 1. The TO ag is set if a WDT time-out occurs and causes a wake-up
that only resets the Program Counter and Stack Pointer, other ags remain in their original status.
Each pin on Port A can be setup using the PAWU register to permit a negative transition on the
pin to wake-up the system. When a pin wake-up occurs, the program will resume execution at the
instruction following the “HALT” instruction. If the system is woken up by an interrupt, then two
possible situations may occur. The first is where the related interrupt is disabled or the interrupt
is enabled but the stack is full, in which case the program will resume execution at the instruction
following the “HALT” instruction. In this situation, the interrupt which woke-up the device will not
be immediately serviced, but will rather be serviced later when the related interrupt is nally enabled
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.
Watchdog Timer
The Watchdog Timer is provided to prevent program malfunctions or sequences from jumping to
unknown locations, due to certain uncontrollable external events such as electrical noise.
Watchdog Timer Clock Source
The Watchdog Timer clock source is provided by the internal clock, f
the LIRC oscillator. The LIRC internal oscillator has an approximate frequency of 32kHz and this
specied internal clock period can vary with VDD, temperature and process variations. The Watchdog
Timer source clock is then subdivided by a ratio of 28 to 215 to give longer timeouts, the actual value
being chosen using the WS2~WS0 bits in the WDTC register.
Watchdog Timer Control Register
A single register, WDTC, controls the required time-out period as well as the enable/disable and
reset MCU operation.
HT45F6530
AC Voltage Regulator Flash MCU
which is sourced from
LIRC
• WDTC Register
Bit76543210
NameWE4WE3WE2WE1WE0WS2WS1WS0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR01010011
Bit 7~3 WE4~WE0: WDT function control
10101: Disable
01010: Enable
Other values: Reset MCU
When these bits are changed to any other values due to environmental noise the
microcontroller will be reset; this reset operation will be activated after a delay time,
t
, and the WRF bit in the RSTFC register will be set high.
This bit is set high by the WDTC register software reset and cleared by the application
program. Note that this bit can only be cleared to 0 by the application program.
Watchdog Timer Operation
The Watchdog Timer operates by providing a device reset when its timer overows. This means
that in the application program and during normal operation the user has to strategically clear the
Watchdog Timer before it overows to prevent the Watchdog Timer from executing a reset. This is
done using the clear watchdog instruction. If the program malfunctions for whatever reason, jumps
to an unknown location, or enters an endless loop, the clear instruction will not be executed in the
correct manner, in which case the Watchdog Timer will overow and reset the device. There are ve
bits, WE4~WE0, in the WDTC register to offer the enable/disable control and reset control of the
Watchdog Timer. The WDT function will be disabled when the WE4~WE0 bits are set to a value of
10101B while the WDT function will be enabled if the WE4~WE0 bits are equal to 01010B. If the
WE4~WE0 bits are set to any other values, other than 01010B and 10101B, it will reset the device
after a delay time, t
. After power on these bits will have a value of 01010B.
SRESET
WE4~WE0 BitsWDT Function
10101BDisable
01010BEnable
Any other valueReset MCU
Watchdog Timer Enable/Disable Control
“x”: unknown
Under normal program operation, a Watchdog Timer time-out will initialise a device reset and set
the status bit TO. However, if the system is in the SLEEP or IDLE Mode, when a Watchdog Timer
time-out occurs, the TO bit in the STATUS register will be set and only the Program Counter and
Stack Pointer will be reset. Three methods can be adopted to clear the contents of the Watchdog
Timer. The rst is a WDTC register software reset, which means a certain value except 01010B and
10101B written into the WE4~WE0 bits, the second is using the Watchdog Timer software clear
instruction and the third is via a HALT instruction.
There is only one method of using software instruction to clear the Watchdog Timer. That is to use
the single “CLR WDT” instruction to clear the WDT.
The maximum time-out period is when the 215 division ratio is selected. As an example, with a
32kHz LIRC oscillator as its source clock, this will give a maximum watchdog period of around 1
second for the 215 division ratio, and a minimum timeout of 8ms for the 28 division ration.
AC Voltage Regulator Flash MCU
WE4~WE0 bitsWDTC RegisterReset MCU
HT45F6530
“CLR WDT” Instruction
“HALT” Instruction
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. The most important reset
condition is after power is rst applied to the microcontroller. In this case, internal circuitry will
ensure that the microcontroller, after a short delay, will be in a well-defined state and ready to
execute the rst program instruction. After this power-on reset, certain important internal registers
will be set to dened states before the program commences. One of these registers is the Program
Counter, which will be reset to zero forcing the microcontroller to begin program execution from the
lowest Program Memory address.
In addition to the power-on reset, another reset exists in the form of a Low Voltage Reset, LVR,
where a full reset is implemented in situations where the power supply voltage falls below a
certain threshold. 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.
CLR
f
LIRC8-stage DividerWDT Prescaler
LIRC
f
LIRC
8
/2
8-to-1 MUXWS2~WS0
Watchdog Timer
WDT Time-out
8
/f
~215/f
(2
LIRC
LIRC
)
Reset Functions
There are several ways in which a microcontroller reset can occur, through events occurring
internally:
Power-on Reset
The most fundamental and unavoidable reset is the one that occurs after power is rst applied to
the microcontroller. As well as ensuring that the Program Memory begins execution from the rst
memory address, a power-on reset also ensures that certain other registers are preset to known
conditions. All the I/O port and port control registers will power up in a high condition ensuring that
Holtek microcontrollers offer considerable exibility 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.
The device provides bidirectional input/output lines labeled with port names PA~PC. These I/O
ports are mapped to the RAM Data Memory with specic addresses as shown in the Special Purpose
Data Memory table. All of these I/O ports can be used for input and output operations. For input
operation, these ports are non-latching, which means the inputs must be ready at the T2 rising edge
of instruction “MOV A, [m]”, where m denotes the port address. For output operation, all the data is
latched and remains unchanged until the output latch is rewritten.
Register
Name
PAPA 7PA6PA5PA4PA 3PA2PA1PA0
PACPAC7PAC6PAC5PAC4PAC3PAC2PAC1PAC0
PAPUPAPU7PAPU6PAPU5PAPU4PAPU3PAPU2PAPU1PAPU0
PAWUPAWU7PAWU6PAWU5PAWU4PAWU3PAWU2PAWU1PAWU0
PBPB7PB6PB5PB4PB3PB2PB1PB0
PBCPBC7PBC6PBC5PBC4PBC3PBC2PBC1PBC0
PBPUPBPU7PBPU6PBPU5PBPU4PBPU3PBPU2PBPU1PBPU0
PC——PC5PC4PC3PC2PC1PC0
PCC——PCC5PCC4PCC3PCC2PCC1PCC0
PCPU——PCPU5PCPU4PCPU3PCPU2PCPU1PCPU0
76543210
I/O Logic Function Register List
Bit
“—”: Unimplemented, read as “0”
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
congured as a digital input have the capability of being connected to an internal pull-high resistor.
These pull-high resistors are selected using registers, namely PAPU~PCPU, and are implemented
using weak PMOS transistors.
Note that the pull-high resistor can be controlled by the relevant pull-high control register only when
the pin-shared functional pin is selected as a digital input or NMOS output. Otherwise, the pull-high
resistors cannot be enabled.
• PxPU Register
Bit76543210
NamePxPU7PxPU6PxPU5PxPU4PxPU3PxPU2PxPU1PxPU0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR00000000
PxPUn: I/O Port x Pin pull-high function control
0: Disable
1: Enable
The PxPUn bit is used to control the pin pull-high function. Here the “x” can be A, B or C.
However, the actual available bits for each I/O Port may be different.
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. This function is especially suitable for applications that can be woken up
via external switches. Each pin on Port A can be selected individually to have this wake-up feature
using the PAWU register.
Note that the wake-up function can be controlled by the wake-up control registers only when the
pin-shared functional pin is selected as a general purpose input and the MCU enters the IDLE or
SLEEP mode.
• PAWU Register
Bit76543210
NamePAWU7PAWU6PAWU5PAWU4PAWU3PAWU2PAWU1PAWU0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR00000000
Bit 7~0 PAWU7~PAWU0: PA7~PA0 wake-up function control
HT45F6530
AC Voltage Regulator Flash MCU
0: Disable
1: Enable
I/O Port Control Registers
Each I/O port has its own control register known as PAC~PCC, to control the input/output
configuration. With this control register, each CMOS output or input can be reconfigured
dynamically under software control. Each pin of the I/O ports is directly mapped to a bit in its
associated port control register. For the I/O pin to function as an input, the corresponding bit of the
control register must be written as a “1”. This will then allow the logic state of the input pin to be
directly read by instructions. When the corresponding bit of the control register is written as a “0”,
the I/O pin will be setup as a CMOS output. If the pin is currently setup as an output, instructions
can still be used to read the output register. However, it should be noted that the program will in fact
only read the status of the output data latch and not the actual logic status of the output pin.
• PxC Register
Bit76543210
NamePxC7PxC6PxC5PxC4PxC3PxC2PxC1PxC0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR11111111
PxCn: I/O Port x Pin type selection
0: Output
1: Input
The PxCn bit is used to control the pin type selection. Here the “x” can be A, B or C.
However, the actual available bits for each I/O Port may be different.
Pin-shared Functions
The exibility of the microcontroller range is greatly enhanced by the use of pins that have more
than one function. Limited numbers of pins can force serious design constraints on designers but by
supplying pins with multi-functions, many of these difculties can be overcome. For these pins, the
desired function of the multi-function I/O pins is selected by a series of registers via the application
Within the user program, one of the rst 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 pullhigh selections have been chosen. If the port control registers are then programmed to setup some
pins as outputs, these output pins will have an initial high output value unless the associated port
data registers are rst programmed. Selecting which pins are inputs and which are outputs can be
achieved byte-wide by loading the correct values into the appropriate port control register or by
programming individual bits in the port control register using the “SET [m].i” and “CLR [m].i”
instructions. Note that when using these bit control instructions, a read-modify-write operation takes
place. The microcontroller must rst read in the data on the entire port, modify it to the required new
bit values and then rewrite this data back to the output ports.
Port A has the additional capability of providing wake-up function. When the device is in the SLEEP
or IDLE Mode, various methods are available to wake the device up. One of these is a high to
low transition of any of the Port A pins. Single or multiple pins on Port A can be setup to have this
function.
Timer Module – TM
One of the most fundamental functions in any microcontroller device is the ability to control and
measure time. To implement time related functions the device includes several Timer Modules,
abbreviated to the name TM. The TMs are multi-purpose timing units and serve to provide
operations such as Timer/Counter, Compare Match Output as well as being the functional unit for
the generation of PWM signals. Each of the TMs has two individual interrupts. The addition of
input and output pins for each TM ensures that users are provided with timing units with a wide and
exible range of features.
The general features of the Compact type TM are described here with more detailed information
provided in the individual Compact type TM section.
Introduction
The device contains two Compact type TM. The main features of the CTM are summarised in the
accompanying table.
TM Operation
The Compact type TM offers a diverse range of functions, from simple timing operations to
PWM signal generation. The key to understanding how the TM operates is to see it in terms of
a free running counter whose value is then compared with the value of pre-programmed internal
comparators. When the free running counter has the same value as the pre-programmed comparator,
known as a compare match situation, a TM interrupt signal will be generated which can clear the
counter and perhaps also change the condition of the TM output pin. The internal TM counter is
driven by a user selectable clock source, which can be an internal clock or an external pin.
FunctionCTM
Timer/Counter√
Compare Match Output√
PWM Output√
PWM AlignmentEdge
PWM Adjustment Period & DutyDuty or Period
CTM Function Summary
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. The clock source can be a ratio of
the system clock f
The CTCKn pin clock source is used to allow an external signal to drive the TM as an external clock
source or for event counting.
TM Interrupts
Each Compact type TM has two internal interrupts, the internal comparator A or comparator P,
which generate a TM interrupt when a compare match condition occurs. When a TM interrupt is
generated, it can be used to clear the counter and also to change the state of the TM output pin.
TM External Pins
Each Compact type TM has one TM input pin, with the label CTCKn. The CTMn input pin,
CTCKn, is essentially a clock source for the CTMn and is selected using the CTnCK2~CTnCK0
bits in the CTMnC0 register. This external TM input pin allows an external clock source to drive the
internal TM. The CTCKn input pin can be chosen to have either a rising or falling active edge.
The TMs each have two output pins with the label CTPn and CTPnB. When the TM is in the
Compare Match Output Mode, these pins can be controlled by the TM to switch to a high or low
level or to toggle when a compare match situation occurs. The external CTPn and CTPnB output
pins are also the pins where the TM generates the PWM output waveform.
As the TM input and output pins are pin-shared with other functions, the TM input and output
function must rst be setup using relevant pin-shared function selection register described in the
Pin-shared Function section.
HT45F6530
AC Voltage Regulator Flash MCU
or the internal high clock fH, the f
SYS
CTM0CTM1
InputOutputInputOutput
CTCK0CTP0, CTP0BCTCK1CTP1, CTP1B
CTM External Pins
clock source or the external CTCKn pin.
SUB
Clock input
CTMn
CCR output
CTM Function Pin Block Diagram (n=0~1)
CTCKn
CTPn
CTPnB
Programming Considerations
The TM Counter Registers and the Capture/Compare CCRA registers, all have a low and high byte
structure. The high bytes can be directly accessed, but as the low bytes can only be accessed via an
internal 8-bit buffer, reading or writing to these register pairs must be carried out in a specic way.
The important point to note is that data transfer to and from the 8-bit buffer and its related low byte
only takes place when a write or read operation to its corresponding high byte is executed.
As the CCRA registers are implemented in the way shown in the following diagram and accessing
The counter can be paused by setting this bit high. Clearing the bit to zero restores
normal counter operation. When in a Pause condition the CTMn will remain powered
up and continue to consume power. The counter will retain its residual value when
this bit changes from low to high and resume counting from this value when the bit
changes to a low value again.
These three bits are used to select the clock source for the CTMn. The external pin
clock source can be chosen to be active on the rising or falling edge. The clock source
f
is the system clock, while fH and f
SYS
are other internal clocks, the details of which
SUB
can be found in the oscillator section.
Bit 3 CTnON: CTMn Counter On/Off control
0: Off
1: On
This bit controls the overall on/off function of the CTMn. Setting the bit high enables
the counter to run while clearing the bit disables the CTMn. Clearing this bit to zero
will stop the counter from counting and turn off the CTMn which will reduce its power
consumption. When the bit changes state from low to high the internal counter value
will be reset to zero, however when the bit changes from high to low, the internal
counter will retain its residual value until the bit returns high again. If the CTMn is in
the Compare Match Output Mode or the PWM Output Mode then the CTMn output
pin will be reset to its initial condition, as specified by the CTnOC bit, when the
CTnON bit changes from low to high.
HT45F6530
AC Voltage Regulator Flash MCU
Bit 2~0 CTnRP2~CTnRP0: CTMn CCRP 3-bit register, compared with the CTMn counter
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. The result of this
comparison can be selected to clear the internal counter if the CTnCCLR bit is set to
zero. Setting the CTnCCLR bit to zero ensures that a compare match with the CCRP
values will reset the internal counter. As the CCRP bits are only compared with the
highest three counter bits, the compare values exist in 128 clock cycle multiples.
Clearing all three bits to zero is in effect allowing the counter to overflow at its
maximum value.
These bits setup the required operating mode for the CTMn. To ensure reliable
operation the CTMn should be switched off before any changes are made to the
CTnM1 and CTnM0 bits. In the Timer/Counter Mode, the CTMn output pin state is
undened.
Bit 5~4 CTnIO1~CTnIO0: Select CTMn external pin CTPn function
Compare Match Output Mode
00: No change
01: Output low
10: Output high
11: Toggle output
PWM Output Mode
00: PWM output inactive state
01: PWM output active state
10: PWM output
11: Undened
Timer/Counter Mode
Unused
These two bits are used to determine how the CTMn external pin changes state when a
certain condition is reached. The function that these bits select depends upon in which
mode the CTMn is running.
In the Compare Match Output Mode, the CTnIO1 and CTnIO0 bits determine how the
CTMn output pin changes state when a compare match occurs from the Comparator A.
The CTMn output pin can be setup to switch high, switch low or to toggle its present
state when a compare match occurs from the Comparator A. When the bits are both
zero, then no change will take place on the output. The initial value of the CTMn
output pin should be setup using the CTnOC bit in the CTMnC1 register. Note that
the output level requested by the CTnIO1 and CTnIO0 bits must be different from the
initial value setup using the CTnOC bit otherwise no change will occur on the CTMn
output pin when a compare match occurs. After the CTMn output pin changes state,
it can be reset to its initial level by changing the level of the CTnON bit from low to
high.
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 modied 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.
Unpredictable PWM outputs will occur if the CTnIO1 and CTnIO0 bits are changed
when the CTMn is running.
Bit 3 CTnOC: CTMn CTPn Output control
Compare Match Output Mode
0: Initial low
1: Initial high
PWM Output Mode/Single Pulse Output Mode
0: Active low
1: Active high
This is the output control bit for the CTMn output pin. Its operation depends upon
whether CTMn is being used in the Compare Match Output Mode or in the PWM
Output Mode. It has no effect if the CTMn is in the Timer/Counter Mode. In the
Compare Match Output Mode it determines the logic level of the CTMn output pin
before a compare match occurs. In the PWM Output Mode it determines if the PWM
signal is active high or active low.
Bit 2 CTnPOL: CTMn CTPn Output polarity control
0: Non-invert
1: Invert
This bit controls the polarity of the CTPn output pin. When the bit is set high the
CTMn output pin will be inverted and not inverted when the bit is zero. It has no effect
if the CTMn is in the Timer/Counter Mode.
This bit determines which of the CCRA and CCRP registers are used for period and
duty control of the PWM waveform.
Bit 0 CTCCLR: CTMn Counter Clear condition selection
0: Comparator P match
1: Comparator A match
This bit is used to select the method which clears the counter. Remember that the
CTMn contains two comparators, Comparator A and Comparator P, either of which
can be selected to clear the internal counter. With the CTnCCLR bit set high, the
counter will be cleared when a compare match occurs from the Comparator A. When
the bit is low, the counter will be cleared when a compare match occurs from the
Comparator P or with a counter overflow. A counter overflow clearing method can
only be implemented if the CCRP bits are all cleared to zero. The CTnCCLR bit is not
used in the PWM Output mode.
• CTMnDL Register
Bit76543210
NameD7D6D5D4D3D2D1D0
R/WRRRRRRRR
POR00000000
Bit 7~0 D7~D0: CTMn Counter Low Byte Register bit 7~bit 0
CTMn 10-bit Counter bit 7~bit 0
HT45F6530
AC Voltage Regulator Flash MCU
• CTMnDH Register
Bit76543210
Name——————D9D8
R/W——————RR
POR——————00
Bit 7~2 Unimplemented, read as “0”
Bit 1~0 D9~D8: CTMn Counter High Byte Register bit 1~bit 0
CTMn 10-bit Counter bit 9~bit 8
• CTMnAL Register
Bit76543210
NameD7D6D5D4D3D2D1D0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR00000000
Bit 7~0 D7~D0: CTMn CCRA Low Byte Register bit 7~bit 0
CTMn 10-bit CCRA bit 7~bit 0
• CTMnAH Register
Bit76543210
Name——————D9D8
R/W——————R/WR/W
POR——————00
Bit 7~2 Unimplemented, read as “0”
Bit 1~0 D9~D8: CTMn CCRA High Byte Register bit 7~bit 0
CTMn 10-bit CCRA bit 9~bit 8
Compact Type TM Operation Modes
The Compact Type TM can operate in one of three operating modes, Compare Match Output Mode,
PWM Output Mode or Timer/Counter Mode. The operating mode is selected using the CTnM1 and
CTnM0 bits in the CTMnC1 register.
Compare Match Output Mode
To select this mode, bits CTnM1 and CTnM0 in the CTMnC1 register, should be set to 00
respectively. In this mode once the counter is enabled and running it can be cleared by three
methods. These are a counter overow, a compare match from Comparator A and a compare match
from Comparator P. When the CTnCCLR bit is low, there are two ways in which the counter can be
cleared. One is when a compare match from Comparator P, the other is when the CCRP bits are all
zero which allows the counter to overow. Here both CTMnAF and CTMnPF interrupt request ags
for Comparator A and Comparator P respectively, will both be generated.
If the CTnCCLR bit in the CTMnC1 register is high then the counter will be cleared when a compare
match occurs from Comparator A. However, here only the CTMnAF interrupt request ag will be
generated even if the value of the CCRP bits is less than that of the CCRA registers. Therefore when
CTnCCLR is high no CTMnPF interrupt request ag will be generated. If the CCRA bits are all
zero, the counter will overow when it reaches its maximum 10-bit, 3FF Hex, value. However, here
the CTMnAF interrupt request ag will not be generated.
As the name of the mode suggests, after a comparison is made, the CTMn output pin, will change
state. The CTMn output pin condition however only changes state when a CTMnAF interrupt
request ag is generated after a compare match occurs from Comparator A. The CTMnPF interrupt
As this device contains an internal 12-bit A/D converter, it requires two data registers to store the
converted value. These are a high byte register, known as SADOH, and a low byte register, known
as SADOL. After the conversion process takes place, these registers can be directly read by the
microcontroller to obtain the digitised conversion value. As only 12 bits of the 16-bit register space
is utilised, the format in which the data is stored is controlled by the ADRFS bit in the SADC0
register as shown in the accompanying table. D0~D11 are the A/D conversion result data bits. Any
unused bits will be read as zero. Note that A/D data registers contents will be unchanged if the A/D
converter is disabled.
ADRFS
7654321076543210
0D11 D10 D9 D8 D7D6D5D4 D3D2D1D00000
10000D11 D10 D9D8D7D6D5 D4D3D2D1D0
SADOHSADOL
A/D Converter Data Registers
Bit
A/D Converter Control Registers – SADC0, SADC1, SADC2
To control the function and operation of the A/D converter, three control registers known as
SADC0~SADC2 are provided. These 8-bit registers dene functions such as the selection of which
analog signal is connected to the internal A/D converter, the digitised data format, the A/D clock
source as well as controlling the start function and monitoring the A/D converter busy status. As the
device contains only one actual analog to digital converter hardware circuit, each of the external
or internal analog signal inputs must be routed to the converter. The SACS3~SACS0 bits in the
SADC0 register are used to determine which external channel input is selected to be converted.
The SAINS3~SAINS0 bits in the SADC1 register are used to determine that the analog signal to be
converted comes from the internal analog signal or external analog channel input. The A/D converter
also contains a programmable gain amplier, PGA, to generate the A/D converter internal reference
voltage. The overall operation of the PGA is controlled using the SADC2 register.
The relevant pin-shared function selection bits determine which pins on I/O Ports are used as analog
inputs for the A/D converter input and which pins are not to be used as the A/D converter input.
When the pin is selected to be an A/D input, its original function whether it is an I/O or other pin-
shared function will be removed. In addition, any internal pull-high resistor connected to the pin will
be automatically removed if the pin is selected to be an A/D converter input.
HT45F6530
AC Voltage Regulator Flash MCU
• SADC0 Register
Bit76543210
NameSTARTADBZADCENADRFSSACS3SACS2SACS1SACS0
R/WR/WRR/WR/WR/WR/WR/WR/W
POR00000000
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.
Bit 6 ADBZ: A/D converter busy ag
0: No A/D conversion is in progress
1: A/D conversion is in progress
This read only ag is used to indicate whether the A/D conversion is in progress or
not. When the START bit is set from low to high and then to low again, the ADBZ ag
will be set to 1 to indicate that the A/D conversion is initiated. The ADBZ ag will be
cleared to 0 after the A/D conversion is complete.
Bit 5 ADCEN: A/D converter function enable control
0: Disable
1: Enable
This bit controls the A/D internal function. This bit should be set to one to enable
the A/D converter. If the bit is set low, then the A/D converter will be switched off
reducing the device power consumption. When the A/D converter function is disabled,
the contents of the A/D data register pair known as SADOH and SADOL will be
unchanged.
Bit 4 ADRFS: A/D converter data format select
0: A/D converter data format → SADOH=D[11:4]; SADOL=D[3:0]
1: A/D converter data format → SADOH=D[11:8]; SADOL=D[7:0]
This bit controls the format of the 12-bit converted A/D value in the two A/D data
registers. Details are provided in the A/D data register section.
Bit 3~0 SACS3~SACS0: A/D converter external analog channel input select
1010~1011: Reserved, connected to ground
1100~1111: External input – External analog channel input, ANn
When the internal analog signal is selected to be converted, the external channel signal
input will automatically be switched off regardless of the SACS eld value.
Bit 3 Unimplemented, read as “0”
Bit 2~0 SACKS2~SACKS0: A/D conversion clock source select
000: f
SYS
001: f
010: f
011: f
100: f
101: f
110: f
111: f
These three bits are used to select the clock source for the A/D converter.
SYS
SYS
SYS
SYS
SYS
SYS
SYS
/2
/4
/8
/16
/32
/64
/128
DD
R
OPA0O
OPA1O
• SADC2 Register
Bit76543210
NameADPGAEN——PGAISSAVRS1 SAVRS0 PGAGS1 PGAGS0
R/WR/W——R/WR/WR/WR/WR/W
POR0——00000
Bit 7 ADPGAEN: PGA enable/disable control
0: Disable
1: Enable
When the PGA output VR is selected as A/D converter input or A/D converter
reference voltage, the PGA must to be enabled by setting this bit high. Otherwise the
PGA should to be disabled by clearing this bit to zero to conserve the power.
Bit 6~5 Unimplemented, read as “0”
Bit 4 PGAIS: PGA input (VRI) select
0: External VREFI pin
1: Internal independent reference voltage, V
BG
This bit is used to select the PGA input source. When the internal voltage independent
reference VBG is selected, the external voltage on VREFI pin will automatically be
switched off.
Bit 3~2 SAVRS1~SAVRS0: A/D converter reference voltage select
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.
Bit 1~0 PGAGS1~PGAGS0: PGA gain select
00: Gain=1
01: Gain=2
10: Gain=3
11: Gain=4
A/D Converter Reference Voltage
The actual reference voltage supply to the A/D converter can be supplied from the positive power
supply pin, VDD, or from an external reference source supplied on pin VREF, or from the internal
PGA output voltage, VR. The desired selection is made using the SAVRS1 and SAVRS0 bits in the
SADC2 register. When the SAVRS bit eld is set to “00”, the A/D converter reference voltage will
come from the VDD pin. If the SAVRS bit eld is set to “01”, the A/D converter reference voltage
will come from the VREF pin. Otherwise, the A/D converter reference voltage will come from the
PGA output, VR. As the VREF pin is pin-shared with other functions, when the VREF pin is selected
as the reference voltage supply pin, the VREF pin-shared function control bits should be properly
congured to disable other pin functions. However, if the internal reference signal, VDD or VR, is
selected as the A/D converter reference source, the external reference input from the VREF pin
will automatically be switched off by the hardware. The analog input values must not be allowed to
exceed the value of the selected reference voltage, V
In addition, the A/D converter also has a VREFI pin which is one of PGA inputs for A/D converter
reference. To select this PGA input signal, the PGAIS bit in the SADC2 register must be cleared to
zero and the relevant pin-shared control bits should be properly congured. However, the PGA input
can be also supplied from the internal independent reference voltage, VBG. If the internal voltage
VBG is selected as the PGA input source, the external voltage on the VREFI pin will automatically be
switched off by the hardware. The PGA input voltage can be amplied through a programmable gain
amplier, PGA, which is controlled by the ADPGAEN bit in the SADC2 register. The PGA gain can
Independent D/A converter;
Combine to a function of operational amplier and comparator:
the operational amplier amplies a signal and then the
comparator compares it with the external signals
Independent operational amplier
Combine to an over voltage protection function of D/A converter
and comparator
Combine to a complete over current protection function of
operational amplier, comparator and D/A converter
HT45F6530
AC Voltage Regulator Flash MCU
Register
Name
DAnH————D11D10D9D8
DAnLD7D6D5D4D3D2D1D0
DACnCDACnEN DACnVRS————Sn7Sn6
OPnCOPnOUTOPnEN————OPnBW1 OPnBW0
OPnVOSOnOFMOnRSPOnOF5OnOF4OnOF3OnOF2OnOF1OnOF0
CMPnC—CMPnENCnPOLCMPnO CNVTn1 CNVTn0——
CMPnVOS—CnOFMCnRSPCnOF4CnOF3CnOF2CnOF1CnOF0
76543210
Over Current Protection Register List (n=0~1)
Bit
D/A Converter Registers – DAnH, DAnL, DACnC
• DAnH Register
Bit76543210
Name————D 11D10D9D8
R/W————R/WR/WR/WR/W
POR————0000
Bit 7~4 Unimplemented, read as “0”
Bit 3~0 D11~D8: OCP D/A Converter n output control code high byte
• DAnL Register
Bit76543210
NameD7D6D5D4D3D2D1D0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR00000000
Bit 7~0 D7~D0: OCP D/A Converter n output control code low byte
Writing this register will only write the data to a shadow buffer and writing the DAnH
register will simultaneously copy the shadow buffer data to the DAnL register.
OCP D/A Converter n Output=(D/A Converter n reference voltage/212)×D[11:0]
• DACnC Register
Bit76543210
NameDACnEN DACnVRS————Sn7Sn6
R/WR/WR/W————R/WR/W
POR00————00
Bit 7 DACnEN: OCP D/A Converter n enable or disable control bit
0: Disable
1: Enable
Note that in applications the BUF_OUTn function should be rst selected by properly
conguring the corresponding pin-shared function register before the DACnEN bit is
set high.
Bit 6 DACnVRS: OCP D/A Converter n reference voltage selection
When the switch S7 is on by setting this bit high, the operational amplier n output
signal will be internally connected to the comparator n positive input. Therefore the
CMPnP pin function should be rst switched off by properly conguring the relevant
pin-shared control bits to avoid signal coniction.
Bit 0 Sn6: Switch S6 control
0: Off
1: On
When the switch S6 is on by setting this bit high, the D/A converter n output signal
will be internally connected to the comparator n negative input. Therefore the CMPnN
pin function should be first switched off by properly configuring the relevant pin-
shared control bits to avoid signal coniction.
Operational Amplier Registers – OPnC, OPnVOS
• OPnC Register
Bit76543210
NameOPnOUT OPnEN————OPnBW1 OPnBW0
R/WRR/W————R/WR/W
POR00————00
Bit 7 OPnOUT: OCP Operational Amplier n digital output bit, positive logic (read only)
When the OCP Operational Amplier n is disabled, this bit will be cleared to zero.
When the OnOFM bit is set high, the OPnOUT bit is defined as OCP Operational
Amplier n output status, refer to the “Operational Amplier Input Offset Calibration”
section for the detailed offset calibration procedures.
Bit 6 OPnEN: OCP Operational Amplier n enable or disable control bit
0: Disable
1: Enable
Bit 5~2 Unimplemented, read as “0”
Bit 1~0 OPnBW1~OPnBW0: OCP Operational Amplier n bandwidth control bits
Refer to “Operational Amplier Electrical Characteristics” for details.
• OPnVOS Register
Bit76543210
NameOnOFMOnRSPOnOF5OnOF4OnOF3OnOF2OnOF1OnOF0
R/WR/WR/WR/WR/WR/WR/WR/WR/W
POR00100000
Bit 7 OnOFM: OCP Operational Amplier n operating mode selection
0: Normal operating mode
1: Input offset calibration mode
This bit is used to select the OCP Operational Amplier n operating mode. If the bit
is zero the OCP Operational Amplier n will operate normally. The OCP Operational
Amplifier n will enter the offset calibration mode if this bit is set high. Refer to
the “Operational Amplifier Input Offset Calibration” section for the detailed offset
alibration procedures.
c
Bit 6 OnRSP: OCP Operational Amplier n input offset voltage calibration reference
selection
0: From OPAnN pin
1: From OPAnP pin
This bit is used to select the OCP Operational Amplifier n input offset calibration
reference. When the OCP Operational Amplier n is in the offset calibration mode,
the calibration reference input can come from the OCP Operational Amplier n inputs,
OPAnN or OPAnP, determined by this bit. This bit is only available when the OCP
Operational Amplier n operates in offset calibration mode.
HT45F6530
AC Voltage Regulator Flash MCU
Bit 5~0 OnOF5~OnOF0: OCP Operational Amplier n input offset voltage calibration control
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.
More detailed information is described in the “Operational Amplifier Input Offset
Calibration” section.
Comparator Registers – CMPnC, CMPnVOS
• CMPnC Register
Bit76543210
Name—CMPnENCnPOLCMPnOCNVTn1 CNVTn0——
R/W—R/WR/WRR/WR/W——
POR—00000——
Bit 7 Unimplemented, read as “0”
Bit 6 CMPnEN: OCP Comparator n enable or disable control
0: Disable
1: Enable
This bit is used to control the OCP Comparator n on/off. The OCP Comparator n
output will be set low when this bit is cleared to zero. Therefore, CMPnO=0 when
CnPOL=0, or CMPnO=1 when CnPOL=1.
Bit 5 CnPOL: OCP Comparator n output polarity control
0: Non-invert
1: Invert
This bit is used to control the OCP Comparator n output polarity. If the bit is zero
then the OCP Comparator n output bit, CMPnO, will reect the non-inverted output
condition of the OCP Comparator n. If the bit is high the OCP Comparator n output bit
will be inverted.
Bit 4 CMPnO: OCP Comparator n output bit
If CnPOL=0,
0: CMPnP < CMPnN
1: CMPnP > CMPnN
If CnPOL=1,
0: CMPnP > CMPnN
1: CMPnP < CMPnN
This bit stores the OCP Comparator n output bit. The polarity of the bit is determined by
the voltages on the OCP Comparator n inputs and by the condition of the CnPOL bit.
Bit 3~2 CNVTn1~CNVTn0: OCP Comparator n response time selection
These bits are used to select the OCP Comparator n response time. The response time
is also determined by the overdriven voltage applied on the inputs except these bits.
Refer to “Comparator Electrical Characteristics” for details.
Bit 1~0 Unimplemented, read as “0”
• CMPnVOS Register
Bit76543210
Name—CnOFMCnRSPCnOF4CnOF3CnOF2CnOF1CnOF0
R/W—R/WR/WR/WR/WR/WR/WR/W
POR—0010000
Bit 7 Unimplemented, read as “0”
Bit 6 CnOFM: OCP Comparator n operating mode selection
0: Normal operating mode
1: Input offset calibration mode
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” section for the detailed offset calibration procedures.
Bit 5 CnRSP: OCP Comparator n input offset calibration reference selection
0: From CMPnN pin
1: From CMPnP pin
This bit is used to select the OCP Comparator n input offset calibration reference.
When the OCP Comparator n is in the offset calibration mode, the calibration reference
input can come from the OCP Comparator n inputs, CMPnN or CMPnP, determined
by this bit. This bit is only available when the OCP Comparator n operates in offset
calibration mode.
Bit 4~0 CnOF4~CnOF0: OCP Comparator n input offset calibration control bits
These bits are used to calibrate the input offset according to the selected reference
input when the OCP Comparator n is in the offset calibration mode. More detailed
information is described in the “Comparator Input Offset Calibration” section.
Offset Calibration Procedure
To operate in the input offset calibration mode for the OCP Operational Amplifier n or the OCP
Comparator n, the OnOFM or CnOFM bit should rst be set to “1” followed by the reference input
selection by conguring the OnRSP or CnRSP bit. Note that as the OCP Operational Amplier n or
the OCP Comparator n inputs are pin-shared with I/O pins, they should be congured as the OCP
Operational Amplier n inputs or the OCP Comparator n inputs rst. The following procedures use
the positive input pins as reference input for example.
Operational Amplier Input Offset Calibration
Step 1. Set OnOFM=1 and OnRSP=1, the OCP Operational Amplier n will operate in the input
offset calibration mode, S0 and S2 on. To make sure VOS as minimize as possible after
calibration, the input reference voltage in calibration should be the same as input DC
operating voltage in normal operation.
Step 2. Set OnOF[5:0]=000000 and then read the OPnOUT bit.
Step 3. Increase the OnOF[5:0] value by 1 and then read the OPnOUT bit.
If the OPnOUT bit state has not changed, then repeat Step 3 until the OPnOUT bit state has
changed.
If the OPnOUT bit state has changed, record the OnOF[5:0] value as V
and then go to
OS1
Step 4.
Step 4. Set OnOF[5:0]=111111 and read the OPnOUT bit.
Step 5. Decrease the OnOF[5:0] value by 1 and then read the OPnOUT bit.
If the OPnOUT bit state has not changed, then repeat Step 5 until the OPnOUT bit state has
changed.
If the OPnOUT bit state has changed, record the OnOF[5:0] value as V
and then go to
OS2
Step 6.
Step 6. Restore the OCP Operational Amplifier n input offset calibration value VOS into the
OnOF[5:0] bit eld. The offset Calibration procedure is now nished.
Where VOS=(V
Residue VOS=V
OS1+VOS2
OUT
– V
)/2. If (V
IN
OS1+VOS2
)/2 is not integral, discard the decimal.
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 VOS as minimize as possible
after calibration, the input reference voltage in calibration should be the same as input DC
operating voltage in normal operation.
Step 2. Set CnOF[4:0]=00000 and read the CMPnO bit.
Step 3. Increase the CnOF[4:0] value by 1 and then read the CMPnO bit.
If the CMPnO bit state has not changed, then repeat Step 3 until the CMPnO bit state has
changed.
If the CMPnO bit state has changed, record the CnOF[4:0] value as V
Step 4. Set CnOF[4:0]=11111 and then read the CMPnO bit.
Step 5. Decrease the CnOF[4:0] value by 1 and then read the CMPnO bit.
If the CMPnO bit state has not changed, then repeat Step 5 until the CMPnO bit state has
changed.
If the CMPnO bit state has changed, record the CnOF[4:0] value as V
Step 6. Restore the OCP Comparator n input offset calibration value VOS into the CnOF[4:0] bit
eld. The offset Calibration procedure is now nished.
Where VOS=(V
Residue VOS=V
OS1+VOS2
OUT
– V
)/2. If (V
IN
OS1+VOS2
)/2 is not integral, discard the decimal.
and then go to Step 4.
OS1
and then go to Step 6.
OS2
Low Voltage Detector – LVD
The device has a Low Voltage Detector function, also known as LVD. This enabled the device to
monitor the power supply voltage, VDD, and provide a warning signal should it fall below a certain
level. This function may be especially useful in battery applications where the supply voltage will
gradually reduce as the battery ages, as it allows an early warning battery low signal to be generated.
The Low Voltage Detector also has the capability of generating an interrupt signal.
LVD Register
The Low Voltage Detector function is controlled using a single register with the name LVDC. Three
bits in this register, VLVD2~VLVD0, are used to select one of eight xed voltages below which
a low voltage condition will be determined. A low voltage condition is indicated when the LVDO
bit is set. If the LVDO bit is low, this indicates that the VDD voltage is above the preset low voltage
value. The LVDEN bit is used to control the overall on/off function of the low voltage detector.
Setting the bit high will enable the low voltage detector. Clearing the bit to zero will switch off the
internal low voltage detector circuits. As the low voltage detector will consume a certain amount of
power, it may be desirable to switch off the circuit when not in use, an important consideration in