Running an SPDIF example program on XK-EVK-XU316

Discussions relating to the XK-EVK-XU316
Kronoh
Junior Member
Posts: 6
Joined: Wed May 10, 2023 10:01 am

Running an SPDIF example program on XK-EVK-XU316

Post by Kronoh »

Hi, I have problems with an SPDIF program that i want to flash on my XK-EVK-XU316 board.

This is the program :

#include <xs1.h>
#include <platform.h>
#include "SpdifTransmit.h"

#define SAMPLE_FREQUENCY_HZ 96000
#define MASTER_CLOCK_FREQUENCY_HZ 12288000

on stdcore[1] : buffered out port:32 oneBitPort = XS1_PORT_1K;
on stdcore[1] : in port masterClockPort = XS1_PORT_1L;
on stdcore[1] : clock clockblock = XS1_CLKBLK_1;

void transmitSpdif (chanend c)
{
SpdifTransmitPortConfig (oneBitPort, clockblock, masterClockPort);
SpdifTransmit (oneBitPort, c);
}



#define WAVE_LEN 512


void generate (chanend c)
{
int i = 0;
outuint (c, SAMPLE_FREQUENCY_HZ);
outuint (c, MASTER_CLOCK_FREQUENCY_HZ);
while (1)
{
// Generate a triangle wave
int sample = i;

if ( i > ( WAVE_LEN / 4))
{
// After the first quarter of the cycle
sample = ( WAVE_LEN / 2) - i ;
}
if ( i > (3 * WAVE_LEN / 4))
{
// In the last quarter of the cycle
sample = i - WAVE_LEN;
}
sample <<= 23; // Shift to highest but 1 bits
outuint (c, sample); // Left channel
outuint (c, sample); // Right channel
i++;
i %= WAVE_LEN;
}
outct (c, XS1_CT_END); // to stop SpdifTransmit thread
}


void example (void)
{
chan c;
setupPll();
par
{
transmitSpdif(c);
generate (c);
clockGen();
}
}

int main (void)
{
par
{
on stdcore[1]: example();
}
return 0;
}

You can fin the program page 9 of this document :
https://www.xmos.ai/download/S-PDIF-Sof ... 9128A).pdf

When im trying to compile the program on the XTC Tools 15.2.1 (with the command line "xcc -O2 -Wall -target=XK-EVK-XU316 spdifTEST.xc -o spdifTEST.xe") I get errors :

spdifTEST.xc:56:3: error: unknown function identifier `setupPll' (possibly missing prototype?)
setupPll();
^
spdifTEST.xc:61:5: error: unknown function identifier `clockGen' (possibly missing prototype?)
clockGen();
^
I didnt modify the program and I work on the XTC Tools 15.2.1.

Does anyone can help me ? :)
User avatar
Ross
Verified
XCore Legend
Posts: 1070
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Try the latest example from www.github.com/xmos/lib_spdif they have been updated for the new XK-AUDIO-316-MC board but should operate on your XK-EVK-XU-316 (if you add the required external S/PDIF circuity and possibly modify the S/PDIF port to avoid clashes with other hardware on that board)
Technical Director @ XMOS. Opinions expressed are my own