dac-waveform
Generate a sine wave on BOARD_DAC0 via a 32-point lookup table at a configurable sample rate, using <alp/dac.h>. Portable across families — BOARD_DAC0 resolves to the native Alif DAC12 on E1M (E1M-AEN801) and to the GD32-bridged DAC0 (PA4) on E1M-X (V2N).
Source: examples/peripheral-io/dac-waveform/.
What it does
- Opens
BOARD_DAC0and parks it at mid-rail. - Steps a 32-point sine LUT out with
alp_dac_write_mv, pacing each step withalp_delay_usfor the requested sample rate. - Uses integer-only Q15 scaling (no FPU) and parks at mid-rail again before
close().
board.yaml
som:
sku: E1M-AEN801 # or an E1M-X V2N SKU — BOARD_DAC0 resolves per family
preset: e1m-evk
cores:
m55_he:
app: ./src
peripherals: [dac]
diagnostics:
log_level: info
Expected output
A 32-step staircase sine approximation on the DAC pin. The console reports the configured sample rate and the per-step setpoints.
See also
<alp/dac.h>aen-analog-validate— DAC0 → ADC loopback on E8
Questions about this page? Discuss in Community Forum