
Analog / digital converter
UM0404
DocID13284 Rev 2
otherwise the input multiplexer will switch to the new channel. It is recommended to only
change the channel number with no injected conversion running (see
).
A channel injection can be triggered in two ways:
•
Setting the Channel Injection Request bit ADCRQ via software a compare or a capture
event of Capture/Compare register CC31 of the CAPCOM2 Unit, which also sets bit
ADCRQ.
•
Triggering a channel injection at a specific time on the occurrence of a predefined
count value of the CAPCOM timers or on a capture event of register CC31. This can be
either the positive, negative, or both the positive and the negative edge of an external
signal. In addition, this option allows recording the time of occurrence of this signal.
Note:
The channel injection request bit ADCRQ will be set on any interrupt request of CAPCOM2
channel CC31, regardless whether the channel injection mode is enabled or not. It is
recommended to always clear bit ADCRQ before enabling the channel injection mode.
While an injected conversion is in progress, no further channel injection request can be
triggered. The Channel Injection Request flag ADCRQ remains set until the result of the
injected conversion is written to the ADDAT2 register.
If the converter was idle before the channel injection, and during the injected conversion the
converter is started by software for normal conversions, the channel injection is aborted,
and the converter starts in the selected mode (as described above). This can be avoided by
checking the busy bit ADBSY before starting a new operation.
When Port1 channels are used in addition to those of Port5, attention must be paid in
managing the channel injection mode. When the injection is controlled via software, the
status of bit ADCMUX in register XMISC should be considered:
•
If the channel to inject is on Port5, and ADCMUX is set, before setting bit ADCRQ in
register ADCON, bit ADCMUX needs to be reset;
•
If the channel to inject is on Port1, and ADCMUX is reset, before setting bit ADCRQ in
register ADCON, bit ADCMUX needs to be set;
•
If the channel to inject is on Port5, and ADCMUX is reset, setting bit ADCRQ in register
ADCON will properly inject the right channel;
•
If the channel to inject is on Port1, and ADCMUX is set, setting bit ADCRQ in register
ADCON will properly inject the right channel.
When the injection is not controlled via software, the status of the bit ADCMUX cannot be
checked: this implies that the analog signal to convert as injected channel, must be
available on both the channel banks on Port5 and Port1. This is true when the channel to
inject is mapped on P5(7:0) or P1(7:0): supposing channel to inject is channel #3, P5.3 and
P1.3 pins must be externally shorted, providing the analog signal to both. On the contrary,
when the channel to inject is on P5(15:8), there is no correspondent channel on Port1: this
means that if ADCMUX is set at the time the injection is triggered, an unpredictable result is
expected, since the A/D converter analog input is left floating.
After the completion of the current conversion (if any is in progress) the converter will start
(inject) the conversion of the specified channel. When the conversion of this channel is
complete, the result will be placed into the alternate result register ADDAT2, and a Channel
Injection Complete Interrupt request will be generated, which uses the interrupt request flag
ADEIR (for this reason the Wait for ADDAT Read Mode is required).