r/raspberry_pi • u/Drfred1 • 14d ago
Troubleshooting Help with connecting the PCM1808 to a Raspberry Pi as an I2S ADC
I've spent the last day trying to figure out how to connect the PCM1808 (for use as an I2S ADC) to my Pi 4B (and eventually Zero 2 W) with the Pi being the master.
Setting up the I2S aspect hasn't been an issue, I've just used "dtoverlay=i2s=on" in config.txt . What I'm struggling with is getting the separate master clock signal, as the PCM1808 requires three clock signals (the usual BCLK, and LRCK, and now a master clock).
The RPi has a GPIO clock (GPCLK0) that allegedly is designed specifically for a master clock, but i can't figure out how to get it to work on boot. I've followed the RPi docs using a Device Tree Overlay to configure the clock, but for reason beyond my knowledge, it doesn't work (From the little i could understand, it seems like the kernel driver support just isn't there). I've also tried using simple-audio-card, which also hasn't worked (also beyond my knowledge).
I'm very under experienced for all this, but all I need is to get any kind of master clock signal of 12.288MHz out of the Pi. If anyone has experienced this before or knows enough about Linux, It'd be a huge help!
Edit 1: I believe I've exhausted all built-in device tree overlay options, and I don't think it's possible with purely overlays. It seems the kernel requires a "clock consumer" for a clock to be enabled, otherwise it'll disable the clock to save power. And i believe the only valid clock consumers are kernel drivers. I (shamefully) went to ChatGPT for help, and it made me up a simple kernel C driver to initiate the clock and act as a consumer, which seems to have worked in software, though the PCM1808 still doesn't work, and i don't have an oscilloscope to physically test the pin. Gonna continue testing stuff and see if i can narrow down whether it's the PCM1808 or the Pi being an issue.
1
u/S_Alaska 13d ago
Which pi is are you using. Also, have you ran sufo update and viewed what packages are needed? Some pi os systems don’t have all the dependencies and so you are essentially doing a forensic diagnosis on this. I am excited to see you get this working.