Using the RPi5's videodac as a general purpose DAC
Pieter-Tjerk de Boer, PA3FWM web@pa3fwm.nlThe Raspberry Pi 5 board has a composite video output, for driving analog TVs. This page is about using this output as a general-purpose analog output. The DAC (digital to analog converter) driving it, turns out to have 10 bits of resolution and support samplerates well over 100 MHz, with a nominal 1.28 V output swing when driving a 75 ohm load. (Tantalizingly, it seems the chip contains three such DACs, intended for R/G/B analog video, but only one is accessible on the RPi5 board.)
Background
Ever since the first Raspberry Pi, these single-board computers have had a composite video output.
In the early models it was made prominently available on an RCA socket.
On the current RPi 5, it is only available as soldering islands on the board, presumably
because of reduced interest in driving analog TVs.
There is however another important difference between the older RPi:s and the RPi5. In the older versions, the composite video output came out of the main Broadcom System-on-Chip. In the RPi5, the composite video comes out of a separate chip, designed by the Raspberry Pi foundation themselves. This chip's composite output turns out to be more flexible than the Broadcom chip. The Broadcom chip insists on generating synchronisation pulses (which are a normal part of the composite video signal), while in the RP1 chip these can be switched off, leaving a 'pure' analog output.
Much of what I describe here was done based on a short posting on this thread on the Raspberry Pi forum, where Raspberry Pi engineer 'njh' gave some hints for using the composite output as a general purpose output, saying it 'might be possible, with various gotchas'. That sounded rather tentative and speculative, but it actually turned out to be pretty easy to do, as documented below.
Direct writes to the DAC
One way to use the composite output as a general-purpose DAC is very simple: one can just directly write values to it, without further ado. This is possible thanks to the chip having a mode in which the DAC outputs a constant value, completely ignoring the data coming from video memory (presumably intended for testing). You first once write 0x0019ffff to the register at address 0x1f00140004 to enable the DAC, and then 0x40000000+data, where data is your 10 bit data, to the register at address 0x1f00140010. That's it!
The only complexity is actually writing to I/O registers from a regular user-space program;
that's done by opening, with root privileges, the special /dev/mem device.
In C, that looks like this:
Streaming writes to the DAC using the video hardware
If you want to send data to the DAC at high rate and with nicely regular timing,
doing direct writes as described above is not efficient or reliable.
There is an alternative though:
configure the DAC as a video output.
After all, the normal use of the video DAC is to send image intensities to the monitor,
pixel by pixel from left to right, and line by line from top to bottom, about 60 screenfuls per second.
In a normal composite video signal, this stream is briefly interrupted at the end of every line
and at the end of every screenful to insert synchronization pulses.
Fortunately, it turns out that in the RP1 chip these can be disabled,
leaving a continuous, uninterrupted, datastream,
repeatedly sending out data from the framebuffer video memory,
all by itself, at a constant rate.
I got this to work as follows:
- Configure the RPi5's DPI (Display Parallel Interface) video output in the RPi's config.txt: this sends digital video data to a bunch of GPIO pins, actually meant to drive some types of LCDs.
- Writes to the RP1 chip's registers to reconfigure it:
- disable the sync pulses,
- enable the DAC,
- route the video data to the DAC (besides the GPIO pins),
- read video memory with 2 rather than 4 bytes per sample (the video configuration defaults to 24 bpp, stored in 4 bytes, while we need only 10 bits per output sample, for which 2 bytes suffice).
- Disable the blinking cursor (which otherwise still gets written to the video memory and thence to the DAC).
- Write the to-be-outputted data to the appropriate part video memory, using the framebuffer /dev/fb0 interface. Some synchronization is needed, in order to write new data after the previous frame has been read; the RP1 chip has some interrupt registers which can be used for this.
I have to admit that the above approach, piggybacking on the normal video configuration, is a hack. It was easy to get to work, but it has some disadvantages:
- Any text or graphic data that is (accidentally) still written to the screen disturbs the DAC output.
- It seems impossible to still attach a real screen in parallel; I would think the HDMI output(s) should work independently, but if I plug in a monitor in one of those, the DPI stuff does not get configured correctly anymore.
- I haven't found out how to set the clock frequency other than in config.txt.
- The data is still also uselessly streamed to the GPIO pins, making those unavailable for other use.
Applications
What can this be used for? Some ideas:- A general purpose signal generator, as exemplified by my demo program.
- Generating a decently clean radio signal for use in a a radio transmitter; I'm emphasizing the cleanliness, as previous methods for transmitting with a RPi generate rather dirty signals using a GPIO pin.
- Generating lots of radio signals simultaneously, as in my DAB-to-AM converter, which generates up to 16 simultaneous AM broadcast signals, for reviving old tube-era radios.
- Play back wideband SDR spectrum recordings.
Text and pictures on this page are copyright 2026, P.T. de Boer, web@pa3fwm.nl .
Republication is only allowed with my explicit permission.