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

The 16 MHz NDK crystal passes. Why can’t the ATmega328P use PB0 for its sensor?

Read the CKOUT fuse before replacing the crystal. If a bench procedure enabled clock output to verify the system timebase on a board with a 16 MHz NDK NX2520SA, the ATmega328P uses PB0 as CLKO and overrides normal I/O settings on that pin. Seeing a valid clock confirms the selected test path, not that the same pin remains available for the product’s sensor pulse.

The bench setting changes what the pin does

Microchip lists ICP1, CLKO and PCINT0 as alternate functions of PB0. With CKOUT programmed, PB0 outputs the divided system clock regardless of PORTB0 and DDB0 and continues to output clock during reset. For example, a product may use PB0 as the Timer1 input capture pin for a tachometer, while the bench image uses it for clock output. If that fuse image carries over into production, setting the direction register to input does not restore the intended pin behavior. Do not connect a separate push-pull sensor to the pin while it is configured to drive. Check the wiring and fuse readback first.

A 2 MHz trace on PB0 also does not show that the 16 MHz crystal is running at the wrong frequency. With that crystal selected and a system prescaler of eight, 2 MHz is the expected CLKO result. The example depends on the actual clock source and divider; it is not a claim that every programming image uses that setting.

Keep the CLKO diagnostic and final input-capture checks separate. On a designated test board, isolate another driver from PB0 before using it as a clock output. If production needs ICP1, restore and read back the approved fuse configuration, then exercise capture with a known pulse interval. Tie that result to the board revision and record the clock path used in the earlier measurement. A correctly measured CLKO trace does not qualify the sensor input or establish that every crystal with the same nominal frequency can be substituted.

Related selection guide: MERLIN Crystal Timing: Quartz crystals

Resource link: https://www.mecxtal.com.cn/en/products/quartz-crystals.html

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.