Main operating highlights of the APWM section:
- The time-stamp counter bus is made available for comparison via 2 digital (32-bit) comparators.
- When the ECAP0_CAP1/ECAP0_CAP2 registers are not
used in capture mode, their contents can be used as Period and Compare values in
APWM mode.
- Double buffering is achieved via the shadow
registers - APRD and ACMP (ECAP0_CAP3/ECAP0_CAP4). The shadow register contents
are transferred over to ECAP0_CAP1/ECAP0_CAP2 registers either immediately upon
a write, or on a TSCNT = PRD trigger.
- In APWM mode, writing to the
ECAP0_CAP1/ECAP0_CAP2 active registers will also write the same value to the
corresponding shadow registers (ECAP0_CAP3/ECAP0_CAP4). This emulates immediate
mode. Writing to the shadow registers (ECAP0_CAP3/ECAP0_CAP4) will invoke the
shadow mode.
- During initialization, software must write the PRD and CMP values to the active registers. This automatically copies the initial values into the shadow values. For subsequent compare updates, during run-time, software should use only shadow registers.
The behavior of APWM active-high mode (APWMPOL == 0) is:
CMP = 0x00000000, output low for duration of period (0% duty)
CMP = 0x00000001, output high 1 cycle
CMP = 0x00000002, output high 2 cycles
CMP = PERIOD, output high except for 1 cycle (<100% duty)
CMP = PERIOD+1, output high for complete period (100% duty)
CMP > PERIOD+1, output high for complete period
The behavior of APWM active-low mode (APWMPOL == 1) is:
CMP = 0x00000000, output high for duration of period (0% duty)
CMP = 0x00000001, output low 1 cycle
CMP = 0x00000002, output low 2 cycles
CMP = PERIOD, output low except for 1 cycle (<100% duty)
CMP = PERIOD+1, output low for complete period (100% duty)
CMP > PERIOD+1, output low for complete period