Example description
NVIC_DMA_WFIMode
Example Description
This example shows how to enters the system to WFI mode with DMA transfer enabled
and wake-up from this mode by the DMA End of Transfer interrupt.
In the associated software, the system clock is set to 72 MHz, the DMA1 Channely
is configured to transfer 10 data from the EVAL COM1 USART data register to a
predefined buffer, DST_Buffer, and to generate an interrupt at the end of the
transfer.
The EVAL COM1 USART receives data from Hyperterminal.
A LED1 is toggled with a frequency depending on the system clock, this is used
to indicate whether the MCU is in WFI or RUN mode.
A falling edge on the selected EXTI Line will put the core in the WFI mode,
causing the led pin to stop toggling.
To wake-up from WFI mode you have to send the sequence (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
from the Hyperterminal to the EVAL COM1 USART. These bytes will be transferred
by the DMA from the EVAL COM1 receive data register to the predefined buffer,
then generates an interrupt which exits the system from WFI mode.
The LED1 restarts toggling and a LED2 will toggle if the buffer is correctly
received else a LED3 is toggled.
Directory contents
- NVIC/DMA_WFIMode/stm32f10x_conf.h Library Configuration file
- NVIC/DMA_WFIMode/stm32f10x_it.c Interrupt handlers
- NVIC/DMA_WFIMode/stm32f10x_it.h Interrupt handlers header file
- NVIC/DMA_WFIMode/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
- STM3210C-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PD.07, PD.13, PF.03
and PD.04 pins
- The USART2 signals (Rx, Tx) must be connected to a DB9 connector using a RS232
transceiver.
- Connect a null-modem female/female RS232 cable between the DB9 connector,
CN6 on STM3210C-EVAL board, and PC serial port.
- Hyperterminal configuration:
- Word Length = 8 Bits
- One Stop Bit
- No parity
- BaudRate = 115200 baud
- flow control: None
- Use the Key push-button connected to pin PB.09 (EXTI Line9).
- STM3210E-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 leds connected respectively to PF.06, PF0.7, PF.08
and PF.09 pins
- The USART1 signals (Rx, Tx) must be connected to a DB9 connector using a RS232
transceiver.
- Connect a null-modem female/female RS232 cable between the DB9 connector,
CN12 on STM3210E-EVAL board, and PC serial port.
- Hyperterminal configuration:
- Word Length = 8 Bits
- One Stop Bit
- No parity
- BaudRate = 115200 baud
- flow control: None
- Use the Key push-button connected to pin PG.08 (EXTI Line8).
- STM3210B-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 leds connected respectively to PC.06, PC.07, PC.08
and PC.09 pins
- The USART1 signals (Rx, Tx) must be connected to a DB9 connector using a RS232
transceiver.
- Connect a null-modem female/female RS232 cable between the DB9 connector,
CN6 on STM3210B-EVAL board, and PC serial port.
- Hyperterminal configuration:
- Word Length = 8 Bits
- One Stop Bit
- No parity
- BaudRate = 115200 baud
- flow control: None
- Use the Key push-button connected to pin PB.09 (EXTI Line9).
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_exti.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- stm32f10x_dma.c
- stm32f10x_usart.c
- misc.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.
--------------------------------------------------------------------------------
NVIC_IRQ_Channels
Example Description
This example demontrates the use of the Nested Vectored Interrupt Controller (NVIC)
IRQ Channels configuration:
- Configuration of 3 TIM (TIM2..TIM4)timers to generate an interrupt on each
counter update event.
- The three timers are linked to their correspondant Update IRQ channel.
- Assignment of a ascendant IRQ priority for each IRQ channel :
TIM2 has a preemption priority of 0 and TIM4 has a preemption priority of 2.
- In each interrupt routine:
- TIM2 toggles a LED1 each 1s
- TIM3 toggles a LED2 each 2s
- TIM4 toggles a LED3 each 3s
Directory contents
- NVIC/IRQ_Channels/stm32f10x_conf.h Library Configuration file
- NVIC/IRQ_Channels/stm32f10x_it.c Interrupt handlers
- NVIC/IRQ_Channels/stm32f10x_it.h Interrupt handlers header file
- NVIC/IRQ_Channels/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, LED2 and LED3 connected respectively to PD.07, PD.13 and PF.03
pins
- STM3210E-EVAL Set-up
- Use LED1, LED2 and LED3 leds connected respectively to PF.06, PF0.7 and PF.08
- STM3210B-EVAL Set-up
- Use LED1, LED2 and LED3 leds connected respectively to PC.06, PC.07 and PC.08
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_gpio.c
- stm32f10x_rcc.c
- stm32f10x_exti.c
- misc.c
- stm32f10x_tim.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.
--------------------------------------------------------------------------------
NVIC_Priority
Example Description
This example demontrates the use of the Nested Vectored Interrupt Controller (NVIC):
- Configuration of 2 EXTI Lines (Wakeup button EXTI Line & Key button EXTI Line)
to generate an interrupt on each falling edge and use the SysTick interrupt.
- These interrupts are configured with the following parameters:
- Wakeup button EXTI Line:
- PreemptionPriority = PreemptionPriorityValue
- SubPriority = 0
- Key button EXTI Line:
- PreemptionPriority = 0
- SubPriority = 1
- SysTick Handler:
- PreemptionPriority = !PreemptionPriorityValue
- SubPriority = 0
First, the PreemptionPriorityValue is equal to 0, the Wakeup button EXTI Line
has higher preemption priority than the SysTick handler.
In the key button EXTI Line interrupt routine the Wakeup button EXTI Line and
SysTick preemption priorities are inverted.
In the Wakeup button EXTI Line interrupt routine the pending bit of the SysTick
interrupt is set this will cause SysTick ISR to preempt the Wakeup button EXTI
Line ISR only if it has higher preemption priority.
The system behaves as following:
1) The first time Key button EXTI Line interrupt occurs the SysTick preemption
become higher than Wakeup button EXTI Line one. So when the Wakeup button EXTI
Line interrupt occurs, the SysTick ISR is executed and the PreemptionOccured
variable become TRUE and the four leds (LED1, LED2, LED3, LED4) start toggling.
2) When the next Key button EXTI Line interrupt occurs the SysTick preemption
become lower than Wakeup button EXTI Line one. So when the Wakeup button EXTI Line
interrupt occurs, the PreemptionOccured variable became FALSE and the four leds
(LED1, LED2, LED3, LED4) stop toggling.
Then this behavior is repeated from point 1) in an infinite loop.
Directory contents
- NVIC/Priority/stm32f10x_conf.h Library Configuration file
- NVIC/Priority/stm32f10x_it.c Interrupt handlers
- NVIC/Priority/stm32f10x_it.h Interrupt handlers header file
- NVIC/Priority/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
- STM3210C-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PD.07, PD.13, PF.03
and PD.04 pins
- Use the Key push-button connected to pin PB.09 (EXTI Line9).
- Use the Wakeup push-button connected to pin PA.00 (EXTI Line0).
- STM3210E-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PF.06, PF0.7, PF.08
and PF.09 pins
- Use the Key push-button connected to pin PG.08 (EXTI Line8).
- Use the Wakeup push-button connected to pin PA.00 (EXTI Line0).
- STM3210B-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PC.06, PC.07, PC.08
and PC.09 pins
- Use the Key push-button connected to pin PB.09 (EXTI Line9).
- Use the Wakeup push-button connected to pin PA.00 (EXTI Line0).
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_exti.c
- stm32f10x_gpio.c
- stm32f10x_rcc.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.
--------------------------------------------------------------------------------
NVIC_VectorTable_Relocation
Example Description
This example describes how to set the CortexM3 vector table in a specific
address other than default using the NVIC_SetVectorTable function from the
misc.h/.c driver.
This can be used to build program which will be loaded into Flash memory by an
application previously programmed from the Flash memory base address.
Such application can be In-Application Programming (IAP, through USART) or
Device Firmware Upgrade (DFU, through USB).
These applications are available for download from the ST microcontrollers
website: www.st.com/stm32
The associated program implements a "Delay" function based on SysTick end of count
interrupt, and toggles four leds with timing defined by the "Delay" function.
When using the IAP to load your porgram, the vector table must be relocated at
address 0x08002000.
When using the DFU to load your porgram, the vector table must be relocated at
address 0x08003000.
Directory contents
- NVIC/VectorTable_Relocation/linker:
- EWARMv5:
- stm32f10x_flash_offset.icf ILINK command file template for EWARM5
- RIDE:
- stm32f10x_flash_offset.ld Linker script for RIDE
- NVIC/VectorTable_Relocation/stm32f10x_conf.h Library Configuration file
- NVIC/VectorTable_Relocation/stm32f10x_it.c Interrupt handlers
- NVIC/VectorTable_Relocation/stm32f10x_it.h Interrupt handlers header file
- NVIC/VectorTable_Relocation/main.c Main program
- NVIC/VectorTable_Relocation/main.h Header for main.c
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, LED2, LED3 and LED4 leds connected respectively to PD.07, PD.13, PF.03
and PD.04 pins
- STM3210E-EVAL Set-up
- Use LD1, LD2, LD3 and LD4 leds connected respectively to PF.06, PF0.7, PF.08
and PF.09 pins
- STM3210B-EVAL Set-up
- Use LD1, LD2, LD3 and LD4 leds connected respectively to PC.06, PC.07, PC.08
and PC.09 pins
How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration:
EWARM5
- Use "stm32f10x_flash_offset.icf" as linker file
- Add the required Library files:
- stm32f10x_gpio.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.
- In the main.c and linker files, the vector table is relocated at address 0x08002000.
You can modify this address depending on the requirement of your application.
- Rebuild all files
- Convert the program image to a binary file, *.bin, then you can download and
run it using the IAP or DFU application.
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.