[En-Nut-Discussion] stammering audio playback on EIR/VS1053B

Harald Kipp harald.kipp at egnite.de
Wed Feb 15 18:33:04 CET 2012

Hi Charles,

On 15.02.2012 16:19, Bonnemayer C (PSYCHOLOGY) wrote:
> With a slightly modified version of the NutWiki MMC MP3 player I tried to play .ogg and .flac files (the latter with the VS1053B patch v1.95) on my EIR board.  It appears that when using high quality files (with low compression and/or high bitrates) the output is interrupted during playback. I.e. the file plays for a second or so, waits for half a second, and then continues where it has left, this happens intermittentally.  I tried several audio formats and to me it seems that high bitrate files (mp3  > 192 kbps, ogg >  44.1KHz, 147kbps) have more problems than low bitrate files.
> I played around with some settings, but changing VSCODEC0_OUTPUT_BUFSIZ in audio.h doesn't help. Also, changing VSCODEC0_SPI_RATE has no effect.
> it looks like that the problem lies in the fact that the VS1053 codec shares the SPI bus with the MMC interface, so there's a lot of data trafic on this bus. Unfortunately I don't have a logic analyzer, so I can't verify this.

When designing the EIR, I intentionally did not share the SPI bus between MMC and the codec. Instead, I connected the MMC to the SSC in the hope, that one day I may be able to mimic SPI with the SSC interface. A first attempt failed, so I decided to use software SPI (bit-banging) as a temporary solution.

However, when trying to play audio files from MMC, I experienced the same problems that you described.

The good news is, that I finally managed to make SPI working on the SSC hardware, even with DMA (Atmel term: PDC). The bad new is, that a minor hardware change is required. You must connect

PA16(TK) Port A connector pin 17


PA19(RK) Port A connector pin 20

The problem with SSC is, that you cannot stop the receiver. But you can stop the transmitter, so my idea was to feed the receiver clock from the transmitter clock. I created a new SPI buts driver based on SSC and... it works! :-)

The bad news is, that we are, in general, not allowed to add new features to a stable version. Therefore this new driver is only available in the current beta 5.0. However, I'm almost sure, that the driver will work with version 4.10 too. If you do not want to modify the configuration scripts (which may not be trivial, because the directory structure was modified), then you can simply place the driver's code in your local app directory and add it to the app's Makefile.

You can find the code here
Look out for spibus*at91ssc.c.

There's also an include file required
#include <dev/spibus_ssc.h>
or, if locally used
#include "spibus_ssc.h"

If you are considering to upgrade to Nut/OS 5.0 (looks quite stable to me), then you may wait a bit. I'm currently building a new beta release.

Here's the code to use this new driver:

printf("Register memory card device...");
if (NutRegisterSpiDevice(&devSpiMmcGpio, &spiBus0Ssc, 0)) {
} else {

printf("Register file system...");
if (NutRegisterDevice(&devPhat0, 0, 0)) {
} else {

printf("Mounting memory card...");
volid = _open(DEV_MMCARD_NAME ":1/PHAT0", _O_RDWR | _O_BINARY);
if (volid == -1) {
    printf("Error %d\n", errno);
    for (;;);

So far I had no time to test its real performance, but playing and recording on MMC worked. I remember having had problems with recording 192kbps streams, probably because of MMC latencies. This may be solved by using larger buffers.

I'm also aware, that the PHAT filesystem layer is somewhat slow.

Best regards,


More information about the En-Nut-Discussion mailing list