S/PDIF passthrough - Slow I/O? Noise?

03 Sep 2011

Hi! I'm doing some research on S/PDIF and I'm trying to use the mbed as a passthrough device between a Toslink (TORX) receiver and a transmitter (TOTX). Connecting the receiver to the transmitter directly works fine. I believe my issue is with the I/O performance of the mbed, but I've read that it can go up to 24MHz and S/PDIF requires 6MHz from what I've read. First I tried using DigitalOut/DigitalIn, but that was clearly just too slow, so I tried using FastOut, even optimizing it a bit extra, but that didn't work either.

My last test has been using the registers directly (p21 = input, p22 = output):

#include "mbed.h"

int main() {
    LPC_GPIO2->FIODIR |= (1 << 4);
    
    while (1) {
        LPC_GPIO2->FIOPIN = (LPC_GPIO2->FIOPIN & 0xFFFFFFCF) | ((LPC_GPIO2->FIOPIN & (1 << 5)) >> 1);
    }
}

It still doesn't work with S/PDIF, but at least the code works. Unfortunately I don't have a scope, so I can't compare the output to the input, otherwise I could see if there was any noise in the output.

The passthrough is just a test, later on I want the mbed to encode/decode S/PDIF data.

So, does anyone know why the signal doesn't come out correctly? Wouldn't the code above be fast enough (>6MHz) to capture and output the signal properly?

03 Sep 2011

maybe you got a little confused with the S/PDIF parameters: it can be 2.0 Mbps at 32 kHz sampling rate, 2.8 Mbps at 44,1 kHz sampling rate or 3.1 Mbps at 48 kHz sampling rate and the peak voltage is at + AND - 0.5V So you have to check for positive and negative input and output voltage.

03 Sep 2011

I'm doing optical S/PDIF, not coaxial. The transmitters and receivers are TTL (going high at +2V). As for the speed, 3.1Mbps is the bitrate required to be able to transfer audio at a sampling rate of 48kHz, but since S/PDIF uses biphase mark code the clock frequency must be double that, so 6.2MHz for 48kHz sampling rate. Based on the other threads I've read about the I/O performance of the mbed, it should be able to run about 3-4 times faster than required.

04 Sep 2011

yeah, the mbed should be able to sample that. but I haven't worked with the optical S/PDIF.

04 Sep 2011

yeah, the mbed should be able to sample that. but I haven't worked with the optical S/PDIF.

04 Sep 2011

The receiver just outputs a TTL signal on its output pin and the transmitter takes a TTL signal on its input pin, so it's not really different from any other digital electronics. This is why I find it weird that the code i posted (and FastOut) fails, since it seems to work fine with slower signals (like UART). I really need to get my hands on a logic analyzer ... Or build one, since I do have another mbed sitting in its box.

04 Sep 2011

did you try using high priority interrupts?

have your input pin trigger an interrupt on rising edge and do the sending inside the ISR.

04 Sep 2011

scratch that, i just found out the EINTx pins are not broken out on the mbed board

04 Sep 2011

This is what I managed to capture using a simple logic analyzer based on another mbed:

http://frigolit.net/tmp/mbedlogic.gif

This is with one channel completely disabled in code, so it runs a bit faster. This is with both channels (input and output):

http://frigolit.net/tmp/mbedlogic2.gif

They're clearly not identical, but I'm unsure if this is because of the logic analyzer being to slow. Regardless, if it's too slow to capture two channels of S/PDIF data, then the mbed won't be able to do what I had in mind anyway, at least not without extra components (like S/PDIF decoder ICs).

Herson: I haven't, but I doubt it'll make any difference since it should by running as fast as it can as it is. I can of course try anyway. (edit: just saw your post about EINTx) I'm also going to redo the tests with a proper logic analyzer, since I don't even know the timing on this simple build :P But I don't have it here, so it'll have to wait.

15 Feb 2014

I know this post is quit old ;o) But does someone think that it would be possible to decode an spdif ttl signal with an LPC4088 QSB ? (using moddma library to get max of bandwidth).

Thanks for your advices.