Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

Applying PWM Duty Changes at the Period Boundary on a 40 MHz Oscillator Board

An immediately applied duty-cycle change can turn the output back on partway through the old period. Check when the preload is committed before diagnosing a clock glitch.

Consider an owned low-voltage board connected only to an indicator. After a change from dimmer to brighter, later cycles look normal, but the transition cycle contains two separate high intervals. The upstream 40 MHz active reference and PWM period remain stable. The counter has passed the old compare value but not the new one, so an immediate write can make the continuous comparator assert again.

The same compare value can take effect at different times

In an up-counting pulse-width modulation (PWM) mode that is active while the count is less than the active compare value, the output starts high, goes low at the threshold and stays low until the next period. Writing the active register can change that decision immediately. With preload, software writes a pending value and a specified update event transfers it to the active register. Both methods can reach the same steady duty cycle with different transitions.

The update event need not coincide with the software write. Depending on count mode and configuration, it can come from a period boundary or another permitted event. Establish how long the old value persists after the first request. A successful register write does not establish when it became active.

Electrical reflections can cause overshoot or ringing near an edge. A mid-cycle compare update can instead produce a definite pulse width consistent with the count range. Output inversion or other stages can also change what a pin shows relative to the comparator. Check selected action, polarity and observation point.

Worked example: low at count 30, high again at 50

In an ideal up-counter model, each period covers counts 0 to 99 at 1 µs per tick. The old compare value of 30 keeps the first 30 ticks high. At count 50, software writes 70. Assume that direct writes become active immediately.

The output can be high at counts 0–29, low at 30–49, high again at 50–69 for 20 ticks, then low from 70 onward. Total high time is 50 ticks, split across two intervals, rather than a continuous 50 µs or the requested 70 µs. The next full cycle is high for the first 70 ticks.

If the value is preloaded and committed only at the next period start, the current cycle retains its original 30 high ticks and the next has 70. This gives a predictable transition with about 50 ticks from the write to the new duty cycle in the example. Actual delay depends on the update event. If immediate response is required, explicitly define allowed transition edges instead of assuming an immediate change will still produce one complete pulse.

The 40 MHz reference determines tick duration

If the indicator board needs an active 40 MHz CMOS reference, Taiwan's Taitien O3 series lists a corresponding standard frequency. Verify voltage, output, load, temperature and exact order code. This is an inquiry candidate without identifying a fitted part or controlling a motor or hazardous actuator.

At 40 MHz, the reference period is 25 ns. Dividing that clock by 40 would give the 1 µs ticks in the model. Real timers can use a different internal clock, bus multiplier or prescaler, so PWM frequency cannot identify the oscillator by itself. Tighter tolerance changes tick duration slightly. It does not determine when the compare register commits.

If the extra pulse recurs near the same count on each change, check the update event first. If it also occurs without a write or there is independent clock evidence, examine signal integrity and control logic. A stable PWM period alone does not qualify the reference path.

Record the request, write and hardware update separately

On a simulator or isolated indicator board, replay the same change at different counts. Capture request, write, update event and pin waveform. Fix count mode and polarity, and retain the complete periods before, during and after the change. Steady captures can miss an extra pulse.

Distinguish compare, period and multi-channel changes. Preload on one register does not guarantee that other values update with it. If channels must change together, verify a shared approved update event. Use permitted test paths without changing live production controls.

CheckEvidenceWhat to confirm
Timer stateInput clock, prescaler, count and polarityWhether output logic explains the change
Compare transferOld and new values, write and active updateWhether mid-period decisions are allowed
WaveformEdge positions and widths across three consecutive periodsTransition as well as steady duty cycle
Interface requirementAllowed delay and complete-period requirementsWhich visible edge defines immediate response
Reference partFull order code and electrical conditionsClock performance independent of software behavior

Ask the supplier for timer mode, transition waveform and delay from request to full-cycle operation. Specify oscillator frequency, supply, output and load separately. Both records support comparisons after controller or clock substitutions.

Frequently asked questions

Does preload always prevent an extra pulse? Confirm the update source, output state and any settings that take effect immediately. Forced updates or other hardware paths can still affect transitions.

Why check the transition if two instruments report the same average duty cycle? The average can hide multiple high intervals. Edge count, minimum width and synchronized updates require a time-domain capture.

Identify when the request arrived, when the active value changed and whether it split a pulse or waited for the next cycle. Those events distinguish timer behavior from an electrical edge or reference fault.

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.