Example description
DMA_ADC_TIM1
Example Description
This example provides a description of how to use a DMA channel to transfer
continuously a data from a peripheral (ADC1) to another peripheral (TIM1) supporting
DMA transfer.
The ADC channel14 is configured to be converted continuously. TIM1_CH1 is configured
to generate a PWM signal on its output.
The dedicated DMA1 channel5 is configured to transfer in circular mode the last ADC
channel14 converted value to the TIM1_CCR1 register. The DMA channel request is driven
by the TIM1 update event. The duty cycle of TIM1_CH1 output signal is then changed
each time the input voltage value on ADC channel14 pin is modified.
The duty cycle variation can be visualized on oscilloscope on the TIM1_CH1 pin
PA.08 while changing the analog input on ADC channel14 using the potentiometer.
Directory contents
- DMA/ADC_TIM1/stm32f10x_conf.h Library Configuration file
- DMA/ADC_TIM1/stm32f10x_it.c Interrupt handlers
- DMA/ADC_TIM1/stm32f10x_it.h Interrupt handlers header file
- DMA/ADC_TIM1/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)
- Connect an oscilloscope to TIM1_CH1 (PA.08) pin
- STM3210E-EVAL Set-up
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1)
- Connect an oscilloscope to TIM1_CH1 (PA.08) pin
- STM3210B-EVAL Set-up
- Connect a variable power supply 0-3.3V to ADC Channel14 mapped on pin
PC.04 (potentiometer RV1)
- Connect an oscilloscope to TIM1_CH1 (PA.08) pin
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_dma.c
- stm32f10x_rcc.c
- stm32f10x_gpio.c
- stm32f10x_adc.c
- stm32f10x_tim.c
- system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
- 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.
--------------------------------------------------------------------------------
DMA_FLASH_RAM
Example Description
This example provides a description of how to use a DMA channel to transfer
a word data buffer from FLASH memory to embedded SRAM memory.
DMA1 Channel6 is configured to transfer the contents of a 32-word data buffer
stored in Flash memory to the reception buffer declared in RAM.
The start of transfer is triggered by software. DMA1 Channel6 memory-to-memory
transfer is enabled. Source and destination addresses incrementing is also enabled.
The transfer is started by setting the Channel enable bit for DMA1 Channel6.
At the end of the transfer a Transfer Complete interrupt is generated since it
is enabled. Once interrupt is generated, the remaining data to be transferred is
read which must be equal to 0. The Transfer Complete Interrupt pending bit is
then cleared. A comparison between the source and destination buffers is done to
check that all data have been correctly transferred.
Directory contents
- DMA/FLASH_RAM/stm32f10x_conf.h Library Configuration file
- DMA/FLASH_RAM/stm32f10x_it.c Interrupt handlers
- DMA/FLASH_RAM/stm32f10x_it.h Interrupt handlers header file
- DMA/FLASH_RAM/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.
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_dma.c
- stm32f10x_rcc.c
- stm32f10x_flash.c
- misc.c
- system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
- 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.
--------------------------------------------------------------------------------
DMA_FSMC
Example Description
This example provides a description of how to use two DMA channels to transfer
a word data buffer from Flash memory to external SRAM memory and to recuperate
the written data from external SRAM to be stored in internal SRAM.
DMA2 Channel5 is configured to transfer, word by word, the contents of a 32-word data
buffer stored in Flash memory to the external SRAM memory interfaced by FSMC.
The start of transfer is triggered by software. DMA2 Channel5 memory-to-memory
transfer is enabled.
Source and destination address incrementing is also enabled. The transfer is started
by setting the Channel enable bit for DMA2 Channel5. A polling on the Transfer Complete
flag is done to check the end of transfer. The DMA2 Channel5 Transfer complete flag
is then cleared.
DMA1 Channel3 is configured to transfer, byte by byte, the contents of the first
128Bytes of external SRAM to the internal SRAM memory. The start of transfer is
triggered by software. DMA1 Channel3 memory-to-memory transfer is enabled.
Source and destination address incrementing is also enabled. The transfer is started
by setting the Channel enable bit for DMA1 Channel3. A polling on the Transfer Complete
flag is done to check the end of transfer.
A comparison between the source and destination buffers is done to check that all data
have been correctly transferred.
Directory contents
- DMA/FSMC/stm32f10x_conf.h Library Configuration file
- DMA/FSMC/stm32f10x_it.c Interrupt handlers
- DMA/FSMC/stm32f10x_it.h Interrupt handlers header file
- DMA/FSMC/main.c Main program
- DMA/FSMC/fsmc_sram.c FSMC SRAM driver
- DMA/FSMC/fsmc_sram.h Header for the fsmc_sram.c file
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.
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_dma.c
- stm32f10x_rcc.c
- stm32f10x_fsmc.c
- stm32f10x_gpio.c
- system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
- 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.
--------------------------------------------------------------------------------
DMA_I2C_RAM
Example Description
This example provides a description of how to use two DMA channels to transfer a
data buffer from memory to I2C2 through I2C1.
I2C1 is set as the master transmitter and I2C2 as the slave receiver. DMA1 Channel5 is
configured to store the data received from I2C2 into the Rx buffer (reception buffer).
DMA1 Channel6 is configured to transfer data from the Tx buffer (transmission buffer)
to the I2C1 DR register. After the generation of the Start condition and once the slave
address has been acknowledged, DMA capability is enabled for both I2C1 and I2C2.
As soon as the two I2C DMAEN bits are set in the I2C1_CR2 and I2C2_CR2 registers,
the transmission of the Tx buffer is started by DMA1 Channel5 and at the same time the
data received on I2C2 is stored in Rx buffer using DMA1 Channel6 .
The transmitted and the received buffers are compared to check that all data have been
correctly transferred.
Directory contents
- DMA/I2C_RAM/stm32f10x_conf.h Library Configuration file
- DMA/I2C_RAM/stm32f10x_it.c Interrupt handlers
- DMA/I2C_RAM/stm32f10x_it.h Interrupt handlers header file
- DMA/I2C_RAM/main.c Main program
Hardware and Software environment
- This example runs on STM32F10x High-Density, STM32F10x Medium-Density,
STM32F10x Low-Density and STM32F10x Connectivity-Line Devices.
- This example has been tested with STMicroelectronics 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.
This example can't be tested with STMicroelectronics STM3210C-EVAL (STM32F10x
Connectivity-Line) evaluation boards since the I2C2 pins (PB10 and PB11) are
already used by Ethernet PHY module.
- STM3210E-EVAL Set-up
- Connect I2C1 SCL pin (PB.06) to I2C2 SCL pin (PB.10)
- Connect I2C1 SDA pin (PB.07) to I2C2 SDA pin (PB.11)
- Check that a pull-up resistor is connected on one I2C SDA pin
- Check that a pull-up resistor is connected on one I2C SCL pin
- STM3210B-EVAL Set-up
- Connect I2C1 SCL pin (PB.06) to I2C2 SCL pin (PB.10)
- Connect I2C1 SDA pin (PB.07) to I2C2 SDA pin (PB.11)
- Check that a pull-up resistor is connected on one I2C SDA pin
- Check that a pull-up resistor is connected on one I2C SCL pin
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_dma.c
- stm32f10x_rcc.c
- stm32f10x_i2c.c
- stm32f10x_gpio.c
- system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
- 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.
--------------------------------------------------------------------------------
DMA_SPI_RAM
Example Description
This example provides a description of how to use four DMA channels to transfer
a data buffer from memory to SPI_SLAVE through SPI_MASTER and a second data buffer
from memory to SPI_MASTER through SPI_SLAVE in full-duplex mode.
SPI_MASTER and SPI_SLAVE can be SPI1 and SPI2 or SPI3 and SPI2, depending on the
STMicroelectronics EVAL board you are using.
For each SPI the NSS pin is configured by software (thus NSS pin is free for GPIO use)
and DMA Tx/Rx requests are enabled.
In this example both transmission and reception are managed through DMA and the
received data are stored into buffers declared in the SRAM. The DMA channels
involved in this transfer depend on the used SPIs (for more details please refer
to platform_config.h file).
A polling on all Transfer complete flags are done for all used DMA channels to
check the end of all DMA channels transfers. The last received data on SPI_MASTER
and SPI_SLAVE are the CRC values sent by each SPI to the other.
The transmitted and received buffers are compared to check that all data have
been correctly transferred.
Directory contents
- DMA/SPI_RAM/platform_config.h Evaluation board specific configuration file
- DMA/SPI_RAM/stm32f10x_conf.h Library Configuration file
- DMA/SPI_RAM/stm32f10x_it.c Interrupt handlers
- DMA/SPI_RAM/stm32f10x_it.h Interrupt handlers header file
- DMA/SPI_RAM/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 DMA/SPI_RAM/platform_config.h file.
- STM3210C-EVAL Set-up
- Connect SPI3 SCK pin (PC.10) to SPI2 SCK pin (PB.13)
- Connect SPI3 MISO pin (PC.11) to SPI2 MISO pin (PB.14)
- Connect SPI3 MOSI pin (PC.12) to SPI2 MOSI pin (PB.15)
note In this case SPI3 pins are remapped by software.
- STM3210E-EVAL Set-up
- Connect SPI1 SCK pin (PA.05) to SPI2 SCK pin (PB.13)
- Connect SPI1 MISO pin (PA.06) to SPI2 MISO pin (PB.14)
- Connect SPI1 MOSI pin (PA.07) to SPI2 MOSI pin (PB.15)
note The jumper 14 (USB Disconnect) must be set in position 1<->2 in order
to not interfer with SPI2 MISO pin PB14.
- STM3210B-EVAL Set-up
- Connect SPI1 SCK pin (PA.05) to SPI2 SCK pin (PB.13)
- Connect SPI1 MISO pin (PA.06) to SPI2 MISO pin (PB.14)
- Connect SPI1 MOSI pin (PA.07) to SPI2 MOSI pin (PB.15)
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_dma.c
- stm32f10x_rcc.c
- stm32f10x_spi.c
- stm32f10x_gpio.c
- system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
- Edit stm32f10x.h file to select the device you are working on.
- Edit DMA/SPI_RAM/platform_config.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.