A digital signal generator for verifying DSP filters and audio signal chains. This project configures a FRDM-MCXN947 as an I2S Master stimulus provider controlled via the Zephyr Shell, calibrated for the PCM5102A DAC.
This project is designed to run on one FRDM-MCXN947 board, acting as the Source, connected to a PCM5102A DAC (or compatible).
Use this setup to verify the generator output via listening or an oscilloscope.
| FRDM-MCXN947 (SAI1) | Signal | PCM5102A DAC |
|---|---|---|
| J1 Pin 1 (PIO3_16) | BCLK | BCK |
| J1 Pin 11 (PIO3_17) | LRCK | LCK |
| J1 Pin 5 (PIO3_20) | DATA | DIN |
| J1 Pin 14 | GND | GND |
| J1 Pin 16 | 3.3V | VCC |
Note: The PCM5102A generates its own MCLK from BCLK, so no MCLK connection is required for this phase.
In this configuration, Board A provides the digital stimulus to Board B. Board B processes the signal and outputs it to the DAC.
Inter-Board Wiring (I2S Bus):
| Board A (Generator) SAI1 - Master | Signal | Board B (DSP Filter) SAI1 - Slave |
|---|---|---|
| J1 Pin 1 (PIO3_16) | BCLK | J1 Pin 1 (PIO3_16) |
| J1 Pin 11 (PIO3_17) | LRCK | J1 Pin 11 (PIO3_17) |
| J1 Pin 5 (PIO3_20) | DATA | J1 Pin 5 (PIO3_20) |
| J1 Pin 14 | GND | J1 Pin 14 |
Board B Output (DSP Filter -> DAC):
Board B then uses its second SAI (sai0) to drive the DAC.
| Board B (SAI0) | Signal | PCM5102A DAC |
|---|---|---|
| PIO2_6 | BCLK | BCK |
| PIO2_7 | LRCK | LCK |
| PIO2_2 | DATA | DIN |
- Flash the
i2s-generatorproject to Board A. - Open a serial terminal (115200 baud).
- Use the
genshell commands to control the signal:
uart:~$ gen wave sine
uart:~$ gen freq 440
uart:~$ gen level pro
uart:~$ gen startTo start a continuous logarithmic sweep:
# Sweep from 20 Hz to 20 kHz over 5 seconds (5000 ms)
uart:~$ gen sweep start 20 20000 5000To stop the sweep and return to the fixed frequency:
uart:~$ gen sweep stopDiagnostic features for stereo imaging and transient response:
# Set Right channel 180 degrees out of phase
uart:~$ gen phase 180
# Start an 8-cycle on, 16-cycle off tone burst
uart:~$ gen burst start 8 16
# Stop burst mode
uart:~$ gen burst stopsine: Sine wave using CMSIS-DSP FastMath.white: White noise with 0V DC offset.pink: Pink noise (-3dB/octave) using the Voss-McCartney algorithm.square/triangle/saw: Geometric shapes.dirac: Periodic impulse train (Dirac Comb).silence: Digital silence (all zeros) for noise floor measurement.lrswap: Channel identification; alternates a sine tone between Left and Right every 1 second.imd: Intermodulation Distortion test signal (SMPTE RP120-1994).jtest: Jitter diagnostic signal (Julian Dunn, 1992).
max: 0 dBFS (2.165 Vrms).pro: +4 dBu (1.228 Vrms). Targets SMPTE RP155 / AES3 professional alignment.consumer: -10 dBV (0.316 Vrms). Targets IEC 60268-10 consumer standard.
- Pink Noise: McCartney, J. (1999). A New Pink Noise Algorithm.
- IMD (SMPTE): SMPTE RP120-1994. Measurement of Intermodulation Distortion in Audio Systems.
- J-Test: Dunn, J. (1992). A Sampled Test Signal for Jitter. Audio Engineering Society.
- Professional Levels: SMPTE RP155. Reference Level for Digital Audio Systems.
- Consumer Levels: IEC 60268-10. Sound system equipment - Peak programme level meters.
This generator is implemented with the following design choices on Cortex-M33:
- Encapsulated State: Generator parameters (phase, frequency, sweep, burst, noise state) are encapsulated in a
struct gen_state. - Fixed-Point DSP: Uses
q15_tandq31_tarithmetic. Floating point operations are excluded from the audio hot-path. - CMSIS-DSP: Employs
arm_sin_q15andarm_scale_q15for signal generation. - Persistent Clocking: Utilises the MCX SAI RX interface to provide stable, continuous bit-clocks for the transmitter.
To build for the FRDM-MCXN947:
west build -b frdm_mcxn947/mcxn947/cpu0 -p always