Rev. 1.00
80
August 29, 2018
Rev. 1.00
81
August 29, 2018
HT45F6530
AC Voltage Regulator Flash MCU
HT45F6530
AC Voltage Regulator Flash MCU
Programming Considerations
During microcontroller operations where the A/D converter is not being used, the A/D internal
circuitry can be switched off to reduce power consumption, by clearing bit ADCEN to 0 in the
SADC0 register. When this happens, the internal A/D converter circuits will not consume power
irrespective of what analog voltage is applied to their input lines. If the A/D converter input lines are
used as normal I/Os, then care must be taken as if the input voltage is not at a valid logic level, then
this may lead to some increase in power consumption.
A/D Conversion Function
As the device contains a 12-bit A/D converter, its full-scale converted digitised value is equal
to 0FFFH. Since the full-scale analog input value is equal to the actual A/D converter reference
voltage, V
REF
, this gives a single bit analog input value of V
REF
divided by 4096.
1 LSB=V
REF
÷4096
The A/D Converter input voltage value can be calculated using the following equation:
A/D input voltage=A/D output digital value×(V
REF
÷4096)
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
REF
level. Note that here the
V
REF
voltage is the actual A/D converter reference voltage determined by the SAVRS field.
FFFH
FFEH
FFDH
03H
02H
01H
0
1
2
3
4093 4094 4095 4096
V
REF
4096
Analog Input Voltage
A/D Conversion
Result
1.5 LSB
0.5 LSB
Ideal A/D Transfer Function
A/D Conversion Programming Examples
The following two programming examples illustrate how to setup and implement an A/D conversion.
In the first example, the method of polling the ADBZ bit in the SADC0 register is used to detect
when the conversion cycle is complete, whereas in the second example, the A/D interrupt is used to
determine when the conversion is complete.
Example: Using an ADBZ polling method to detect the end of conversion
clr
ADE
;
disable
ADC
interrupt
mov
a,03H ;
select
f
SYS
/8 as A/D clock and A/D input
mov SADC1,a ; signal comes from external channel
mov a,00H ; select V
DD
as the A/D reference voltage source
mov SADC2,a