PWM Input Capture handling.
- Author
- SMFSW
- Copyright
- MIT (c) 2017-2024, SMFSW
PWM_In configuration: TIM with multiple channels with slave mode capability shall be used
Slave Mode: Reset Mode Trigger: TI1FP1/TI2FP2 (depending physical MCU pin used tied to channel 1 or 2) Channel tied to pin: Input Capture direct mode Channel (2nd one): Input Capture indirect mode
Prescaler & CLK div: 0, No CLK div Counter Period: max possible value Counter Mode: Up Auto-Reload Preload: Disabled Trigger Output parameters: Disabled Input Capture Channel tied to pin: Rising Edge, Direct, No CLK div Input Capture Channel (2nd one): Falling Edge, Indirect, No CLK div
Instead, CubeMX Combined channels capture may be configured to PWM input capture, avoiding manual timer configuration
GPIO configuration: Alternate Function Push Pull ; Pull Up (if needed) ; High Speed may be recommended
NVIC configuration: Enable interrupt(s) if PWM_IC_NO_IT is not defined at project level
- Note
- Define NB_PWM_IC symbol with number of inputs at project level to use PWM_IC functionalities
-
Define PWM_IC_NO_IT symbol at project level to disable TIM interrupts driven capture
- Warning
- Input Capture limitation:
- Lower/Higher frequency/duty cycle measurable totally depends on TIM configuration and clocks used.
- Continuous signal (pin held low or high) is detected automatically after timeout:
- !!Please note there can be up to 1 second with startup timeout during which low to high continuous signal may be misinterpreted before retrieving values!!
- If PWM signal to capture can never become continuous, it may save some time of servicing interrupts to disable them (with PWM_IC_NO_IT symbol)