Rev. 1.10
100
November 04, 2019
Rev. 1.10
101
November 04, 2019
HT45F5Q-3
Battery Charger Flash MCU
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
voltage V
OS
as minimise as possible after calibration, the input reference voltage in calibration
mode should be the same as input DC operating voltage in normal mode operation.
Step2: Set OOF[5:0]=000000 then read OPO flag.
Step3: Let OOF[5:0]=OOF[5:0]+1 then read OPO flag, if the OPO flag state is changed, record the
data as V
OS1
.
Step4: Set OOF[5:0]=111111 then read OPO flag.
Step5: Let OOF[5:0]=OOF[5:0]-1 then read OPO flag, if the OPO flag state is changed; record the
data as V
OS2
.
Step6: restore V
OS
=(V
OS1
+V
OS2
)/2 to OOF[5:0] bits, the calibration is finished.
If (V
OS1
+V
OS2
)/2 is not integral, discard the decimal.
Residue V
OS
=V
OUT
–V
IN
.
Universal Serial Interface Module – USIM
The device contains a Universal Serial Interface Module, which includes the four-line SPI interface, the
two-line I
2
C interface and the two-line UART interface types, to allow an easy method of communication
with external peripheral hardware. Having relatively simple communication protocols, these serial
interface types allow the microcontroller to interface to external SPI, I
2
C or UART based hardware
such as sensors, Flash or EEPROM memory, etc. The USIM interface pins are pin-shared with other
I/O pins therefore the USIM interface functional pins must first be selected using the corresponding
pin-shared function selection bits. As all the interface types share the same pins and registers, the choice
of whether the UART, SPI or I
2
C type is used is made using the UART mode selection bit, named
UMD, and the SPI/I
2
C operating mode control bits, named SIM2~SIM0, in the SIMC0 register. These
pull-high resistors of the USIM pin-shared I/O are selected using pull-high control registers when the
USIM function is enabled and the corresponding pins are used as USIM input pins.
SPI Interface
The SPI interface is often used to communicate with external peripheral devices such as sensors,
Flash or EEPROM memory devices etc. Originally developed by Motorola, the four line SPI
interface is a synchronous serial data interface that has a relatively simple communication protocol
simplifying the programming requirements when communicating with external hardware devices.
The communication is full duplex and operates as a slave/master type, where the device can be
either master or slave. Although the SPI interface specification can control multiple slave devices
from a single master, but the device provides only one SCS pin. If the master needs to control
multiple slave devices from a single master, the master can use I/O pin to select the slave devices.
SPI Interface Operation
The SPI interface is a full duplex synchronous serial data link. It is a four line interface with pin
names SDI, SDO, SCK and SCS. Pins SDI and SDO are the Serial Data Input and Serial Data
Output lines, the SCK pin is the Serial Clock line and SCS is the Slave Select line. As the SPI
interface pins are pin-shared with normal I/O pins and with the I
2
C/UART function pins, the SPI
interface pins must first be selected by configuring the pin-shared function selection bits and setting
the correct bits in the SIMC0 and SIMC2 registers. Communication between devices connected
to the SPI interface is carried out in a slave/master mode with all data transfer initiations being
implemented by the master. The Master also controls the clock signal. As the device only contains