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

AT89S52 runs after a 24 MHz crystal swap but will not program: check the ISP clock

If the full device number is AT89S52 and existing firmware runs after a change to 24 MHz but the programmer cannot identify the device, do not immediately try another crystal. Establish that the target has a stable system clock during programming, then measure the incoming SCK at the board. The serial programming section calls for SCK below one sixteenth of the system clock. At 24 MHz, 1.5 MHz is the calculated boundary, not the recommended setting. Start with a slower supported rate, such as a measured 500 kHz, to see whether excessive programming speed is part of the problem.

1. Identify the actual device speed grade

“89S52” printed on the board does not identify the speed grade of the installed device. Nor should AT89C52 instructions be applied to AT89S52 without checking. Compare the chip marking against traceable purchasing records and the ordering table. If the marking is illegible, a working old program does not establish the guaranteed maximum clock or minimum supply voltage. This is particularly important on repair benches where devices in the same package can get mixed.

The ordering table distinguishes a 24 MHz grade at 4.0–5.5 V from a 33 MHz grade at 4.5–5.5 V. Do not combine the lowest supply voltage and highest frequency from the cover to invent a guarantee. If the supply sags when the programming fixture is connected, measure the lowest voltage at the chip relative to its local ground and check interface levels. A room-temperature startup or a regulator marking cannot answer that question.

ItemReference at 24 MHzWhat it cannot prove
Device speed gradeCheck the order number and supply rangePackage alone cannot identify the grade
Crystal loopPassive crystal across XTAL1 and XTAL2It may not stay stable with the fixture connected
Programming SCKStrictly below the nominal 1.5 MHz boundaryReset and interface levels may still be wrong
Slow comparisonA measured 500 kHz can help isolate the faultIt cannot replace verification after writing

2. Why normal execution does not prove programming works

Normal operation and serial programming are different states. During normal execution, the MCU runs on its own clock. In the reset-related programming state, the programmer supplies an independent shift clock over the programming interface. Normal execution only establishes that the target ran some instructions on that occasion. It does not establish that the crystal starts early enough during programming or that the programmer meets the pulse timing requirement. Application UART baud rate, system frequency, and the programmer's SCK setting are separate quantities.

Compare two known programming rates

Divide 24 MHz by 16 to obtain 1.5 MHz. An actual programmer output of 2 MHz is above that boundary even if it worked on a board with a faster target clock. Do not transplant the datasheet's 2 MHz example for a 33 MHz target to a 24 MHz board. Conversely, the calculated boundary on a 12 MHz target is just 750 kHz. Compare measured pulses under equivalent hardware conditions rather than assuming two project settings yield the same clock.

Change just one thing. Keep the same board, power source, and wiring, lower the clock rate, re-enter programming, and check identification. Repeat the same verification action. If identification becomes repeatable at the slower rate, record the actual measured rate and reset behavior before choosing a production setting. If the device still does not identify, do not keep trying to write and do not start by erasing the customer's firmware. Use non-modifying identification or a supported read operation to separate circuit trouble from writing trouble.

3. Keep passive and driven clock connections separate

A passive quartz crystal goes across XTAL1 and XTAL2, with the two load branches connected to ground according to the design. For an external oscillator, follow the external-clock diagram: drive XTAL1 and leave XTAL2 unconnected. Bridging a module output across the original crystal pads is not an equivalent substitution. Check external input levels, power sequencing, and common ground. At a 5.0 V chip supply, the XTAL1 high-level minimum of 0.7 times supply is 3.50 V. A module labeled with a 3.3 V output cannot be assumed to meet that minimum. This is a digital-drive requirement, not a full-swing requirement for voltages on the two passive crystal nodes.

Record the crystal part and the external capacitors separately

Epson lists FA-238A X1E0003410048 as 24 MHz and 12 pF in its application information. That figure is the nominal crystal load, not a direction to install a 12 pF capacitor on each side or an Epson qualification for AT89S52. The example shows how to identify an orderable part's parameters; a different controller still needs board validation. Likewise, the capacitor range in the legacy MCU oscillator diagram is not a fixed prescription for every crystal package.

A first-order estimate for equal capacitors adds effective parasitics to their series combination. For example, 18 pF on each side plus an assumed 3 pF effective stray contribution gives about 12 pF. The stray term is an assumption; sockets, pads, traces, and probes change it. Copying larger capacitors to both sides may slow startup rather than improve frequency error. Check ESR, drive level, and temperature requirements, and compare cold starts against an unmodified board instead of saving only one oscilloscope reading.

4. Debug the point at which the failure begins

Record startup without the programmer first, then connect it while keeping the same supply and reset configuration. Reference measurements to target ground and observe near the chip. A pulse at the programmer is not necessarily a clean pulse at the target. Long ribbon cables, poor grounding, and other logic connected to the header can change the waveform. Check levels and edges at the target, then establish whether the enable command arrives after the system clock has stabilized. If behavior changes from one power-up to another, compare the ordering of supply ramp, oscillator startup, and reset release.

Without an appropriate low-capacitance active probe, avoid leaving a general-purpose probe on a crystal node. Probe capacitance itself may change the result. If the board has a validated buffered observation point that reflects the system clock, use that first for comparison. Distinguish occasional identification from repeatable identification across power cycles. An isolated pass helps direct troubleshooting but does not prove the repair. After a successful serial read, follow the normal maintenance procedure to confirm that the intended image can be written, verified, and run.

5. Record results that can be reused

Put the exact MCU number, exact 24 MHz crystal number, fitted capacitor values, measured device supply, actual SCK with the programmer attached, and cold-start conditions on the work order. Save the before-and-after comparison rather than writing “fixed by replacing crystal.” Reuse the diagnostic sequence for another board, not the capacitor values or fixture setting by default. If the supplier changes the crystal to another same-size, same-frequency part, recheck startup and identification with the substitute, including samples close to production temperature, supply, and assembly conditions. Also distinguish short bench leads from longer production leads: a passing bench setting does not qualify every fixture or programmer.

In short, the speed grade and hardware define whether 24 MHz is suitable. System clock, reset, interface levels, and SCK during programming explain why old firmware can run without successful programming. A rate below 1.5 MHz is an SCK constraint under this clock condition, not a measure of crystal quality. Repeatable entry, programming, and verification are what the board and fixture ultimately need to demonstrate.

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.