Turns your STM32F4 development board into an analog signal generator with precise UART control. Uses built-in 12-bit DAC to produce waves of various form, frequency and level generated by Welle library.
Install Welle library header.
Install STM32CubeCLT command tools package with arm-none-eabi-gcc, STM32_Programmer_CLI and ST-LINK_gdbserver tools included.
Build the project using CMake:
mkdir build; cd build
# Using USART2 by default if -DUSE_USART3=1 flag isn't provided
cmake ../ -DPROGRAMMER_CLI=/opt/ST/STM32CubeCLT_1.18.0/STM32CubeProgrammer/bin/STM32_Programmer_CLI \
-DUSE_USART3=0
make
# Upload to the device
make flash
DAC output pin is PA4.
Using USART2 by default: TX PA2, RX PA3. Note that on Nucleo boards USART2 is routed to ST-Link USB, so that you can send UART commands directly by plugging-in the board via USB.
Using USART3 when built with -DUSE_USART3=1
:
TX PC10, RX PC11. Use this feature when external UART control is required.
Built-in DAC produces signals with max voltage = Vdda - 0.2V
, so for 3.3V supply it outputs signals with a peak-to-peak level 3.1V and DC offset 1.55V.
Connect a capacitor to the DAC output pin to remove the DC offset and generate signals oscillating around 0V.
# WaveForm Frequency(Hz) Level(mV)
sine|square|saw|triangle 10..30000 200..1500LF
Signal level is given without DC offset. Note that LF(\n)
at the end is required.
When using Nucleo board or any UART to USB adapter it's possible to send commands via a serial port.
# Install picocom serial port terminal
brew install picocom
# Find your connected device
ls /dev/tty.*
# Start session (press Ctrl+a Ctrl+x to exit)
picocom --echo --omap crlf --imap lfcrlf -b 115200 /dev/tty.usbmodem14203
# Generating 440Hz, 1500mV sine signal
sine 440 1500
# Generating 200Hz, 1500mV square signal
square 200 1500
# Generating 300Hz, 1500mV saw signal
saw 300 1500
# Generating 600Hz, 1500mV triangle signal
triangle 600 1500
Tests are using Digilent WaveForms SDK and require a compatible Analog Discovery device to be plugged-in and connected to the corresponding SMT32F4 pins.
cd ./integration-test
mkdir build; cd build
# The following pins configuration is default
cmake ../ -DSCOPE_CHANNEL=1 \
-DDIGITAL_TX_PIN=0 \
-DDIGITAL_RX_PIN=1
make
# Run tests
./SignalGeneratorIntegrationTests