HT45F5Q-3 Battery Charger 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 –...
Battery Charger Flash MCU General Description The HT45F5Q-3 is a Flash Memory A/D type 8-bit high performance RISC architecture microcontroller especially designed for battery charger applications. Offering users the convenience of Flash Memory multi-programming features, this device also includes a wide range of functions and features.
HT45F5Q-3 Battery Charger Flash MCU Block Diagram Reset Port A USIM Circuit PA0~PA7 Driver × × SCOM Interrupt Emulated Controller Stack EEPROM Pin-Shared Port B 6-level PB0~PB7 × Function Driver INT0~ INT1 Timers Watchdog Timer Pin-Shared Port C PC0~PC6 With Port A...
2. The OCDSDA and OCDSCK pins are supplied for the OCDS dedicated pins and as such only available for the HT45V5Q-3 device which is the OCDS EV chip for the HT45F5Q-3 device. 3. For the less pin count package type there will be unbounded pins which should be properly configured to avoid unwanted power consumption resulting from floating input conditions.
Page 10
HT45F5Q-3 Battery Charger Flash MCU Pin Name Function Description PAPU General purpose I/O. Register enabled pull-up PAWU CMOS and wake-up PAS1 PAS1 — CMOS STM output STCK PAS1 — STM clock input PA4/STP/STCK/SDI/SDA/RX PAS1 — SPI serial data input PAS1...
HT45F5Q-3 Battery Charger Flash MCU Absolute Maximum Ratings Supply Voltage ......................V -0.3V to 6.0V Input Voltage ..................... V -0.3V to V +0.3V Storage Temperature ..................... -50°C to 125°C Operating Temperature ....................-40°C to 105°C Total ............................-80mA Total ............................80mA Total Power Dissipation ......................
HT45F5Q-3 Battery Charger Flash MCU 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 influence 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.
HT45F5Q-3 Battery Charger Flash MCU System Start Up Time Characteristics Ta=-40°C~105°C Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions — f /64, f — — System Start-up Time HIRC HIRC (Wake-up from condition where f is off) — f —...
HT45F5Q-3 Battery Charger Flash MCU Memory Characteristics Ta=-40°C~105°C, unless otherwise specified Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions Flash Program / Emulated EEPROM Memory Operating Voltage for Read — — — Operating Voltage for Erase/Write — — Erase / Write Time – Flash Program Memory —...
HT45F5Q-3 Battery Charger Flash MCU Test Conditions Symbol Parameter Min. Typ. Max. Unit Conditions 2.2V — μA Additional Current for A/D Converter Enable No load, t =0.5μs — μA ADCK — μA A/D Converter Clock Period — — — 10.0 μs...
Battery Charger 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...
HT45F5Q-3 Battery Charger Flash MCU If the stack is overflow, the first Program Counter save in the stack will be lost. Program Counter Top of Stack Stack Level 1 Stack Level 2 Stack Stack Level 3 Program Pointer Memory Bottom of Stack Stack Level 6 Arithmetic and Logic Unit –...
HT45F5Q-3 Battery Charger Flash MCU 000H Initialisation Vector 004H Interrupt Vectors 020H n00H Look-up Table nFFH 15 bits FFFH Program Memory Structure Special Vectors Within the Program Memory, certain locations are reserved for the reset and interrupts. The location 000H is reserved for use by the device reset for program initialisation. After a device reset is initiated, the program will jump to this location and begin execution.
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.
* must be less than 1nF. On-Chip Debug Support – OCDS There is an EV chip named HT45V5Q-3 which is used to emulate the HT45F5Q-3 device. This EV chip device also provides an “On-Chip Debug” function to debug the real MCU device during the development process.
HT45F5Q-3 Battery Charger 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.
HT45F5Q-3 Battery Charger 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.
HT45F5Q-3 Battery Charger 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.
HT45F5Q-3 Battery Charger Flash MCU Bank Pointer – BP For this device, the Data Memory is divided into two banks, Bank0 and Bank1. Selecting the required Data Memory area is achieved using the Bank Pointer. Bit 0 of the Bank Pointer is used to select Data Memory Bank 0~1.
HT45F5Q-3 Battery Charger 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.
HT45F5Q-3 Battery Charger Flash MCU Bit 1 AC: Auxiliary flag 0: No auxiliary carry 1: An operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction...
HT45F5Q-3 Battery Charger Flash MCU Emulated EEPROM Registers Several registers control the overall operation of the Emulated EEPROM Data Memory. These are the address register, EAR, the data registers, ED0L/ED0H ~ ED3L/ED3H, and a single control register, ECR. Register Name —...
Page 31
HT45F5Q-3 Battery Charger Flash MCU • ED1H Register Name — — — Bit 7 Unimplemented, read as “0” Bit 6~0 D14~D8: The second Emulated EEPROM data bit 14 ~ bit 8 • ED2L Register5 Name Bit 7~0 D7~D0: The third Emulated EEPROM data bit 7 ~ bit 0 •...
Page 32
HT45F5Q-3 Battery Charger Flash MCU Bit 5 EEREN: Emulated EEPROM Erase enable 0: Disable 1: Enable This bit is used to enable the Emulated EEPROM erase function and must be set high before erase operations are carried out. This bit will be automatically reset to zero by the hardware after the erase cycle has finished.
HT45F5Q-3 Battery Charger Flash MCU Erasing the Emulated EEPROM For Emulated EEPROM erase operation the desired erase page address should first be placed in the EAR register. The number of the erase operation is 16 words per page each time, therefore, the available page erase address is only specified by the EAR4 bit in the EAR register and the content of EAR3~EAR0 in the EAR register is not used to specify the page address.
Page 34
HT45F5Q-3 Battery Charger Flash MCU set high, to ensure the write or erase cycle executes correctly. The global interrupt bit EMI should also be cleared before a write or erase cycle is executed and then set again after a valid write or erase activation procedure has completed.
HT45F5Q-3 Battery Charger Flash MCU Reading Data from the Emulated EEPROM – polling method MOV A, EEPROM_ADRES ; user-defined address MOV EAR, A SET ERDEN ; set ERDEN bit, enable read operation SET ERD ; start Read Cycle – set ERD bit BACK: SZ ERD ; check for read cycle end JMP BACK CLR ECR ; disable Emulated EEPROM read if no more read operations ; are required MOV A, ED0L ; move read data which is placed in the ED0L/ED0H ; to user-defined registers MOV READ_DATA_L, A MOV A, ED0H MOV READ_DATA_H, A Note: For each read operation, the address register should be re-specified followed by setting the ERD bit high to activate a read cycle even if the target address is consecutive.
As Holtek has provided the 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.
HT45F5Q-3 Battery Charger Flash MCU FAST Mode 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 39
HT45F5Q-3 Battery Charger 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 101: f...
HT45F5Q-3 Battery Charger 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 41
HT45F5Q-3 Battery Charger Flash MCU 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”...
Page 42
HT45F5Q-3 Battery Charger Flash MCU SLOW Mode to FAST Mode Switching In SLOW mode the system clock is derived from f . When system clock is switched back to the FAST mode from f , the CKS2~CKS0 bits should be set to “000”~“110” and then the system clock will respectively be switched to f /64.
Page 43
HT45F5Q-3 Battery Charger Flash MCU Entering the IDLE0 Mode There is only one way for the device to enter the IDLE0 Mode and that is to execute the “HALT” instruction in the application program with the FHIDEN bit in the SCC register equal to “0” and the FSIDEN bit in the SCC register equal to “1”.
HT45F5Q-3 Battery Charger Flash MCU 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.
HT45F5Q-3 Battery Charger Flash MCU 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 f...
HT45F5Q-3 Battery Charger Flash MCU Bit 0 WRF: WDT control register software reset flag 0: Not occurred 1: Occurred This bit is set to 1 by the WDT Control register software reset and cleared by the application program. Note that this bit can only be cleared to 0 by the application program.
HT45F5Q-3 Battery Charger Flash MCU 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 first 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 first program instruction.
Page 48
HT45F5Q-3 Battery Charger Flash MCU to 1. After power on the register will have the value of 01011010B. Note that the LVR function will be automatically disabled when the device enters the SLEEP/IDLE mode. RSTD Internal Reset Note: t is power-on delay specified in System Start Up Time Characteristics.
HT45F5Q-3 Battery Charger Flash MCU Watchdog Time-out Reset during Normal Operation When the Watchdog time-out Reset during normal operation occurs, the Watchdog time-out flag TO will be set to “1”. WDT Time-out RSTD Internal Reset Note: t is power-on delay specified in System Start Up Time Characteristics.
Page 50
HT45F5Q-3 Battery Charger Flash MCU Power On LVR Reset WDT Time-out WDT Time-out Register Name Reset (Normal Operation) (Normal Operation) (IDLE/SLEEP) IAR0 x x x x x x x x u u u u u u u u u u u u u u u u...
Battery Charger 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.
HT45F5Q-3 Battery Charger 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 54
HT45F5Q-3 Battery Charger 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 55
HT45F5Q-3 Battery Charger Flash MCU • PAS1 Register Name PAS17 PAS16 PAS15 PAS14 PAS13 PAS12 PAS11 PAS10 Bit 7~6 PAS17~PAS16: PA7 Pin-Shared function selection 00: PA7 01: SDO/TX 10: PA7 11: PA7 Bit 5~4 PAS15~PAS14: PA6 Pin-Shared function selection 00: PA6...
Page 56
HT45F5Q-3 Battery Charger Flash MCU • PBS1 Register Name PBS17 PBS16 PBS15 PBS14 PBS13 PBS12 PBS11 PBS10 Bit 7~6 PBS17~PBS16: PB7 Pin-Shared function selection 00: PB7 01: PB7 10: PB7 11: AN7 Bit 5~4 PBS15~PBS14: PB6 Pin-Shared function selection 00: PB6/INT1...
Page 57
HT45F5Q-3 Battery Charger Flash MCU • PCS1 Register Name — — PCS15 PCS14 PCS13 PCS12 PCS11 PCS10 — — — — Bit 7~6 Unimplemented, read as “0” Bit 5~4 PCS15~PCS14: PC6 Pin-Shared function selection 00: PC6 01: SCOM3 10: PC6...
HT45F5Q-3 Battery Charger Flash MCU I/O Pin Structures The accompanying diagram illustrates the internal structures of the I/O logic function. As the exact logical construction of the I/O pin will differ from this diagram, it is supplied as a guide only to assist with the functional understanding of the logic function I/O pins.
HT45F5Q-3 Battery Charger Flash MCU READ PORT Function Disabled Enabled Port Control Register Bit – PxC.n I/O Function Pin value Digital Input Function Data latch Digital Output Function (except USIM) Pin value value USIM: SCK/SCL, SDI/SDA/RX/TX Pin value Analog Function Note: The value on the above table is the content of the ACC register after “mov a, Px”...
HT45F5Q-3 Battery Charger Flash MCU Timer Modules – TM One of the most fundamental functions in any microcontroller device is the ability to control and measure time. To implement time related functions each 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, Input Capture, Compare Match Output and Single Pulse Output as well as being the functional unit for the generation of PWM signals.
HT45F5Q-3 Battery Charger Flash MCU TM Interrupts The Compact and Standard type TMs each have two internal interrupts, one for each of 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.
HT45F5Q-3 Battery Charger Flash MCU 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 specific way.
HT45F5Q-3 Battery Charger 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 Type TM can also be controlled with an external input pin and can drive two external output pins.
Page 65
HT45F5Q-3 Battery Charger Flash MCU Bit 2~0 CTRP2~CTRP0: CTM CCRP 3-bit register, compared with the CTM counter bit 9 ~ bit 7 Comparator P match period= 000: 1024 CTM clocks 001: 128 CTM clocks 010: 256 CTM clocks 011: 384 CTM clocks...
Page 66
HT45F5Q-3 Battery Charger Flash MCU setup using the CTOC bit otherwise no change will occur on the CTM output pin when a compare match occurs. After the CTM output pin changes state, it can be reset to its initial level by changing the level of the CTON bit from low to high.
HT45F5Q-3 Battery Charger Flash MCU • CTMDH Register Name — — — — — — — — — — — — — — — — — — Bit 7~2 Unimplemented, read as “0” Bit 1~0 D9~D8: CTM Counter High Byte Register bit 1~ bit 0 CTM 10-bit Counter bit 9 ~ bit 8 •...
Page 68
HT45F5Q-3 Battery Charger Flash MCU flag, generated from a compare match occurs from Comparator P, will have no effect on the CTM output pin. The way in which the CTM output pin changes state are determined by the condition of the CTIO1 and CTIO0 bits in the CTMC1 register.
Page 70
HT45F5Q-3 Battery Charger Flash MCU Timer/Counter Mode To select this mode, bits CTM1 and CTM0 in the CTMC1 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 CTM output pin is not used.
Page 71
HT45F5Q-3 Battery Charger Flash MCU Counter Value CTDPX = 0; CTM [1:0] = 10 Counter cleared by CCRP Counter Reset when CTON returns high CCRP Counter Stop if Pause Resume CTON bit low CCRA Time CTON CTPAU CTPOL CCRA Int.
Page 72
HT45F5Q-3 Battery Charger Flash MCU Counter Value CTDPX = 1; CTM [1:0] = 10 Counter cleared by CCRA Counter Reset when CTON returns high CCRA Counter Stop if Pause Resume CTON bit low CCRP Time CTON CTPAU CTPOL CCRP Int.
HT45F5Q-3 Battery Charger Flash MCU Standard Type TM – STM The Standard Type TM contains five operating modes, which are Compare Match Output, Timer/Event Counter, Capture Input, Single Pulse Output and PWM Output modes. The Standard TM can be controlled with two external input pins and can drive two external output pins.
Page 75
HT45F5Q-3 Battery Charger Flash MCU Bit 2~0 STRP2~STRP0: STM CCRP 3-bit register, compared with the STM counter bit 9 ~ bit 7 Comparator P Match Period= 000: 1024 STM clocks 001: 128 STM clocks 010: 256 STM clocks 011: 384 STM clocks...
Page 76
HT45F5Q-3 Battery Charger Flash MCU In the Compare Match Output Mode, the STIO1 and STIO0 bits determine how the STM output pin changes state when a compare match occurs from the Comparator A. The STM 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.
Page 77
HT45F5Q-3 Battery Charger Flash MCU • STMDL Register Name Bit 7~0 D7~D0: STM Counter Low Byte Register bit 7 ~ bit 0 STM 10-bit Counter bit 7 ~ bit 0 • STMDH Register Name — — — — — —...
HT45F5Q-3 Battery Charger Flash MCU Standard Type TM Operation Modes The Standard Type TM can operate in one of five operating modes, Compare Match Output Mode, PWM Output Mode, Single Pulse Output Mode, Capture Input Mode or Timer/Counter Mode. The operating mode is selected using the STM1 and STM0 bits in the STMC1 register.
Page 81
HT45F5Q-3 Battery Charger Flash MCU Timer/Counter Mode To select this mode, bits STM1 and STM0 in the STMC1 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 STM output pin is not used.
Page 82
HT45F5Q-3 Battery Charger Flash MCU Counter Value STDPX = 0; STM [1:0] = 10 Counter cleared by CCRP Counter Reset when STON returns high CCRP Counter Stop if Pause Resume STON bit low CCRA Time STON STPAU STPOL CCRA Int.
Page 83
HT45F5Q-3 Battery Charger Flash MCU Counter Value STDPX = 1; STM [1:0] = 10 Counter cleared by CCRA Counter Reset when STON returns high CCRA Counter Stop if Pause Resume STON bit low CCRP Time STON STPAU STPOL CCRP Int.
Page 84
HT45F5Q-3 Battery Charger Flash MCU Single Pulse Output Mode To select this mode, bits STM1 and STM0 in the STMC1 register should be set to 10 respectively and also the STIO1 and STIO0 bits should be set to 11 respectively. The Single Pulse Output Mode, as the name suggests, will generate a single shot pulse on the STM output pin.
Page 85
HT45F5Q-3 Battery Charger Flash MCU Counter Value STM [1:0] = 10 ; STIO [1:0] = 11 Counter stopped by CCRA Counter Reset when STON returns high CCRA Counter Stops by Resume Pause software CCRP Time STON Auto. set by STCK pin...
Page 86
HT45F5Q-3 Battery Charger Flash MCU Capture Input Mode To select this mode bits STM1 and STM0 in the STMC1 register should be set to 01 respectively. This mode enables external signals to capture and store the present value of the internal counter and can therefore be used for applications such as pulse width measurements.
Page 87
HT45F5Q-3 Battery Charger Flash MCU Counter Value STM [1:0] = 01 Counter cleared by CCRP Counter Counter Stop Reset CCRP Resume Pause Time STON STPAU Active Active Active edge edge edge STM capture pin STPI CCRA Int. Flag STMAF CCRP Int.
HT45F5Q-3 Battery Charger 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. By integrating the A/D conversion electronic circuitry into the microcontroller, the need for external components is reduced significantly with the corresponding follow-on benefits of lower costs and reduced component space requirements.
HT45F5Q-3 Battery Charger Flash MCU A/D Converter Register Description Overall operation of the A/D converter is controlled using a series of registers. A read only register pair exists to store the A/D converter data 12-bit value. The remaining two registers are control registers which setup the operating and control function of the A/D converter.
Page 90
HT45F5Q-3 Battery Charger 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.
HT45F5Q-3 Battery Charger Flash MCU Care must be taken if the SAINS2~SAINS0 bits are set to “001” to select the internal analog signal to be converted. When the internal analog signal is selected to be converted, the external input pin must never be selected as the A/D input signal by properly setting the SACS3~SACS0 bits with a value from 1010 to 1111.
HT45F5Q-3 Battery Charger Flash MCU There is an internal analog signal derived from 20×A2P, which can be connected to the A/D converter as the analog input signal by configuring the SAINS2~SAINS0 bits. If the external channel input is selected to be converted, the SAINS2~SAINS0 bits should be set to “000” or “101~111” and the SACS3~SACS0 bits can determine which external channel is selected.
HT45F5Q-3 Battery Charger Flash MCU Controlling the power on/off function of the A/D converter circuitry is implemented using the ADCEN bit in the SADC0 register. This bit must be set high to power on the A/D converter. When the ADCEN bit is set high to power on the A/D converter internal circuitry a certain delay, as indicated in the timing diagram, must be allowed before an A/D conversion is initiated.
HT45F5Q-3 Battery Charger Flash MCU • Step 4 If the A/D converter input signal comes from the external channel input selecting by configuring the SAINS bit field, the corresponding pins should be configured as A/D converter input function by configuring the relevant pin-shared function control bits. The desired analog channel then should be selected by configuring the SACS bit field.
HT45F5Q-3 Battery Charger Flash MCU The diagram shows the ideal transfer function between the analog input value and the digitised output value for the A/D converter. Except for the digitised zero value, the subsequent digitised values will change at a point 0.5 LSB below where they would change without the offset, and the last full scale digitised value will change at a point 1.5 LSB below the V...
Page 96
HT45F5Q-3 Battery Charger Flash MCU Example: using the interrupt method to detect the end of conversion clr ADE ; disable A/D converter interrupt mov a,03h ; select f /8 as A/D clock and mov SADC1,a ; select external channel input and external reference input mov a,0Ah ; setup PBS0 to configure pin AN0 and pin VREF mov PBS0,a mov a,20h mov SADC0,a ; enable A/D and connect AN0 channel to A/D converter Start_conversion: clr START ; high pulse on START bit to initiate conversion set START ; reset A/D clr START ; start A/D clr ADF ; clear ADC interrupt request flag...
HT45F5Q-3 Battery Charger Flash MCU Battery Charge Module The device contains a battery charge module which consists of three operational amplifies, a 14-bit and a 12-bit D/A converters. The OPA0 together with DAC0 and OPA1 together with DAC1 are used for battery charge constant current (CC) and constant voltage (CV) control respectively.
HT45F5Q-3 Battery Charger Flash MCU Digital to Analog Converter The battery charge module contains a 14-bit and 12-bit R2R D/A converters, namely DAC0 and DAC1. Their reference input voltage comes from V , and can be power down to save power.
HT45F5Q-3 Battery Charger Flash MCU Offset Calibration Procedure As the OPA2 input pin is pin-shared with other functions, it should be configured as the operational amplifier input first by the corresponding pin-shared function selection register. Step1: Set OOFM=1, the OPA2 is now under offset calibration mode. To make sure the input offset...
Page 101
HT45F5Q-3 Battery Charger Flash MCU a single SCS pin only one slave device can be utilized. The SCS pin is controlled by software, set CSEN bit to 1 to enable SCS pin function, set CSEN bit to 0 the SCS pin will be floating state.
Page 102
HT45F5Q-3 Battery Charger Flash MCU SPI Data Register The SIMD register is used to store the data being transmitted and received. The same register is used by both the SPI and I C functions. Before the device writes data to the SPI bus, the actual data to be transmitted must be placed in the SIMD register.
Page 103
HT45F5Q-3 Battery Charger Flash MCU Bit 1 SIMEN: USIM SPI/I C Enable Control 0: Disable 1: Enable The bit is the overall on/off control for the USIM SPI/I C interface. When the SIMEN bit is cleared to zero to disable the USIM SPI/I...
Page 104
HT45F5Q-3 Battery Charger Flash MCU Bit 3 MLS: SPI data shift order 0: LSB first 1: MSB first This is the data shift select bit and is used to select how the data is transferred, either MSB or LSB first. Setting the bit high will select MSB first and low for LSB first.
Page 106
HT45F5Q-3 Battery Charger Flash MCU SPI Transfer Write Data Clear WCOL UMD=0 into SIMD Master Slave WCOL=1? Master or Slave SIM[2:0]=000, 001, SIM[2:0]=101 Transmission 010, 011 or 100 completed? (TRF=1?) Configure CKPOLB, Read Data CKEG, CSEN and MLS from SIMD...
Page 107
HT45F5Q-3 Battery Charger Flash MCU SPI Bus Enable/Disable To enable the SPI bus, set CSEN=1 and SCS=0, then wait for data to be written into the SIMD (TXRX buffer) register. For the Master Mode, after data has been written to the SIMD (TXRX buffer) register, then transmission or reception will start automatically.
HT45F5Q-3 Battery Charger Flash MCU • Step 8 Clear TRF. • Step 9 Go to step 4. Slave Mode • Step 1 Select the SPI Slave mode using the UMD and SIM2~SIM0 bits in the SIMC0 control register • Step 2 Setup the CSEN bit and setup the MLS bit to choose if the data is MSB or LSB first, this setting must be the same with the Master devices.
Page 109
HT45F5Q-3 Battery Charger Flash MCU C Interface Operation The I C serial interface is a two line interface, a serial data line, SDA, and serial clock line, SCL. As many devices may be connected together on the same bus, their outputs are both open drain types.
Page 110
HT45F5Q-3 Battery Charger Flash MCU The SIMDEB1 and SIMDEB0 bits determine the debounce time of the I C interface. This uses the internal clock to in effect add a debounce time to the external clock to reduce the possibility of glitches on the clock line causing erroneous operation. The debounce time, if selected, can be chosen to be either 2 or 4 system clocks.
Page 111
HT45F5Q-3 Battery Charger Flash MCU • SIMA Register Name SIMA6 SIMA5 SIMA4 SIMA3 SIMA2 SIMA1 SIMA0 Bit 7~1 SIMA6~SIMA0: I C slave address SIMA6~SIMA0 is the I C slave address bit 6 ~ bit 0. Bit 0 D0: Reserved bit, can be read or written...
Page 112
HT45F5Q-3 Battery Charger Flash MCU Bit 1 SIMEN: USIM SPI/I C Enable Control 0: Disable 1: Enable The bit is the overall on/off control for the USIM SPI/I C interface. When the SIMEN bit is cleared to zero to disable the USIM SPI/I...
Page 113
HT45F5Q-3 Battery Charger Flash MCU Bit 2 SRW: I C Slave Read/Write flag 0: Slave device should be in receive mode 1: Slave device should be in transmit mode The SRW flag is the I C Slave Read/Write flag. This flag determines whether the master device wishes to transmit or receive data from the I C bus.
Page 114
HT45F5Q-3 Battery Charger Flash MCU Start CLR UMD SET SIM[2:0]=110 SET SIMEN Write Slave Address to SIMA C Bus Interrupt=? CLR USIME SET USIME Poll USIMF to decide Wait for Interrupt when to go to I C Bus ISR Go to Main Program...
Page 115
HT45F5Q-3 Battery Charger Flash MCU C Bus Slave Address Acknowledge Signal After the master has transmitted a calling address, any slave device on the I C bus, whose own internal address matches the calling address, must generate an acknowledge signal. The acknowledge signal will inform the master that a slave device has accepted its calling address.
Page 116
HT45F5Q-3 Battery Charger Flash MCU Start SIMTOF=1? SET SIMTOEN HAAS=1? CLR SIMTOF HTX=1? SRW=1? RETI Read from SIMD to CLR HTX release SCL Line SET HTX CLR TXAK RETI Dummy read from SIMD Write data to SIMD to to release SCL Line...
HT45F5Q-3 Battery Charger Flash MCU When an I C time-out counter overflow occurs, the counter will stop and the SIMTOEN bit will be cleared to zero and the SIMTOF bit will be set high to indicate that a time-out condition has occurred.
Page 118
HT45F5Q-3 Battery Charger Flash MCU • Separately enabled transmitter and receiver • 2-byte Deep FIFO Receive Data Buffer • RX pin wake-up function • Transmit and receive interrupts • Interrupts can be triggered by the following conditions: Transmitter Empty ♦...
Page 119
HT45F5Q-3 Battery Charger Flash MCU It should be noted that the actual register for data transmission and reception only exists as a single shared register in the Data Memory. This shared register known as the UTXR_RXR register is used for both data transmission and data reception.
Page 120
HT45F5Q-3 Battery Charger Flash MCU • UUSR Register The UUSR register is the status register for the UART, which can be read by the program to determine the present status of the UART. All flags within the UUSR register are read only. Further...
Page 121
HT45F5Q-3 Battery Charger Flash MCU Bit 2 URXIF: Receive UTXR_RXR data register status 0: UTXR_RXR data register is empty 1: UTXR_RXR data register has available data The URXIF flag is the receive data register status flag. When this read only flag is “0”, it indicates that the UTXR_RXR read data register is empty.
Page 122
HT45F5Q-3 Battery Charger Flash MCU When the UART is disabled, it will empty the buffer so any character remaining in the buffer will be discarded. In addition, the value of the baud rate counter will be reset. If the UART is disabled, all error and status flags will be reset. Also the UTXEN, URXEN, UTXBRK, URXIF, UOERR, UFERR, UPERR and UNF bits will be cleared, while the UTIDLE, UTXIF and URIDLE bits will be set.
Page 123
HT45F5Q-3 Battery Charger Flash MCU • UUCR2 Register The UUCR2 register is the second of the two UART control registers and serves several purposes. One of its main functions is to control the basic enable/disable operation of the UART Transmitter and Receiver as well as enabling the various USIM UART mode interrupt sources.
Page 124
HT45F5Q-3 Battery Charger Flash MCU Bit 3 UWAKE: RX pin wake-up UART function enable control 0: RX pin wake-up UART function is disabled 1: RX pin wake-up UART function is enabled This bit is used to control the wake-up UART function when a falling edge on the RX pin occurs.
Page 125
HT45F5Q-3 Battery Charger Flash MCU • UBRG Register Name UBRG7 UBRG6 UBRG5 UBRG4 UBRG3 UBRG2 UBRG1 UBRG0 “x”: unknown Bit 7~0 UBRG7~UBRG0: Baud Rate values By programming the UBRGH bit in UUCR2 Register which allows selection of the related formula described above and programming the required value in the UBRG register, the required baud rate can be setup.
Page 126
HT45F5Q-3 Battery Charger Flash MCU UART transmitter and receiver are functionally independent, they both use the same data format and baud rate. In all cases stop bits will be used for data transmission. Enabling/Disabling the UART Interface The basic on/off function of the internal UART function is controlled using the UREN bit in the UUCR1 register.
Page 127
HT45F5Q-3 Battery Charger Flash MCU UART Transmitter Data word lengths of either 8 or 9 bits can be selected by programming the UBNO bit in the UUCR1 register. When UBNO bit is set, the word length will be set to 9 bits. In this case the 9th bit, which is the MSB, needs to be stored in the UTX8 bit in the UUCR1 register.
Page 128
HT45F5Q-3 Battery Charger Flash MCU 1. A UUSR register access 2. A UTXR_RXR register write execution Note that both the UTXIF and UTIDLE bits are cleared by the same software sequence. Transmit Break If the UTXBRK bit is set then break characters will be sent on the next transmission. Break character transmission consists of a start bit, followed by 13×N ‘0’...
Page 129
HT45F5Q-3 Battery Charger Flash MCU Receive Break Any break character received by the UART will be managed as a framing error. The receiver will count and expect a certain number of bit times as specified by the values programmed into the UBNO bit plus one stop bit.
Page 130
HT45F5Q-3 Battery Charger Flash MCU Noise Error – UNF Over-sampling is used for data recovery to identify valid incoming data and noise. If noise is detected within a frame the following will occur: • The read only noise flag, UNF, in the UUSR register will be set on the rising edge of the URXIF bit.
Page 131
HT45F5Q-3 Battery Charger Flash MCU UART register section. The overall UART interrupt can be disabled or enabled by the USIM interrupt enable control bit in the interrupt control register of the microcontroller to decide whether the interrupt requested by the UART module is masked out or allowed.
HT45F5Q-3 Battery Charger Flash MCU that the UUSR, UUCR1, UUCR2, transmit and receive registers, as well as the UBRG register will not be affected. It is recommended to make sure first that the UART data transmission or reception has been finished before the microcontroller enters the IDLE or SLEEP mode.
Page 135
HT45F5Q-3 Battery Charger Flash MCU CRC Calculation Procedures 1. Clear the checksum register pair, CRCDH and CRCDL. 2. Execute an “Exclusive OR” operation with the 8-bit input data byte and the 16-bit CRCSUM high byte. The result is called the temporary CRCSUM.
HT45F5Q-3 Battery Charger 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 137
HT45F5Q-3 Battery Charger Flash MCU • INTEG Register Name — — — — INT1S1 INT1S0 INT0S1 INT0S0 — — — — — — — — Bit 7~4 Unimplemented, read as “0” Bit 3~2 INT1S1~INT1S0: Interrupt edge control for INT1 pin...
Page 138
HT45F5Q-3 Battery Charger Flash MCU • INTC1 Register5 Name MF1F MF0F TB1F MF1E MF0E TB1E Bit 7 ADF: A/D Converter interrupt request flag 0: No request 1: Interrupt request Bit 6 MF1F: Multi-function 1 interrupt request flag 0: No request...
HT45F5Q-3 Battery Charger Flash MCU • MFI0 Register Name — — CTMAF CTMPF — — CTMAE CTMPE — — — — — — — — Bit 7~6 Unimplemented, read as “0” Bit 5 CTMAF: CTM Comparator A match interrupt request flag...
Page 140
HT45F5Q-3 Battery Charger Flash MCU When an interrupt is generated, the Program Counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. The Program Counter will then be loaded with a new address which will be the value of the corresponding interrupt vector. The microcontroller will then fetch its next instruction from this interrupt vector.
HT45F5Q-3 Battery Charger Flash MCU External Interrupts The external interrupt is controlled by signal transitions on the pins INT0~INT1. An external interrupt request will take place when the external interrupt request flags, INT0F~INT1F, is set, which will occur when a transition, whose type is chosen by the edge select bits, appears on the external interrupt pins.
HT45F5Q-3 Battery Charger Flash MCU Multi-function Interrupts Within the device there are two Multi-function interrupts. Unlike the other independent interrupts, these interrupts have no independent source, but rather are formed from other existing interrupt sources, namely the TM Interrupts. A Multi-function interrupt request will take place when any of the Multi-function interrupt request flags, MFnF are set.
HT45F5Q-3 Battery Charger Flash MCU a transmitter data register empty, transmitter idle, receiver data available, receiver overrun, address detect and an RX pin wake-up, can generate a USIM interrupt with the USIMF flag bit set high. To allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, EMI, and the Universal Serial Interface Module Interrupt enable bit, USIME, must first be set.
According to the battery current condition, the charger can use a Buck circuit to implement charger management. The battery charging contains constant voltage Mode and Constant current Mode. The HT45F5Q-3 device is specifically designed for battery charger applications. The above-mentioned function control can be implemented by the integrated battery charger management, these are described below.
HT45F5Q-3 Battery Charger Flash MCU Constant Voltage Mode Description Constant voltage charging means that the charge voltage will remain at a constant value no matter how the battery internal resistance changes. The principle is that the charge voltage B+ is divided by R3 and R4 resistors and then supplied to the OPA1 negative terminal through the OPA1N pin.
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.
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.
HT45F5Q-3 Battery Charger 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 150
HT45F5Q-3 Battery Charger 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...
HT45F5Q-3 Battery Charger Flash MCU Instruction Definition ADC A,[m] Add Data Memory to ACC with Carry Description The contents of the specified Data Memory, Accumulator and the carry flag are added. The result is stored in the Accumulator. Operation ACC ← ACC + [m] + C...
Page 152
HT45F5Q-3 Battery Charger 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. The specified address is then loaded and the program continues execution from this new address.
Page 153
HT45F5Q-3 Battery Charger 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 154
HT45F5Q-3 Battery Charger 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 155
HT45F5Q-3 Battery Charger 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 156
HT45F5Q-3 Battery Charger 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 157
HT45F5Q-3 Battery Charger 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 158
HT45F5Q-3 Battery Charger 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 159
HT45F5Q-3 Battery Charger Flash MCU TABRD [m] Read table (specific page or current page) to TBLH and Data Memory Description The low byte of the program code addressed by the table pointer (TBHP and TBLP or only TBLP if no TBHP) is moved to the specified Data Memory and the high byte moved to TBLH.
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 for the latest version of the Package/Carton Information. Additional supplementary information with regard to packaging is listed below. Click on the relevant section to be transferred to the relevant website page.
HT45F5Q-3 Battery Charger Flash MCU 28-pin SSOP (150mil) Outline Dimensions & " Dimensions in inch Symbol Min. Nom. Max. — 0.236 BSC — — 0.154 BSC — 0.008 — 0.012 C’ — 0.390 BSC — — — 0.069 —...
Page 163
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.
Need help?
Do you have a question about the HT45F5Q-3 and is the answer not in the manual?
Questions and answers