Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Analog-to-digital converter<br />
<strong>STM32W108C8</strong><br />
11.2 Interrupts<br />
The ADC has its own ARM ® Cortex-M3 vectored interrupt with programmable priority. The<br />
ADC interrupt is enabled by writing the INT_ADC bit to the INT_CFGSET register, and<br />
cleared by writing the INT_ADC bit to the INT_CFGCLR register. Section 12: Interrupts on<br />
page 174 describes the interrupt system in detail.<br />
Note:<br />
Four kinds of ADC events can generate an ADC interrupt, and each has a bit flag in the<br />
INT_ADCFLAG register to identify the reason(s) for the interrupt:<br />
● INT_ADCOVF – an ADC conversion result was ready but the DMA was disabled (DMA<br />
buffer overflow).<br />
● INT_ADCSAT– the gain correction multiplication exceeded the limits for a signed 16-bit<br />
number (gain saturation).<br />
● INT_ADCULDFULL – the DMA wrote to the last location in the buffer (DMA buffer full).<br />
● INT_ADCULDHALF – the DMA wrote to the last location of the first half of the DMA<br />
buffer (DMA buffer half full).<br />
Bits in INT_ADCFLAG may be cleared by writing a 1 to their position.<br />
The INT_ADCCFG register controls whether or not INT_ADCFLAG bits actually request the<br />
ARM ® Cortex-M3 ADC interrupt; only the events whose bits are 1 in INT_ADCCFG can do<br />
so.<br />
For non-interrupt (polled) ADC operation set INT_ADCCFG to zero, and read the bit flags in<br />
INT_ADCFLAG to determine the ADC status.<br />
When making changes to the ADC configuration it is best to disable the DMA beforehand. If<br />
this isn’t done it can be difficult to determine at which point the sample data in the DMA<br />
buffer switch from the old configuration to the new configuration. However, since the ADC<br />
will be left running, if it completes a conversion after the DMA is disabled, the INT_ADCOVF<br />
flag will be set. To prevent these unwanted DMA buffer overflow indications, clear the<br />
INT_ADCOVF flag immediately after enabling the DMA, preferably with interrupts off.<br />
Disabling the ADC in addition to the DMA is often undesirable because of the additional<br />
analog startup time when it is re-enabled.<br />
167/215 Doc ID 018587 Rev 2