AD9833: A Frequency Word Is a Fraction of the Clock
The number sent to an AD9833 is not a frequency in hertz. It is an integer fraction of the external clock. Two requested frequencies can select the same integer, and the same integer produces a different frequency when the reference clock changes.
Verification boundary: exact host arithmetic, serialization tests and constructed plots were run. The circuit is an unbuilt design. No Pico code was executed, no target firmware was compiled and no physical frequency, phase noise or output waveform was measured.
Count phase instead of counting complete waves
Direct digital synthesis (DDS) generates a repeating waveform by advancing a digital phase value at every reference-clock tick. A phase accumulator is the wrapping counter holding that progress through a cycle. The frequency tuning word, called N here, is how far the 28-bit accumulator advances each tick. A larger increment wraps around more often and generates a higher output frequency.
The external master clock (MCLK) provides the ticks. For the AD9833, the nominal relation is fOUT = N × fMCLK / 2^28. A hertz (Hz) is one cycle per second; a megahertz (MHz) is one million cycles per second. The integrated circuit (IC) contains this accumulator and a digital-to-analog converter (DAC), which turns the calculated waveform value into a voltage. The FREQ0 register stores the frequency word; the B28 control bit selects loading all 28 frequency bits through two serial frames. A quantization bin is one possible integer setting: adjacent N values differ by fMCLK / 2^28. This digital spacing is different from clock accuracy or the smallest difference your instrument can measure.
At the selected 10 MHz nominal clock, one bin is 0.0372529029846 Hz. To request 1000 Hz, calculate N = round(1000 × 2^28 / 10000000) = 26844. That word predicts 1000.016927719 Hz with an exactly nominal clock. The 1000.001 Hz request selects the same N. Their identical result is an intended consequence of integer bins, not a broken serial link.
Parts per million (ppm) express a fractional difference: one ppm is one millionth of the nominal value. The graph uses ppm to describe clock error separately from integer tuning bins.

Exact device and a clock chosen with timing headroom
Use Analog Devices (ADI) AD9833BRMZ, the RM-10 10-lead MSOP (mini small-outline package). Its official exact model is in Production. The current product hub links Rev G; its revision history dates the F-to-G change April 2019. The product resources also list a historical 2010 data-sheet correction and a 2019 automotive-model change. This article uses current Rev G rather than importing a register or pin assumption from a module advertisement.
The external oscillator is Abracon ASV-10.000MHZ-EJ-T, a 3.3 V, 7.0 × 5.08 mm four-pad clock source. The exact official page lists Active. Its ASV data sheet, revised 09.02.14 as printed, assigns option E to −20 to +70°C, J to ±20 parts per million (ppm), and T to reel packaging. One ppm is one millionth of the nominal value. The data sheet separately allows ±5 ppm first-year aging at 25°C; this lesson conservatively combines 20 + 5 = 25 ppm for the worked first-year budget. That is not a lifetime calibration guarantee.
A nominal 25 MHz oscillator with positive tolerance could exceed the AD9833's 40 ns minimum MCLK period. Duty cycle also matters: it is the fraction of a cycle spent HIGH. Rev G requires at least 16 ns HIGH and 16 ns LOW. The ASV's 40/60% symmetry and 5 ns maximum rise/fall times for this frequency band make 10 MHz a conservative choice. At +25 ppm, the period is about 99.9975 ns. Subtracting a full 5 ns rise and 5 ns fall interval from its shortest 40% half-level pulse gives about 0.4 × 99.9975 − 10 = 29.9990 ns, above 16 ns. This conservative timing screen still requires actual loaded waveform qualification.
At a shared 3.0–3.6 V supply, ASV's specified HIGH floor, 0.9 times its supply, is at least 2.7 V; its LOW ceiling is 0.4 V. These bracket the AD9833's 2.0 V HIGH and 0.7 V LOW requirements at this supply. The oscillator is specified for at most 15 pF load. The AD9833 input capacitance is 3 pF in its data sheet, leaving a nominal 12 pF allocation for routing and measurement loading; that input figure and a route estimate do not prove a real board's total capacitance. Do not add a large-capacitance passive probe and assume the load is unchanged.
Build the named circuit, not an unspecified module
Serial Peripheral Interface (SPI) transfers bits under a controller-generated serial clock. Here SCLK is the 1 MHz serial clock, not the independent 10 MHz MCLK. SDATA carries controller data out; FSYNC, frame synchronization, is an active-LOW input telling the AD9833 to accept a serial word. The Pico uses polarity one and phase zero: SCLK idles HIGH and U1 samples on falling edges. The most significant bit (MSB) goes first.
Reading the circuit labels: Universal Serial Bus (USB) powers the Pico. C0G is a ceramic-capacitor dielectric classification code, not an acronym. A header number identifies a physical connector position; GP numbers identify the Pico general-purpose input/output pins. VDD is a device supply pin, V3 the shared 3.3 V supply net and GND a ground label. Matching net labels join; G0 is this fixture's common reference. SINE is the analog output net.
SCK means serial clock; TX means transmit, here the SPI controller data output rather than an asynchronous serial connection. In the code, MOSI means master out, slave in (controller data output), and MISO means master in, slave out (controller data input). The unused MISO input is physically unconnected. The diagram's nF and µF mean nanofarads and microfarads; kΩ and MΩ mean kilohms and megohms.
All G0 net labels share a low-impedance ground. Join digital ground (DGND) and analog ground (AGND) locally without making output probe current flow along a long clock return. C1 connects COMP, the converter bias-decoupling pin, to VDD. C2 connects the internal regulator's CAP/2.5V pin to DGND; at 3.3 V it is not a separate power-input pin. C3 and C4 bypass VDD to ground. The 10 µF tantalum capacitor's positive terminal faces V3. Put C5 at the oscillator supply pins.
U2 pin 1 is its output-enable (OE) control and is tied HIGH to V3; pin 2 is ground/case, pin 3 the clock output and pin 4 its supply. Keep CLK10 short on a soldered carrier or printed circuit board (PCB), not a long breadboard loop. U1 has no unused functional input in this drawing. Pico general-purpose input/output (GPIO) pin GP16 is initialized as the unused Serial Peripheral Interface receive input but is physically NC, not connected to U1. NC means no connection.

| Reference | Quantity / exact requirement | Purpose / condition |
|---|---|---|
| U1 | 1 × Analog Devices AD9833BRMZ, RM-10/MSOP-10 | Bare exact DDS on pin-labelled soldered carrier |
| U2 | 1 × Abracon ASV-10.000MHZ-EJ-T, 7050 four-pad | 3.3 V, 10 MHz, J ±20 ppm, E −20..+70°C, T reel; exact manufacturer Active |
| Host | Original Raspberry Pi Pico / RP2040; MicroPython 1.26.0 | USB power, 3V3 OUT shared V3; whole assembly 3.0–3.6 V |
| C1 | 1 × 10 nF C0G ±5%, 25 V | COMP to VDD, DAC bias bypass |
| C2 / C3 / C5 | 3 × 100 nF C0G ±5%, 25 V | CAP/2.5V–G0, U1 VDD–G0 and U2 VDD–G0 |
| C4 | 1 × 10 µF tantalum ±10%, 10 V | U1 supply storage; positive V3, negative G0 |
| R1 | 1 × 10 kΩ ±1%, ≥0.125 W | FSYNC default HIGH before controller initialization |
| Tools | Voltage meter; suitably low-capacitance clock probe; counter or scope | Qualify reference timing/load; observe SINE with 10× probe into 1 MΩ; no 50 Ω load |
| Carrier | Short soldered clock route, ground plane or low-impedance return | Clock source total load ≤15 pF; no unspecified oscillator module |
Observe SINE with a compensated 10× probe, its tip at U1 pin 10 and ground at G0, into the oscilloscope's 1 MΩ input. A 10× probe reduces loading at its tip. Rev G includes an internal 200 Ω output resistor; no external load resistor is required. A 50 Ω termination would change the load and amplitude. This lesson makes no calibrated amplitude, distortion, reconstruction-filter or high-frequency waveform-quality claim. The 1 kHz examples keep the arithmetic and measurement task modest.
Load 28 bits through 16-bit serial frames
A 16-bit frame contains two register-address bits and fourteen frequency bits. Set B28, the full 28-bit-write control bit, and send the lower fourteen bits first, followed by the upper fourteen bits, both addressed to FREQ0. The supplied sequence for 1000 Hz at 10 MHz is 2100 68DC 4001 C000 2000. The first control word holds RESET, the next two load FREQ0, C000 loads zero PHASE0, and the last control word selects FREQ0/PHASE0 sine operation with RESET clear. RESET initializes phase; it does not mean every output pin is electrically grounded.
The script keeps FSYNC LOW for the complete pair of bytes belonging to one 16-bit frame. Two microsecond guards before and after each frame exceed the data sheet's nanosecond setup/hold minima at the selected 1 MHz serial clock. Actual serial edges, supply levels and timing are still physical qualification gates. There is no AD9833 serial data-output pin here, so reconstructing outgoing words checks software representation, not a readback from the device.
Run the exact arithmetic before touching hardware
- Extract the archive. Run
python3 tests/test_lab.py, thenpython3 code/dds_plan.py. The latter emits constructed requested frequencies, N, predicted frequencies, quantization errors and exact hexadecimal serial words. - Compare the 1000 and 1000.001 Hz rows. Confirm N is identical. Change only the declared clock in a host call such as
plan(1000, 10000250); that replans N. To model an uncalibrated faster clock acting on an already stored N, keep N fixed and evaluateN × 10000250 / 2^28. These are different experiments. - Keep the returned N=26844 fixed. A +25 ppm clock moves its predicted 1000.016927719 Hz output upward by about 0.025000423 Hz. Nearest-bin rounding can add up to half a nominal bin, about 0.0186264515 Hz. The conservative summed first-year example near 1 kHz is about 0.043627 Hz before instrument uncertainty.
- Read the tests' independent rational-number oracle and known one-sixteenth-clock case. Negative, nonfinite, above-half-clock and invalid-clock requests must be refused. The half-clock upper bound is a software experiment policy, not a claim that the resulting waveform at that boundary is useful.
The host planner uses Python's Fraction type to calculate exact ratios from decimal strings and rounds half upward. The target script uses integer millihertz, one thousandth of a hertz, so its 1000000 input requests 1000 Hz without requiring the host's Fraction module. It checks range before constructing a word. Both complete programs are below; the target integer calculation is also exercised on the host, without calling its pin constructors.
Physical extension and a meaningful control
- With power disconnected, check both exact packages, all support capacitors, C4 polarity, every net and the common return. Check the oscillator's pad orientation against its drawing. Confirm V3 can supply the assembly within 3.0–3.6 V and the clock source starts before initialization.
- Power the Pico through USB, Universal Serial Bus. Measure V3 at both devices. With a suitably low-capacitance probe and instrument bandwidth, qualify CLK10 at U1: loaded voltage levels, period, HIGH and LOW durations, edge shape and overshoot must meet the actual data-sheet limits. Include the probe in the load budget. Stop if this is unqualified.
- Install MicroPython 1.26.0 for the original RP2040 Pico. Copy
pico_dds.pywithout naming itmain.py. Import it and calllaunch()manually. Its confirmation occurs before pin setup. No target binary or hardware result is supplied by this package. - Record the requests 999.990, 1000.000, 1000.001 and 1000.020 Hz, the emitted N, and actual readings in a copy of the blank worksheet. Use a frequency counter or scope method whose uncertainty can resolve the question; an ordinary rounded display may not distinguish neighbouring bins.
- Repeat 1000.000 Hz as the control. On completion or a keyboard interruption, cleanup asserts RESET and deinitializes SPI; then disconnect power. If the bus failed, a cleanup command is not proof the device stopped. Power removal is the final stop.
Use malformed requests only in the host program. Do not short MCLK, probe a powered fine-pitch package with a loose metal tip, or replace the oscillator while powered. A missing clock, incorrect SPI phase, swapped payload order, wrong supply or selected phase register can all defeat an otherwise correct frequency calculation. Start fault diagnosis with those observed facts rather than adjusting N until a display looks plausible.
Challenge: can a better integer remove an unknown reference error?
Not by itself. N describes a fraction of the clock actually present. If the clock is fast by an unknown amount, its output inherits that fractional error. A finer quantization step gives more available settings but does not establish reference accuracy. Measure or calibrate the reference with a suitable independent standard and keep that calibration's conditions and uncertainty separate.
Readout and loading are separate lessons
The Pico frequency measurement lesson compares counting windows and reciprocal periods; it helps explain why an instrument may hide this small difference. The generator-versus-scope termination lesson explains a different loading convention. Neither establishes the frequency accuracy or amplitude of this unbuilt AD9833 fixture.
Primary references and source conditions
- ADI AD9833 exact model product resources — AD9833BRMZ PRODUCTION; current Rev G; historical PCN10_0303 correction and automotive-only PCN19_0017 observed.
- ADI AD9833 current data sheet — G, April 2019 revision history.
- Abracon exact ASV-10.000MHZ-EJ-T — Exact 10 MHz J ±20 ppm E -20..70°C four-pad part, Active.
- Abracon ASV current linked data sheet — 09.02.14 as printed.
- ADI historical correction notice — .
- MicroPython RP2 quick reference — 1.26.0.
- MicroPython machine.SPI — 1.26.0.
- Official original Pico header pinout — .
See source scope and revision index and author source notes. References are manufacturer documentation links. No vendor PDF is redistributed in the reader archive.
Complete delivered code
dds_plan.py
"""Exact host planner; numeric results are constructed, not measurements."""
from fractions import Fraction
import math,csv,json,sys
SCALE=1<<28
def rational(value):
if isinstance(value,bool):raise ValueError('Boolean is not a frequency')
try:r=Fraction(str(value)) if not isinstance(value,Fraction) else value
except (TypeError,ValueError,ZeroDivisionError,OverflowError):raise ValueError('Finite frequency required')
return r
def plan(request_hz,clock_hz=10000000):
f=rational(request_hz);clock=rational(clock_hz)
if not 0<clock<=25000000 or not 0<=f<=clock/2:raise ValueError('Require 0<clock<=25 MHz and 0<=request<=clock/2')
q=f*SCALE/clock;n=(2*q.numerator+q.denominator)//(2*q.denominator)
return dict(word=n,actual_hz=float(n*clock/SCALE),error_hz=float(n*clock/SCALE-f),bin_hz=float(clock/SCALE),words_hex=['%04X'%w for w in words(n)])
def words(n):
if type(n) is not int or not 0<=n<SCALE:raise ValueError('Need unsigned 28-bit integer')
return [0x2100,0x4000|(n&0x3fff),0x4000|(n>>14),0xc000,0x2000]
def reconstruct(pair):
if len(pair)!=2 or any(type(w) is not int or w & 0xc000 !=0x4000 or not 0<=w<=0xffff for w in pair):raise ValueError('Need two FREQ0 serial words, low payload first')
return (pair[0]&0x3fff)|((pair[1]&0x3fff)<<14)
def clock_gate(nominal=10000000,ppm=25,duty_min=.4,edge_ns=5):
fast=nominal*(1+ppm/1000000);period=1e9/fast
# Conservatively subtract a full rise and fall interval from shortest
# half-VDD duty pulse. Actual loaded thresholds/edges remain bench gates.
pulse=duty_min*period-2*edge_ns
return dict(fast_hz=fast,period_ns=period,conservative_pulse_ns=pulse,pass_=period>=40 and pulse>=16,**{'pass':period>=40 and pulse>=16})
def main():
out=sys.stdout;w=csv.writer(out);w.writerow(['kind','requested_hz','declared_clock_hz','tuning_word','predicted_hz','error_hz','serial_words'])
for f in ['0','1','999.99','1000','1000.001','1000.02','12345.678']:
p=plan(f);w.writerow(['constructed',f,10000000,p['word'],'%.9f'%p['actual_hz'],'%.9f'%p['error_hz'],' '.join(p['words_hex'])])
if __name__=='__main__':main()
pico_dds.py
"""Manual AD9833 sine setup. Original Pico / MicroPython 1.26.0.
Host dds_plan.py uses fractions; this target script uses integer millihertz.
No pin or SPI action occurs when this module is imported.
"""
CLOCK_HZ=10000000
def tuning_word_millihz(millihz,clock_hz=CLOCK_HZ):
if type(millihz) is not int or type(clock_hz) is not int or not 0<clock_hz<=25000000 or not 0<=millihz<=clock_hz*500:raise ValueError('Invalid integer millihertz or clock')
denominator=clock_hz*1000
return (millihz*(1<<28)+denominator//2)//denominator
class DDS:
def __init__(self):
from machine import Pin,SPI
import time
self.delay=time.sleep_us;self.fsync=Pin(17,Pin.OUT,value=1)
self.spi=SPI(0,baudrate=1000000,polarity=1,phase=0,bits=8,firstbit=SPI.MSB,sck=Pin(18),mosi=Pin(19),miso=Pin(16))
# GP16 is an unused input, physically NC. Clock source must be running.
time.sleep_ms(10)
def write(self,word):
self.fsync(0);self.delay(2)
try:self.spi.write(bytes([word>>8,word&255]));self.delay(2)
finally:self.fsync(1);self.delay(2)
def set_sine(self,millihz):
n=tuning_word_millihz(millihz)
for w in [0x2100,0x4000|(n&0x3fff),0x4000|(n>>14),0xc000,0x2000]:self.write(w)
return n
def stop(self):
try:self.write(0x2100)
finally:self.fsync(1);self.spi.deinit()
def launch():
if input('Type QUALIFIED 10 MHz EXTERNAL CLOCK after checking wiring/clock: ')!='QUALIFIED 10 MHz EXTERNAL CLOCK':raise ValueError('Cancelled before pin setup')
d=DDS()
try:
for mhz in [999990,1000000,1000001,1000020]:
print('requested millihertz',mhz,'word',d.set_sine(mhz));input('Record actual result, then Enter for next setting: ')
finally:d.stop()
if __name__=='__main__':launch()
Complete host tests
import unittest,sys
from pathlib import Path
from fractions import Fraction
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'code'))
from dds_plan import plan,words,reconstruct,clock_gate
from pico_dds import tuning_word_millihz
class DDSTests(unittest.TestCase):
def test_known_one_sixteenth(self):self.assertEqual(plan(625000,10000000)['word'],0x1000000)
def test_known_1khz(self):self.assertEqual(plan(1000,10000000)['word'],26844);self.assertEqual(words(26844),[0x2100,0x68dc,0x4001,0xc000,0x2000])
def test_nearest_independent_fraction_oracle(self):
for hz in [1,31.25,999.99,1000,1000.01,12345.678,4999999]:
q=Fraction(str(hz))*2**28/10000000;n=(2*q.numerator+q.denominator)//(2*q.denominator);self.assertEqual(plan(hz,10000000)['word'],n)
def test_same_bin(self):self.assertEqual(plan(1000,10000000)['word'],plan(1000.001,10000000)['word'])
def test_half_up(self):self.assertEqual(plan(Fraction(10000000,2**29),10000000)['word'],1)
def test_zero_valid(self):self.assertEqual(plan(0,10000000)['word'],0)
def test_top_policy_edge(self):self.assertEqual(plan(5000000,10000000)['word'],1<<27)
def test_above_half_refused(self):
with self.assertRaises(ValueError):plan(5000000.01,10000000)
def test_bad_requests(self):
for f in [-1,'x',float('nan'),float('inf')]:
with self.assertRaises(ValueError):plan(f,10000000)
def test_bad_clocks(self):
for c in [0,-1,25000001,float('nan'),'x']:
with self.assertRaises(ValueError):plan(1,c)
def test_round_trip_all_bits(self):
for n in [0,1,16383,16384,26844,1<<27,(1<<28)-1]:self.assertEqual(reconstruct(words(n)[1:3]),n)
def test_low_first(self):self.assertEqual(words(0x1234567)[1:3],[0x4567,0x448d])
def test_malformed_word(self):
for n in [-1,1<<28,1.2,True]:
with self.assertRaises(ValueError):words(n)
with self.assertRaises(ValueError):reconstruct([0x8000,0x4000])
def test_clock_scaling(self):n=plan(1000,10000000)['word'];self.assertAlmostEqual(n*10000250/(1<<28)/(n*10000000/(1<<28)),1.000025)
def test_actual_target_integer_planner(self):
for mhz in [0,1,999990,1000000,1000001,1000020,5000000000]:self.assertEqual(tuning_word_millihz(mhz),plan(Fraction(mhz,1000))['word'])
def test_target_rejects_malformed(self):
for mhz in [-1,1.1,True,5000000001]:
with self.assertRaises(ValueError):tuning_word_millihz(mhz)
def test_clock_worst_case_gate(self):r=clock_gate();self.assertTrue(r['pass']);self.assertGreater(r['conservative_pulse_ns'],16);self.assertLess(r['fast_hz'],25000000)
if __name__=='__main__':unittest.main(verbosity=2)
Reader files and actual verification scope
Extraction and run instructions · Blank physical worksheet · Constructed example data · Pin/net checklist · Actual host test output. The reader archive contains these files; keep their relative folders together after extraction.
The supplied arithmetic model and host tests were executed. Physical frequency measurements, Pico execution and target firmware compilation were not performed. Constructed records are not bench measurements.