A frequency generator board based on the AD9833 chip. Purchased as a frequency-tunable clock signal source. The board is equipped with a 25 MHz oscillator. It can generate signals from 0 to 12.5 MHz (though waveform quality may not be satisfactory across the entire range). The waveform can be switched between sine, sawtooth, and square wave. All necessary signals are brought out to pin headers. Controlled via SPI interface.
Architecturally, it contains one 28-bit phase accumulator register, two frequency tuning registers, and two phase offset registers. Only one pair (frequency/phase) can be active at a time. This allows for frequency modulation without phase discontinuity or phase modulation, if needed. However, there is no dedicated hardware input for selecting the register pair – switching is possible only via SPI commands.
Oscilloscope waveforms follow below.
Test setup
To control the DDS, commands must be sent via SPI. I am using an STM8 (STM8S105K4T6) with its hardware SPI. It was crucial to find the correct SPI operating mode. For the STM8 (and likely for STM32 as well), this is Mode 2 (CPOL = 1, CPHA = 0). For more details, refer to the documentation.(RM0016 - STM8S Series and STM8AF Series 8-bit microcontrollers (20.4 SPI registers)). Oscilloscope: C1-112A, 10 MHz bandwidth; probe: generic Chinese P6100 type, rated for 100 MHz. Multimeter: Aneng M20, used as a frequency counter.
I did not write firmware for the microcontroller in the conventional sense. Instead, I flashed the STM8 with the eForth system and connected to it via a serial console. From the console, I sent SPI commands directly, after pre-defining the necessary intermediate words. It looked roughly like this:
...
: word.hi $0100 / ;
: word.lo $00ff and ;
: spi_wr8 SPI_DR c! TXE? ;
: spi_wr16 dup word.lo swap word.hi spi_wr8 spi_wr8 ;
: spi_wr16n dup word.lo swap word.hi nss.lo spi_wr8 spi_wr8 BSY? nss.hi ;
: spi_wr32n nss.lo spi_wr16 spi_wr16 bsy? nss.hi ;
...
$2100 spi_wr16n // reset
$5c20 $4a3d spi_wr32n // freq0
%0111111111111111 %0100000000000000 spi_wr32n // freq0
%0111111111111111 spi_wr16n %0100000000000000 spi_wr16n
$9c29 $8a3d spi_wr32n // freq1
$c000 spi_wr16n // phase0f
$e000 spi_wr16n // phase1
$2000 spi_wr16n // sine
$2020 spi_wr16n // square
$2002 spi_wr16n // saw
It turned out that I used the system interactively, rather than reflashing the firmware each time. This approach reminds me of working with the Erlang virtual machine, where you can debug and modify running code on the fly on production.
Oscilloscope Waveforms
Sine 1 KHz
At 2 MHz, floating peaks on the sawtooth waveform are already visible. At 4 MHz, they become very pronounced. And at 8 MHz, we end up with 25/8 = 3.125 samples per period.
Purely to explore my oscilloscope and probes, I also tried the square wave mode. However, I couldn't be bothered to recalculate the frequency grid. In square wave mode, the period is twice as long, so the resulting frequencies were different.
5 kHz
Starting from 1 MHz, jitter is obviously present; at 2 MHz, it becomes visible on the oscilloscope waveform.
By the way (for those who aren't aware), it's important to note that at high frequencies, to avoid degrading signal edges, you should use the probe in 10:1 attenuation mode. This reduces the probe's loading effect on the circuit (and it's even better to avoid using alligator clips altogether). However, this will require increasing the oscilloscope's input amplifier gain by a factor of 10 to compensate for the attenuation.
Also, don't forget to adjust the probe compensation for accurate waveform display, using a small dielectric (non-metallic) screwdriver.
For comparison, here's a photo showing the same signal — a 2 MHz square wave — captured with the probe set to 1X versus 10X attenuation.
By the way, the original probe that came with the C1-112A is also quite decent.
Conclusions
I acquired this board for experiments in the field of hybrid sound synthesis for my synthesizer project. In the future, I plan to use it for a DCO (Digitally Controlled Oscillator) module — but not with a fixed Master Clock frequency; rather, with a frequency that is a multiple of the generated note frequency. This way, the DAC in the DCO can utilize its full scale and DAC resolution without skipping steps. All of this is part of the effort to combat generation accuracy loss and aliasing... But that's a whole different story.
Links
1 The original version of this article
https://mysku.club/blog/aliexpress/79168.html
2 eForth - Forth for microcontrollers
https://github.com/TG9541/stm8ef/wiki/STM8-eForth-Programming
3 Links about my synth project
https://github.com/UA3MQJ/fpga-synth/wiki
https://github.com/VitaSound/hdl-modules
https://soundcloud.com/vitasynth






























Top comments (0)