Skip to main content

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

  1. Opens BOARD_DAC0 and parks it at mid-rail.
  2. Steps a 32-point sine LUT out with alp_dac_write_mv, pacing each step with alp_delay_us for the requested sample rate.
  3. 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

Questions about this page? Discuss in Community Forum