-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Timer one shot
Neon22 edited this page Feb 5, 2014
·
1 revision
This is a specific setting of input and output capture mode. The counter starts in response to a stimulus and then generates a pulse of specific length after a specific delay.
Delay = CCRy / (TIMx_CLK / (PSC + 1))
Pulse length = (ARR - CCRy) / (TIMx_CLK / (PSC + 1))
###To configure:
- confgure input pin and mode
- select TIxFPx trigger to be used
- in CCMRx reg - write CCxS bits
- select polarity of input (pos, neg, both)
- in CCER reg - write CCxP and CCxNP bits
- configure TIxFPx trigger to slave mode
- in SMCR reg - write TS bits
- select trigger mode to slave mode
- in SMCR reg - write SMS bits
- configure output pin and mode
- select output polarity - in CCER reg - write CCyP bit
- select output compare mode
- in CCMRy reg - write OCyM bits
- PWM1 or PWM2 mode
- set delay value
- in CCRy reg - write delay value
- set autoreload to have desired pulse
pulse = TIMy_ARR - TIMy_CCRy
- select one-pulse mode if only need one pulse (else reset bit)
- in CR1 reg - set OPM bit