forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
PWM Timers
Neon22 edited this page Feb 5, 2014
·
13 revisions
There are 10 Timers on the STM32F405 chip being used by the mircropython KS project. Not all Timers have pins allocated to them on this 64 pin package. (The 407 based chipsets have the same allocation of timers.) Timers in this chipset come with various capabilities:
- TIM1 and TIM8 are advanced 16 bit timers and can count up and down. They can be used to drive steppers or 3 phase motors. They have special trigger and brake input pins to support this. They are the only timers with pinouts defined for complementary outputs. I.e. they can drive three channels of two pins up and down in perfect synchronisation. They are capable of driving 4 channels for output.
- TIM2 and TIM5 are 32 bit Timers. TIM2 can be triggered by an external signal. Both TIM2 and 5 have 4 channels.
- TIM3 and TIM4 are 16 bit timers. Both have 4 channels but TIM3 has more pins allocated.
- TIM9 and TIM12 are 2 channel timers. Only TIM9 has pins.
- TIM10 and TIM11 have a single output channel each.
- The remaining Timers 6,7,13,14 do not have any pin connections on the 64 pin package. All timers can be used to generate timebases. Most can do PWM generation. A digram below shows how timers can be cascaded to make longer or triggered timings. Most triggers can also generate Interrupts.
The following timers can sample an input signal and determine its period.
- 1,2,3,4,5,8,9,10,11
These Timers can be used to correctly determine speed and direction from externally supplied quadrature signals.
- 1,2,3,4,5,8,9
STM32F405 pinouts STM32F405 Timer Triggering Implementation
Advanced - TIM1,8
- 16bit, 4 channels (2x complementary)
- can generate up to three complementary outputs with insertion of dead time
- ideal for motor control.
- seen as three phase PWM generators multiplexed on 6 channels
- max speed 168 MHz, max interface speed 84 MHz
- independent DMA request generation
- as 16bit PWM generators they have full 100% modulation capability
- TIM1 can be slaved to TIM5,2,3,4
- TIM8 can be slaved to TIM1,2,4,5
GP 16bit - TIM3,4
- 4 channels (not complementary)
- timing, delay, one pulse, input capture, encoder input
- up, down count with DMA control, Master/slave
- can generate PWM output
- 16 bit prescaler
- max speed 84 MHz, max interface speed 42 MHz
- TIM3 can be slaved to TIM1,2,5,4
- TIM4 can be slaved to TIM1,2,3,8
GP 32bit - TIM2,5
- 4 channels (not complementary)
- timing, delay, one pulse, input capture, encoder input
- up, down count with DMA control, Master/slave
- can generate PWM output
- 16 bit prescaler
- max speed 84 MHz, max interface speed 42 MHz
- TIM2 can be slaved to TIM1,8,3,4
- TIM5 can be slaved to TIM2,3,4,8
Basic - TIM6,7
- 0 channels - no direct external pin control.
- must be Masters
- up count only with DMA control
- 16 bit prescaler
- used for timebase timers or triggering the DAC
- max speed 84 MHz, max interface speed 42 MHz
1 channel - TIM10,11,13,14
- general purpose timers
- up count only, no DMA control
- can generate PWM output
- 16 bit prescaler
- must be Masters
- TIM13,14 - max speed 84 MHz, max interface speed 42 MHz
- TIM10,11 - max speed 168 MHz, max interface speed 84 MHz
2 channel - TIM9,12
- 2 independent channels
- general purpose timers, Master/slave
- up count only, no DMA control
- can generate PWM output
- 16 bit prescaler
- TIM12 - max speed 84 MHz, max interface speed 42 MHz
- TIM9 - max speed 168 MHz, max interface speed 84 MHz
- TIM12 can be slaved to TIM4,5,13,14
- TIM9 can be slaved to TIM2,3,10,11 Independent watchdog
- 12 bit downcounter and 8 bit prescaler
- driven from independent 32kHz rc clock
- operates in stop or standby mode and can reset the device
- can be used as free running app timeout counter
Window watchdog
- free running 7bit downcounter
- clocked from main clock
- can reset the device or generate interrupt
SysTick timer
- 24 bit downcounter from main clock
- autoreload capability
- maskable interrupt on =0
Pin Skin Timer Alt Timer Alt Timer
PB14 Y15 TIM12_CH1
PB15 Y16 TIM12_CH2
PB6 X1 TIM4_CH1
PB7 X2 TIM4_CH2
PB8 Y11 TIM4_CH3 TIM10_CH1
PB9 Y12 TIM4_CH4 TIM11_CH1
PA6 X15 TIM3_CH1 TIM13_CH1
PA7 X16 TIM3_CH2 TIM14_CH1
PC6 Y9 TIM3_CH1 TIM8_CH1
PC7 Y10 TIM3_CH2 TIM8_CH2
PB0 Y3 TIM3_CH3
PB1 Y4 TIM3_CH4
PA5 X14 TIM2_CH1
PB3 X17 TIM2_CH2
PB10 Y1 TIM2_CH3
PB11 Y2 TIM2_CH4
PA0 X9 TIM2_CH1 TIM5_CH1
PA1 X10 TIM2_CH2 TIM5_CH2
PA2 X11 TIM2_CH3 TIM5_CH3 TIM9_CH1
PA3 X12 TIM2_CH4 TIM5_CH4 TIM9_CH2