Continuous playback

Discussions about active development projects
Posts: 11
Joined: Sun Mar 28, 2021 8:04 am

Re: Continuous playback

Post by hermy_sf » Wed May 05, 2021 8:47 am

Hi Pavel,
Sorry for my delayed reply, I was too busy. Thanks for these code snippets, I implemented them and they work perfectly. Very happy indeed :D !

Best regards


Posts: 1
Joined: Mon May 24, 2021 12:34 am

Re: Continuous playback

Post by Darki91 » Mon May 24, 2021 12:48 am

pavel wrote:
Thu Nov 19, 2015 4:05 pm
Hi Cees,

OK for an easy start at 1 Msps with very simple interpolation and decimation.

I've prepared a new FPGA configuration that contains two data processing chains:
  1. DAC data processing chain
    • Writer (gets samples from AXI bus and writes them to AXI-Stream bus)
    • FIFO (32k samples)
    • Zeroer (sends zeros if FIFO is empty)
    • Simple interpolator (sends the same sample N times)
    • FIFO (transports samples from FPGA clock domain to DAC clock domain)
    • DAC interface
  2. ADC data processing chain:
    • ADC interface
    • FIFO (transports samples from ADC clock domain to FPGA clock domain)
    • Simple decimator (accepts 1 sample every M samples)
    • RAM writer (gets samples from AXI-Stream bus and writes them to RAM via AXI bus)
This FPGA configuration also contains some configuration and status registers to configure and to monitor some of the elements of these two data processing chains.

There are two short C programs: adc-recorder.c and dac-player.c.

All the source codes can be found at: ... dac_player

Pre-built FPGA configuration bitstream file (dac_player.bit) can be downloaded from: ... player.bit

Commands to configure FPGA and run the C programs:
  1. download and install the latest Red Pitaya SD card image following the instructions at
  2. set FPGA clock to 143 MHz

    Code: Select all

    echo fclk0 > $devcfg/fclk_export
    echo 1 > $devcfg/fclk/fclk0/enable
    echo 143000000 > $devcfg/fclk/fclk0/set_rate
  3. configure FPGA

    Code: Select all

    cat dac_player.bit > /dev/xdevcfg
  4. compile and run ADC recorder at 1 Msps (decimation factor 125)

    Code: Select all

    gcc adc-recorder.c -o adc-recorder
    ./adc-recorder 125 record.dat
  5. compile and run DAC player at 1 Msps (interpolation factor 125)

    Code: Select all

    gcc dac-player.c -o dac-player
    ./dac-player 125 record.dat
Best regards,

Hi Pavel,

Maybe some things have changed since 2015 but i'm interested by this adc_recorder / dac_player couple and, perhaps due to my lack of experience, i have not been able to make it works.

My RP board used V1.04 build 9 Ecosystem, i have generate the bitstream under vivado using your Tcl scripts and compile the two c programs. However i get an error after adc_recorder execution, it seems that something missing which is probably the "Contiguous Memory Allocator" (/dev/cma does not exists).

A little help is possible would be welcome, is there ant way to enable the CMA in the ecosystem Kernel ?

Thanks by advance.

Posts: 644
Joined: Sat May 23, 2015 5:22 pm

Re: Continuous playback

Post by pavel » Mon May 24, 2021 10:28 am

I've recently written a small driver that allocates memory using the contiguous memory allocator (CMA). With this new driver, my applications can now write directly to the cached memory.

Here is a link to the source code of this driver: ... ches/cma.c

To compile this driver during the compilation of the Linux kernel, I copy it to drivers/char directory in the source code of the Linux kernel and apply the following patches: ... #L170-L196

The code without the CMA driver is also accessible. Here is a link to the last commit before I added the CMA driver: ... 2bd6185449

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: Bing [Bot] and 1 guest