50.6.5 PWM External Trigger Mode
The PWM channels 1 and 2 can be configured to use an external trigger for generating specific PWM signals. The external trigger source can be selected through the TRGSRC bit of the PWM External Trigger Register, see the table below.
Channel | Trigger Source Selection | Trigger Source |
---|---|---|
1 | PWM_ETRG1.TRGSRC = 0 | From PWMEXTRG0 input |
PWM_ETRG1.TRGSRC = 1 | From Analog Comparator Controller | |
2 | PWM_ETRG2.TRGSRC = 0 | From PWMEXTRG1 input |
PWM_ETRG2.TRGSRC = 1 | From Analog Comparator Controller |
Each external trigger source can be filtered by writing a one to the TRGFILT bit in the corresponding PWM External Trigger Register (PWM_ETRGx).
Each time an external trigger event is detected, the corresponding PWM channel counter value is stored in the MAXCNT field of the PWM_ETRGx register if it is greater than the previously stored value. Reading the PWM_ETRGx register will clear the MAXCNT value.
Three different modes are available for channels 1 and 2 depending on the value of the TRGMODE field of the PWM_ETRGx register:
- TRGMODE = 1: External PWM Reset Mode
- TRGMODE = 2: External PWM Start Mode
- TRGMODE = 3: Cycle-By-Cycle Duty Mode
See the following sections.
This feature is disabled when TRGMODE = 0.
This feature should only be enabled if the corresponding channel is left-aligned (CALG = 0 in the PWM Channel Mode Register of channel 1 or 2) and not managed as a synchronous channel (SYNCx = 0 in the PWM Sync Channels Mode Register where x = 1 or 2). Programming the channel to be center-aligned or synchronous while TRGMODE is not ‘0’ could lead to unexpected behavior.