ST AN3116 Application note

AN3116

Application note

STM32™’s ADC modes and their applications

Introduction

STM32 microcontrollers have one of the most advanced ADCs on the microcontroller market. You could imagine a multitude of applications based on the STM32 ADC features. Some ADC modes are provided to simplify measurements and give efficient results in applications such as motor control.

This application note provides help for ADC users to understand some advanced modes offered in the STM32 microcontrollers, and to quick start development. Each of the described modes is provided with an example of application to better understand how to use them. Most modes come with a basic firmware to make it easier to understand the ADC configuration.

This application note is divided into two sections: independent modes and dual modes. The first section describes modes used with a single ADC. The second section describes modes that should be used with two ADCs (ADC1 and ADC2 working jointly).

This application note does not describe the ADC modes that result from the combination of other modes.

March 2010

Doc ID 16840 Rev 1

1/18

www.st.com

Contents

AN3116

 

 

Contents

1

Independent modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

 

1.1 Single-channel, single conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . .

5

1.1.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.2

Multichannel (scan), single conversion mode . . . . . . . . . . . . . . . . . . . . . .

5

 

1.2.1

Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

 

1.2.2

Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

1.3 Single-channel continuous conversion mode . . . . . . . . . . . . . . . . . . . . . . . 6

1.3.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.3.2 Example of applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.4 Multichannel (scan) continuous conversion mode . . . . . . . . . . . . . . . . . . . 7

1.4.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

 

1.5 Injected conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

 

1.5.1

Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

 

1.5.2

Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

2

Dual modes

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9

2.1 Dual regular simultaneous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.1.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.2 Dual fast interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.2.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.3 Dual slow interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.3.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.3.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.4 Dual alternate trigger mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.4.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.4.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.5 Dual combined regular/injected simultaneous mode . . . . . . . . . . . . . . . . 14

2.5.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.5.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2/18

Doc ID 16840 Rev 1

AN3116

Contents

 

 

2.6 Dual combined: injected simultaneous + interleaved mode . . . . . . . . . . . 14

2.6.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.6.2 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16

4

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17

Doc ID 16840 Rev 1

3/18

List of figures

AN3116

 

 

List of figures

Figure 1. Single-channel, single conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 2. ADC sequencer converting 7 channels with different configured sampling

times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 3. Multichannel, single conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 4. Single-channel, continuous conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 5. Multichannel, continuous conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 6. Injected conversion mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 7. Dual regular simultaneous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 8. Simultaneous measurement of voltage and current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 9. Dual fast interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 10. Dual slow interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Figure 11. Dual alternate trigger mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Figure 12. Dual combined regular/injected simultaneous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Figure 13. Dual combined: injected simultaneous + interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . 15 Figure 14. UPS system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4/18

Doc ID 16840 Rev 1

ST AN3116 Application note

AN3116

Independent modes

 

 

1 Independent modes

1.1Single-channel, single conversion mode

1.1.1Description

 

This is the simplest ADC mode. In this mode, the ADC performs the single conversion

 

(single sample) of a single channel x (refer to Figure 1.) and stops after completion of the

 

conversion.

Note:

This application note is not delivered with a firmware example of this mode.

 

Figure 1. Single-channel, single conversion mode

 

 

3TART

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#(X

 

 

 

 

 

 

 

 

 

 

 

 

3TOP

 

 

 

 

AI

 

 

1.1.2

Example of application

 

This mode can be used for the measurement of a voltage level to decide if the system can

 

be started or not. Measure the voltage level of the battery before starting the system: if the

 

battery has a low level, the “low battery” message appears. In this case, do not start the

 

system.

1.2Multichannel (scan), single conversion mode

1.2.1Description

This mode is used to convert some channels successively in independent mode. With the ADC sequencer, you can use this ADC mode to configure any sequence of up to 16 channels successively with different sampling times and in different orders. You can for example carry out the sequence shown in Figure 2. In this way, you do not have to stop the ADC during the conversion process in order to reconfigure the next channel with a different sampling time. This mode saves additional CPU load and heavy software development.

Figure 2. ADC sequencer converting 7 channels with different configured sampling times

Note:

This application note is not delivered with a firmware example of this mode.

Doc ID 16840 Rev 1

5/18

Independent modes

AN3116

 

 

Figure 3. Multichannel, single conversion mode

3TART

#(X

#(N

3TOP

AI

1.2.2Example of application

This mode can be used when starting a system depends on some parameters like knowing the coordinates of the arm’s tip in a manipulator arm system. In this case, you have to read the position of each articulation in the manipulator arm system at power-on to determine the coordinates of the arm’s tip.

This mode can also be used to make single measurements of multiple signal levels (voltage, pressure, temperature, etc.) to decide if the system can be started or not in order to protect the people and equipment.

It can likewise be used to convert signals coming from strain gauges to determine the directions and values of the different strains and deformations of an object.

1.3Single-channel continuous conversion mode

1.3.1Description

The single-channel continuous conversion mode converts a single channel continuously and indefinitely in regular channel conversion.

The continuous mode feature allows the ADC to work in the background. The ADC converts the channels continuously without any intervention from the CPU. Additionally, the DMA can be used in circular mode, thus reducing the CPU load.

Note:

An example of firmware is provided with this application note: SingleChannelContinuous.

 

The example uses two methods: DMA and interrupts. To select either method, simply

 

comment or uncomment #define USE_DMA_Transfer in the main.c file.

 

Figure 4. Single-channel, continuous conversion mode

3TART

#(X

AI

6/18

Doc ID 16840 Rev 1

Loading...
+ 12 hidden pages