Example description
3ADCs_DMA
Example Description
This example describes how to use the 3 ADCs in independant conversions.
Two of them; ADC1 and ADC3 are transfering continuously converted data using DMA
while ADC2 converted data are stored using End of conversion interrupt.
ADC1 is configured to converts continuously ADC channel14. Each time an end of
conversion occurs the DMA1 transfers, in circular mode, the converted data from
ADC1 DR register to the ADC1_ConvertedValue variable.
ADC2 is configured to converts continuously ADC channel13. Each time an end of
conversion occurs an end of conversion interrupt is generated and inside the
interrupt routine the converted data are read from ADC2 DR register and stored
into the ADC2_ConvertedValue variable.
ADC3 is configured to converts continuously ADC channel12. Each time an end of
conversion occurs the DMA2 transfers, in circular mode, the converted data from
ADC3 DR register to the ADC3_ConvertedValue variable.
The ADCs clocks are set to 14 MHz.
The result of ADC1, ADC2 and ADC3 conversion is monitored through the three
variables: ADC1ConvertedValue, ADC2ConvertedValue and ADC3ConvertedValue.
Directory contents
- ADC/3ADCs_DMA/stm32f10x_conf.h Library Configuration file
- ADC/3ADCs_DMA/stm32f10x_it.c Interrupt handlers
- ADC/3ADCs_DMA/stm32f10x_it.h Interrupt handlers header file
- ADC/3ADCs_DMA/main.c Main program
Hardware and Software environment
- This example runs only on STM32F10x High-Density Devices.
- This example has been tested with STMicroelectronics STM3210E-EVAL (STM32F10x
High-Density) evaluation board and can be easily tailored to any other
supported device and development board.
- STM3210E-EVAL Set-up
- Connect a variable power supply 0-3.3V to ADC Channel12 mapped on pin PC.02
- Connect a variable power supply 0-3.3V to ADC Channel13 mapped on pin PC.03
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1 on STM3210E-EVAL board)
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm32f10x_adc.c
- stm32f10x_dma.c
- stm32f10x_flash.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- misc.c
- Edit stm32f10x.h file to select the device you are working on (#define
STM32F10X_HD, in this case).
Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm32f10x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
note
- Low-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
--------------------------------------------------------------------------------
ADC1_DMA
Example Description
This example describes how to use the ADC1 and DMA to transfer continuously
converted data from ADC1 to memory.
The ADC1 is configured to converts continuously ADC channel14.
Each time an end of conversion occurs the DMA transfers, in circular mode, the
converted data from ADC1 DR register to the ADC_ConvertedValue variable.
The ADC1 clock is set to 14 MHz.
Directory contents
- ADC/ADC1_DMA/stm32f10x_conf.h Library Configuration file
- ADC/ADC1_DMA/stm32f10x_it.c Interrupt handlers
- ADC/ADC1_DMA/stm32f10x_it.h Interrupt handlers header file
- ADC/ADC1_DMA/main.c Main program
Hardware and Software environment
- This example runs on STM32F10x Connectivity line, High-Density, Medium-Density
and Low-Density Devices.
- This example has been tested with STMicroelectronics STM3210C-EVAL (STM32F10x
Connectivity line), STM3210E-EVAL (STM32F10x High-Density) and STM3210B-EVAL
(STM32F10x Medium-Density) evaluation boards and can be easily tailored to
any other supported device and development board.
- STM3210C-EVAL Set-up
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1)
- STM3210E-EVAL Set-up
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1)
- STM3210B-EVAL Set-up
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1)
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm32f10x_adc.c
- stm32f10x_dma.c
- stm32f10x_flash.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- Edit stm32f10x.h file to select the device you are working on.
Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm32f10x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
note
- Low-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
--------------------------------------------------------------------------------
Analog Watchdog
Example Description
This example describes how to use the ADC analog watchdog to guard continuously
an ADC channel.
The ADC1 is configured to convert continuously ADC channel14. The analog watchdog
is configured and enabled to guard a single regular channel.
Each time the channel14 converted value exceed programmed analog watchdog high
threshold (value 0x0B00) or goes down analog watchdog low threshold (value 0x0300)
an AWD interrupt is generated and the output pin connected to LED1 is toggled. The
LED will bright as long as the AWD interrupt is generated which means that the
converted value of regular ADC channel14 is outside the range limited by high and
low analog watchdog thresholds.
The ADC1 clock is set to 14 MHz.
Directory contents
- ADC/AnalogWatchdog/stm32f10x_conf.h Library Configuration file
- ADC/AnalogWatchdog/stm32f10x_it.c Interrupt handlers
- ADC/AnalogWatchdog/stm32f10x_it.h Interrupt handlers header file
- ADC/AnalogWatchdog/main.c Main program
Hardware and Software environment
- This example runs on STM32F10x Connectivity line, High-Density, Medium-Density
and Low-Density Devices.
- This example has been tested with STMicroelectronics STM3210C-EVAL (STM32F10x
Connectivity line), STM3210E-EVAL (STM32F10x High-Density) and STM3210B-EVAL
(STM32F10x Medium-Density) evaluation boards and can be easily tailored to
any other supported device and development board.
To select the STMicroelectronics evaluation board used to run the example,
uncomment the corresponding line in stm32_eval.h file (under Utilities\STM32_EVAL)
- STM3210C-EVAL Set-up
- Use LED1 led connected to PD.07 pin
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1)
- STM3210E-EVAL Set-up
- Use LD1 led connected to PF.06 pin
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1)
- STM3210B-EVAL
- Use LD1 led connected to PC.06 pin
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin PC.04
(potentiometer RV1)
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm32f10x_adc.c
- stm32f10x_gpio.c
- stm32f10x_flash.c
- stm32f10x_rcc.c
- stm32f10x_exti.c
- misc.c
- stm32f10x_usart.c
- system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
- stm32_eval.c (under Utilities\STM32_EVAL)
- Edit stm32f10x.h file to select the device you are working on.
- Edit stm32_eval.h file to select the evaluation board you will use.
Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm32f10x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
note
- Low-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
--------------------------------------------------------------------------------
ExtLinesTrigger
Example Description
This example describes how to trigger ADC regular and injected groups channels
conversion using two external line events. Discontinuous mode is enabled for regular
group channel conversion and configured to convert one regular channel on each
external trigger.
ADC1 is configured to start regular group channel conversion on EXTI11 event.
On detection of the first rising edge on PE.11 pin, the conversion of the first regular
channel (ADC channel4) is done and its converted value is transfered by DMA to
ADC_RegularConvertedValueTab table. On the following edge detection, the second
regular channel (ADC channel14) is automatically converted and its converted value
is stored by DMA in the same table. The number of transmitted data by DMA, in this
example is limited to 64 data.
The procedure is repeated for both regular channels on each EXTI11 event.
ADC1 is configured to start injected group channel conversion on EXTI15 event.
On detection of the first rising edge on PE.15 pin all selected injected channels, which
are two in this example (ADC channel11 and channel12), are converted and an interrupt
is generated on JEOC flag rising at the end of all injected channels conversion.
Both injected channels converted results are stored in ADC_InjectedConvertedValueTab
table inside the interrupt routine.
The procedure is repeated for injected channels on each EXTI15 event.
The ADC1 clock is set to 14 MHz.
Directory contents
- ADC/ExtLinesTrigger/stm32f10x_conf.h Library Configuration file
- ADC/ExtLinesTrigger/stm32f10x_it.c Interrupt handlers
- ADC/ExtLinesTrigger/stm32f10x_it.h Interrupt handlers header file
- ADC/ExtLinesTrigger/main.c Main program
Hardware and Software environment
- This example runs on STM32F10x Connectivity line, High-Density, Medium-Density
and Low-Density Devices.
- This example has been tested with STMicroelectronics STM3210C-EVAL (STM32F10x
Connectivity line), STM3210E-EVAL (STM32F10x High-Density) and STM3210B-EVAL
(STM32F10x Medium-Density) evaluation boards and can be easily tailored to
any other supported device and development board.
- STM3210C-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1), ADC Channel4 mapped on pin PA.04, ADC Channel11
mapped on pin PC.01 and ADC Channel12 mapped on pin PC.02.
- Connect a push-button to pin PE.11 (EXTI Line11) and another push-button
to pin PE.15 (EXTI Line15).
- STM3210E-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1), ADC Channel4 mapped on pin PA.04, ADC Channel11
mapped on pin PC.01 and ADC Channel12 mapped on pin PC.02.
- Connect a push-button to pin PE.11 (EXTI Line11) and another push-button
to pin PE.15 (EXTI Line15).
- STM3210B-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1), ADC Channel4 mapped on pin PA.04, ADC Channel11
mapped on pin PC.01 and ADC Channel12 mapped on pin PC.02.
- Connect a push-button to pin PE.11 (EXTI Line11) and another push-button
to pin PE.15 (EXTI Line15).
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm32f10x_adc.c
- stm32f10x_dma.c
- stm32f10x_exti.c
- stm32f10x_flash.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- misc.c
- Edit stm32f10x.h file to select the device you are working on.
Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm32f10x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
note
- Low-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
--------------------------------------------------------------------------------
RegSimul_DualMode
Example Description
This example describes how to use ADC1 and ADC2 in regular simultaneous dual mode.
ADC1 is configured to convert channel14 and channel17 regular channels continuously.
ADC2 is configured to convert channel11 and channel12 regular channels continuously.
The connection between internal Vref and channel17 is enabled for ADC1.
Once the regular channels conversion is started by software, channel14 is converted
on ADC1 and channel11 is converted on ADC2 on the same time. The 32bits conversion
result is then stored on ADC1 DR register. The DMA will transfer this data which
will be stored ADC_DualConvertedValueTab table. Consecutively to those conversion,
channel17 is converted on ADC1 and channel12 on ADC2. The combined conversion
result is also transfered by DMA to the same destination buffer.
The same procedure is repeated until the specified number of data to be transfered
by DMA is reached.
The ADC1 clock is set to 14 MHz.
Directory contents
- ADC/RegSimul_DualMode/stm32f10x_conf.h Library Configuration file
- ADC/RegSimul_DualMode/stm32f10x_it.c Interrupt handlers
- ADC/RegSimul_DualMode/stm32f10x_it.h Interrupt handlers header file
- ADC/RegSimul_DualMode/main.c Main program
Hardware and Software environment
- This example runs on STM32F10x Connectivity line, High-Density, Medium-Density
and Low-Density Devices.
- This example has been tested with STMicroelectronics STM3210C-EVAL (STM32F10x
Connectivity line), STM3210E-EVAL (STM32F10x High-Density) and STM3210B-EVAL
(STM32F10x Medium-Density) evaluation boards and can be easily tailored to
any other supported device and development board.
- STM3210C-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1), ADC Channel11 mapped on pin PC.01 and ADC
Channel12 mapped on pin PC.02.
- STM3210E-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1), ADC Channel11 mapped on pin PC.01 and ADC
Channel12 mapped on pin PC.02.
- STM3210B-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1), ADC Channel11 mapped on pin PC.01 and ADC
Channel12 mapped on pin PC.02.
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm32f10x_adc.c
- stm32f10x_dma.c
- stm32f10x_flash.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- Edit stm32f10x.h file to select the device you are working on.
Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm32f10x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
note
- Low-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
--------------------------------------------------------------------------------
TIMTrigger_AutoInjection
Example Description
This example describes how to convert ADC regular group channels continuously using
TIM1 external trigger and injected group channels using the auto-injected feature.
ADC1 is configured to convert on each TIM1 capture compare event ADC channel14.
Each time an end of regular conversion occurs the DMA transfers, the converted data
from ADC1 DR register to the ADC_RegularConvertedValueTab table.
Enabling the auto-injected feature, allows to convert automatically the injected
channel ADC channel11 after the end of the regular channel14. An ADC interrupt is
generated then by JEOC flag at the end of the injected channel conversion and in
the interrupt routine the result is stored in the ADC_InjectedConvertedValueTab table.
The procedure is repeated 32 times then the TIM1 peripheral is disabled and thus,
no conversion will be done neither regular or injected.
TIM1 start conversion triggers can be visualized on oscilloscope on PA.08 and at the
same time the toggle of pin PC.06 which indicates the automatic auto-injection conversion.
The ADC1 clock is set to 14 MHz.
Directory contents
- ADC/TIMTrigger_AutoInjection/stm32f10x_conf.h Library Configuration file
- ADC/TIMTrigger_AutoInjection/stm32f10x_it.c Interrupt handlers
- ADC/TIMTrigger_AutoInjection/stm32f10x_it.h Interrupt handlers header file
- ADC/TIMTrigger_AutoInjection/main.c Main program
Hardware and Software environment
- This example runs on STM32F10x Connectivity line, High-Density, Medium-Density
and Low-Density Devices.
- This example has been tested with STMicroelectronics STM3210C-EVAL (STM32F10x
Connectivity line), STM3210E-EVAL (STM32F10x High-Density) and STM3210B-EVAL
(STM32F10x Medium-Density) evaluation boards and can be easily tailored to
any other supported device and development board.
- STM3210C-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1) and ADC Channel11 mapped on pin PC.01
- Connect PA.08 and PC.06 pins to an oscilloscope
- STM3210E-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1) and ADC Channel11 mapped on pin PC.01
- Connect PA.08 and PC.06 pins to an oscilloscope
- STM3210B-EVAL Set-up
- Connect a known voltage, between 0-3.3V, to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1) and ADC Channel11 mapped on pin PC.01
- Connect PA.08 and PC.06 pins to an oscilloscope
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm32f10x_adc.c
- stm32f10x_dma.c
- stm32f10x_flash.c
- stm32f10x_tim.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- misc.c
- Edit stm32f10x.h file to select the device you are working on.
Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm32f10x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
note
- Low-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.