0

Using HiFiBerry DAC+ with MCP3008 makes the audio device get stuck

I am trying to play a sound simultaneously while reading analog signals from MCP3008, which is an analog to digital converter (ADC) integrated chip. I have configured ADC to use SPI bus 0 so that it won't interfere with HiFiBerry.

ADC uses GPIO 6, 7, 12, 13, 23, 24 for reading analog signals and GPIO 8, 9, 10, 11 for CS, MISO, MOSI, CLK. 

I expect the system to work properly since there is no overlapping pins between two devices. The problem is, as soon as I initiate or activate ADC, the sound stops playing. 

Here are some details of config files and outputs from few commands.

$ /boot/config.txt

dtparam=spi=on
dtoverlay=hifiberry-dacplus

-----------------------------------------

$ aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

-----------------------------------------

(Playing a sound on a clean reboot)

$ mplayer completed.wav 

MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing completed.wav.
libavformat version 57.56.101 (external)
Mismatching header version 57.56.100
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 11025 Hz, 1 ch, u8, 88.2 kbit/100.00% (ratio: 11025->11025)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] Format u8 is not supported by hardware, trying default.
AO: [alsa] 11025Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 1.1 (01.0) of 1.0 (01.0) 0.1%


Exiting... (End of file)

-----------------------------------------

*** Running a python script to initialize ADC ***

-----------------------------------------

(Playing the exact same sound file)

$ mplayer completed.wav

MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing completed.wav.
libavformat version 57.56.101 (external)
Mismatching header version 57.56.100
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 11025 Hz, 1 ch, u8, 88.2 kbit/100.00% (ratio: 11025->11025)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] Format u8 is not supported by hardware, trying default.
AO: [alsa] 11025Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.0%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
Audio device got stuck!
A: 0.0 (00.0) of 1.0 (01.0) 0.1%
[1]+ Stopped mplayer completed.wav

-----------------------------------------

(Once again, attempt to play the same sound file)

$ mplayer completed.wav

MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing completed.wav.
libavformat version 57.56.101 (external)
Mismatching header version 57.56.100
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 11025 Hz, 1 ch, u8, 88.2 kbit/100.00% (ratio: 11025->11025)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] alsa-lib: pcm_hw.c:1602:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] Playback open error: Device or resource busy
Failed to initialize audio driver 'alsa'
[AO SDL] Samplerate: 11025Hz Channels: Mono Format u8
[AO SDL] using aalib audio driver.
[AO SDL] Unable to open audio: No available audio device
Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video


Exiting... (End of file)

 

 

At this point, I have no idea why the sound interface gets interrupted, or occupied by the ADC device, which is using a different channel to communicate. I would really appreciate it If anyone could give an insight into this problem.

2 comments

Please sign in to leave a comment.