Post Go back to editing

How to sync SPORT Tx and Rx

Using ADSP-SC573 Sharc core, SPORT driver from CCES 2.8.3

I'm trying to test a signal channel by transmitting known signals through the channel and receiving what comes out the other end. I'm using both HSPORTs in a SPORT, one for Tx and the other for Rx, for talking to a single audio CODEC. The CODEC is generating the clocks. Since it's a sigma-delta CODEC, there's a long round-trip delay, which is okay, but there is a one sample uncertainty in the delay, due to the fact that starting the Tx and Rx are two separate operations, and a frame sync can arrive between them. That's not okay. The SPORT is running in I2S mode at a 192K sample rate, 16-bit stereo, using DMA.

How do you do this? How do you guarantee that both Tx and Rx start on the same frame, when using an external clock? Even if I hand-coded it all in assembler, it appears that the enable bit for the two HSPORTs are in two different registers, so I don't see how to start them at the exact same instant. I could probably set up an interrupt handler on the frame sync, and start everything from there, which could work if the time to start them both was well under one frame time, but 5us isn't a very long time, and the ADI drivers do a lot of stuff. Is there an easier way?

  • In case anyone is interested, I eventually managed to solve this problem. I had to deal with two things. First, to ensure that starting Tx and starting Rx didn't straddle a frame sync, I configured the SPORT DMA channels to wait for one of the software triggers supported by the TRU (you can use the first three; the last three are used by MCAPI). Then, after calling adi_sport_Enable for both directions, I disabled interrupts, polled the DAI port bit line used for the frame sync until the appropriate edge occurred, issued the trigger to start both DMAs, and then re-enabled interrupts. Second, to ensure there wasn't a stale sample sitting in the receiver that would throw the alignment off, just before issuing the trigger, I toggled the Rx SPORT half's enable off and on.

    If I only did one or the other of those two things, I'd occasionally get misaligned Tx/Rx. When I did both, the problem was finally solved. It's ugly, but it works.

  • Hi pderocco,

    I also have this problem now. I want to sync all the SPORTs in the same time so that I can send the input datas to the output immediately rather than delay for a block processing time.

    Do you have any new ideas about this problem now?

    Thanks for sharing!

  • The solution I described works, and I don't see any simpler way to do it. But I should also point out that for this to work, the CODEC, or some other external source, must be the I2S master. If the processor is the master, then the clocks will start and stop every time you enable and disable the I2S, and CODEC chips really don't like this. There is probably a way to make the processor generate continuous clocks, but I don't see a way given the existing ADI library code.

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.