HT56R66 Holtek Semiconductor Inc., HT56R66 Datasheet - Page 52

no-image

HT56R66

Manufacturer Part Number
HT56R66
Description
Tinypower Tm A/d Type With Lcd 8-bit Otp Mcu
Manufacturer
Holtek Semiconductor Inc.
Datasheet
Note:
The accompanying diagram shows graphically the vari-
ous stages involved in an analog to digital conversion
process and its associated timing.
The setting up and operation of the A/D converter func-
tion is fully under the control of the application program as
there are no configuration options associated with the
A/D converter. After an A/D conversion process has been
initiated by the application program, the microcontroller
Rev. 1.10
Step 5
If the interrupts are to be used, the interrupt control reg-
isters must be correctly configured to ensure the A/D
converter interrupt function is active. The master inter-
rupt control bit, EMI, in the INTC0 interrupt control reg-
ister must be set to 1 , the multi-function interrupt
enable bit, EMFI, in the INTC1 register and the A/D
converter interrupt bit, EADI, in the INTC1 register
must also be set to 1 .
Step 6
The analog to digital conversion process can now be
initialised by setting the START bit in the ADCR regis-
ter from 0 to 1 and then to 0 again. Note that this
bit should have been originally set to 0 .
Step 7
To check when the analog to digital conversion pro-
cess is complete, the EOCB bit in the ADCR register
can be polled. The conversion process is complete
when this bit goes low. When this occurs the A/D data
registers ADRL and ADRH can be read to obtain the
conversion value. As an alternative method if the in-
terrupts are enabled and the stack is not full, the pro-
gram can wait for an A/D interrupt to occur.
When checking for the end of the conversion
process, if the method of polling the EOCB bit in
the ADCR register is used, the interrupt enable
step above can be omitted.
A/D Conversion Timing
52
internal hardware will begin to carry out the conversion,
during which time the program can continue with other
functions. The time taken for the A/D conversion is 16t
where t
Programming Considerations
When programming, special attention must be given to
the A/D channel selection bits in the register. If these
bits are all cleared to zero no external pins will be se-
lected for use as A/D input pins allowing the pins to be
used as normal I/O pins. When this happens the power
supplied to the internal A/D circuitry will be reduced re-
sulting in a reduction of supply current. This ability to re-
duce power by turning off the internal A/D function by
clearing the A/D channel selection bits may be an impor-
tant consideration in battery powered applications. The
ADONB bit in the ACSR register can also be used to
power down the A/D function.
Another important programming consideration is that
when the A/D channel selection bits change value, the
A/D converter must be re-initialised. This is achieved by
pulsing the START bit in the ADCR register immediately
after the channel selection bits have changed state. The
exception to this is where the channel selection bits are
all cleared, in which case the A/D converter is not re-
quired to be re-initialised.
A/D Programming Example
The following two programming examples illustrate how
to setup and implement an A/D conversion. In the first
example, the method of polling the EOCB bit in the
ADCR 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.
AD
is equal to the A/D clock period.
HT56R66/HT56R666
September 8, 2009
AD

Related parts for HT56R66