
EM358x
226
Rev. 0.4
11.3 Operation
Setting the ADC_EN bit in the ADC_CFG register enables the ADC. Once the ADC is enabled, it performs
conversions continuously until it is disabled. If the ADC had previously been disabled, a 21 µs analog startup
delay is automatically imposed before the ADC starts conversions. The delay timing is performed in hardware and
is simply added to the time until the first conversion result is output.
When the ADC is first enabled, and/or if any change is made to ADC_CFG after it is enabled, the time until a
result is output is double the normal sample time. This is because the ADC’s internal design requires it to discard
the first conversion after startup or a configuration change. This is done automatically and is hidden from
software. Switching the system clock between OSCHF and OSC24M also causes the ADC to go through this
startup cycle. If the ADC was newly enabled, the analog delay time is added to the doubled sample time.
If the DMA is running when the ADC_CFG register is modified, the DMA does not stop, so the DMA buffer may
contain conversion results from both the old and new configurations.
The following procedure illustrates a simple polled method of using the ADC without DMA. This assumes that any
GPIOs and the voltage reference have already been configured.
1. Disable all ADC interrupts: Write 0 to the INT_ADCCFG register.
2. Write the desired offset and gain correction values to the ADC_OFFSET and ADC_GAIN registers.
3. Write the desired conversion configuration, with the ADC_EN bit set, to ADC_CFG register.
4. Clear the ADC data flag: Write the INT_ADCDATA bit to INT_ADCFLAG register.
5. Wait until the INT_ADCDATA bit is set in INT_ADCFLAG register, then read the result, as a 16-bit signed
variable, from the ADC_DATA register.
The following procedure illustrates a simple polled method of using the ADC with DMA. After completing the
procedure, the latest conversion results are available in the location written to by the DMA. This assumes that any
GPIOs and the voltage reference have already been configured.
1. Allocate a 16-bit signed variable, for example analogData, to receive the ADC output.
(Make sure that analogData is half-word aligned – that is, at an even address.)
2. Disable all ADC interrupts: Write 0 to the INT_ADCCFG register.
3. Set up the DMA to output conversion results to the variable, analogData.
Reset the DMA: Set the ADC_DMARST bit in ADC_DMACFG register.
Define a one sample buffer: Write analogData’s address to the ADC_DMABEG register and set the
ADC_DMASIZE register to 1.
4. Write the desired offset and gain correction values to the ADC_OFFSET and ADC_GAIN registers.
5. Start the ADC and the DMA.
Write the desired conversion configuration, with the ADC_EN bit set, to the ADC_CFG register.
Clear the ADC buffer full flag: Write the INT_ADCULDFULL bit to the INT_ADCFLAG register.
Start the DMA in auto wrap mode: Set the ADC_DMAAUTOWRAP and ADC_DMALOAD bits in the
ADC_DMACFG register.
6. Wait until the INT_ADCULDFULL bit is set in the INT_ADCFLAG register, then read the result from
analogData.
To convert multiple inputs using this approach, repeat steps 4 through 6, loading the desired input configurations
to the ADC_CFG register in step 5. If the inputs can use the same offset/gain correction, just repeat steps 5 and
6.
11.4 Calibration
Sampling of internal connections GND, VREF/2, and VREF allow for offset and gain calibration of the ADC in
applications where absolute accuracy is important. Offset error is calculated from the minimum input and gain
error is calculated from the full scale input range. Correction using VREF is recommended because VREF is
calibrated by the Ember software against VDD_PADSA. The VDD_PADSA regulator is factory-trimmed to 1.80 V
Содержание EMBER EM358 series
Страница 2: ...EM358x 2 Rev 0 4 ...
Страница 7: ...EM358x Rev 0 4 7 ...