15.4.3.10.2 Immediate Updates

When using Immediate Update mode, there may be latency from the time of commanding a change to it becoming applied. This mode applies changes as soon as possible to prevent unexpected results.

Note: Avoid immediate updates near new or existing edge values to prevent data corruption. When using immediate updates, write timing should be tested in the software to avoid PWM edges.

An immediate update of period value updates to the PGxPER value becomes effective instantaneously. Care should be taken when the PWM period is shortened. If the PWM time base has already counted beyond the new (shorter) PWM period value, a long period will result as the counter must now count to 0xFFFF and then roll over. If immediate updates are required, the best practice is to capture the time base value prior to the period update so a safe minimum period value may be calculated and written.

Immediate Updates to Duty Cycle, Phase Offset

The immediate update correction logic keeps track of whether a PWM pulse has already been created in the current PWM cycle, and it will not restart a second pulse within the same cycle. For example, if an immediate update changes the PGxPHASE value to a later time in the cycle, but a rising edge and falling edge have already been generated, then the new value of PGxPHASE will not take effect until the next cycle. An immediate update of PGxPHASE can only be used to delay a PWM pulse which has not occurred yet or cause the pulse to start sooner.

Figure 15-34 shows two examples of a correction during immediate updates. In this Update mode, the PWM module implements a compare function that compares the upper 12-bits of the data to the time base. This logic in hardware takes action as needed for the given conditions. The PWM period is relatively short in these examples, and a large duty cycle adjustment is made to emphasize how the correction works. In both examples, the duty cycle is decreased from 75% to 25% (0x7F) at approximately the mid-point of the PWM cycle. In both cases, the time base has already elapsed beyond the compare time for 25% duty.

In the first case, the immediate update write occurs at approximately 55% duty cycle. The PWM pulse is truncated immediately because the PWM time base is at least 0x8F. The programmed duty cycle is 0x7F, so the value of 0x80 provides a true ‘greater than’ comparison when compared to 0x7F. In the second case, the immediate update write occurs just beyond the time of the newly programmed duty cycle. The PWM pulse is not truncated until the time base reaches a value of 0x0080 and the ‘greater than’ comparison becomes true.

Figure 15-34. Immediate Update Correction Examples

Immediate Updates to PER

Using Immediate Update mode with PER data has some inherent hazards and should be avoided unless required by application. If used, user software must manage write time in relation to the PWM counter and known or planned event timing. The time base capture feature can be used for this purpose.

For example, it is possible to write a smaller period after both rising and falling edges have occurred. The PER compare will not occur in the cycle, and PWM counter will roll over at 0xFFFF. Due to no EOC event, the subsequent cycle will have no rising or falling edges. This can be avoided by reading time base capture and gating update if new PGxPER < PGxCAP.

Immediate Update to Dead Time

If a DT blanking is in progress and an immediate update to the DT occurs, the actual dead time after the update will be extended. This extension is due to the DT counter being reloaded before it has expired. Future dead-time delays after the immediate update will be the new time, as expected.