Page:
STM32F405 Timer Triggering
Pages
Board FreeSOC
Board Arduino Due
Board BLACK F407VE
Board BLACK F407ZE
Board BLACK F407ZG
Board Crazyflie2
Board Espruino Pico
Board FEZ Cerb40 II
Board FEZ Cerb40
Board FEZ Lemur
Board G30HDR
Board HydraBus V1.0
Board NUCLEO F401RE
Board NetduinoPlus2
Board Nucleo F767ZI
Board Olimex STM32 405STK
Board Olimex STM32 E407
Board OpenMV
Board STM32F401 Discovery
Board STM32F407 Discovery
Board STM32F429
Board STM32F746 Discovery
Board Teensy 3.1 3.5 3.6
Board Tiva TM4C123G Launchpad
Board VCC GND STM32F407VET6 Mini
Boards Summary
Build Troubleshooting
Building Micropython Binaries
Building st flash
Collections module
ContributorGuidelines
CrossBranch
Developing on a microcontroller
Differences
Examples
FAQ
Getting Started Compiling Micropython for Ubuntu 16.04
Getting Started STM
Getting Started
HY STM32F4xxCore144
Hardware API
Home
Instrumenting code using GPIOs
LCD driver
LTO
Learn MicroPython
Memory Manager
Micro Python on Mac OSX
MicroPythonVsELua
Micropython Git Development Workflow
PPP on ESP32
PWM Timers
Performance
Programming Debugging the pyboard using ST Link v2
ProjectsUsingMicroPython
Pyboard Firmware Update
STM32F405 Timer Triggering
STM32F405 pinouts
Securing a MicroPython System
Servos
Soft reset
Standard Library Coverage
Symbolic Debugging for STM32
Threads
Timebase calculation and Clock sources
Timer Implementation
Timer capture mode
Timer one shot
Tips and Tricks
VS Code
Watchdogs, Crash prevention, Crash recovery
5
STM32F405 Timer Triggering
Jay Kickliter edited this page 2017-04-07 11:13:55 -07:00
Table of Contents
The Timers can be cascaded to make more complex timing relationships, or longer periods. Internally only some timers can trigger others. This is a Master/Slave relationship and is handled by the SMS register.
For example, you can see below that TIM8 can be triggerd by TIM1.
- One Timer can be used as the prescaler for another.
- The first timer update_event, or output_compare signal is used as clock for the second.
- Uses TRGI to map.
- Counter mode is set using the TIMx_CR1 reg and CMS bits as indicated in the example below.
- The counter mode sets whether the update_event occurs on overflow and/or underflow of the Timer.
Example for internal trigger
Internal trigger clock mode 1 (ITRx) TIM_CLK is replaced by ITRx_CLK which is the internal trigger freq mapped to timer Trigger input TRGI.
The counter mode indicates if the update_event is generated:
- on overflow - if mode = up counting, the DIR bit is reset in TIMx_CR1
- on underlfow - if mode = down counting, the DIR bit is set in TIMx_CR1
- both - if mode is center aligned, the CMS bits are non zero
The update_event is also generated by:
- software if the UG bit (Update Generation) is set in TIM_EGR reg.
- update generation through the slave mode controller
refer to Timer app note: DM00042534.pdf
Timer synchronisation
A Master can control a slave Timer using a Trigger TRGO. A Timer is slaved if its ITRx is connected to a Slave and the Master is set to use TRGO
Trigger outputs from the Master can be selected from:
- Reset:
- UG bit from EGR reg is used as TRGO
- Enable:
- Counter enable is used as TRGO.
- Used to start several timers at the same time or control window for Slave start
- Update:
- the update_event is TRGO.
- e.g. a master timer can act as a prescaler for a slave timer.
- Compare pulse:
- as soon as a capure or match occurs TRGO goes high when CC1IF flag is to be set
- OC1REF: use OC1REF as TRGO
- OC2REF: use OC2REF as TRGO
- OC3REF: use OC3REF as TRGO
- OC4REF: use OC4REF as TRGO
Master mode:
- Configure the Timer
- Select Trigger output to be used
- in CR2 reg - set MSM bits
- Enable Master/slave mode
- in SMCR reg - enable MSM bit