Hello,
trying to find out what is the max supported sr for spdif rx library functionality. Since there is 96kHz in the library doc but have seen 192kHz in the code comments.
Can somebody confirm production grade sample rate limit for spdif rx implemented in xmos lib_spdif 2.0.2?
thanks in advance.
wbr
malo
Spdif rx 192kHz
-
- Active Member
- Posts: 33
- Joined: Fri Sep 16, 2016 9:03 pm
-
Verified
- Respected Member
- Posts: 347
- Joined: Wed Jan 27, 2016 5:21 pm
Hi Malo,
192 kHz works fine if the physical layer does not add a lot of jitter to the signal. If the physical layer adds a lot of jitter (optical transceivers can be notorious by adding different delays to rising and falling edges), then 192 is beyond the capabilities of the rX software component.
Cheers,
Henk
192 kHz works fine if the physical layer does not add a lot of jitter to the signal. If the physical layer adds a lot of jitter (optical transceivers can be notorious by adding different delays to rising and falling edges), then 192 is beyond the capabilities of the rX software component.
Cheers,
Henk
-
- Active Member
- Posts: 33
- Joined: Fri Sep 16, 2016 9:03 pm
Hello Henk,
thanks for quick answer.
have coax input for spdif and production circuity with transformer. Testing with Digirator DR2.
The problem is that I'm still loosing samples - like 1 mono sample per hour...
For me seems like the problem is with spdif "sampling" implementation with different sampling rate.
Just wanted to know if somebody got it working on 192kHz wo loosing the samples, or ext spdif receiver with PLL is the way to go?
wbr
malo
thanks for quick answer.
have coax input for spdif and production circuity with transformer. Testing with Digirator DR2.
The problem is that I'm still loosing samples - like 1 mono sample per hour...
For me seems like the problem is with spdif "sampling" implementation with different sampling rate.
Just wanted to know if somebody got it working on 192kHz wo loosing the samples, or ext spdif receiver with PLL is the way to go?
wbr
malo
-
- Active Member
- Posts: 33
- Joined: Fri Sep 16, 2016 9:03 pm
Hello,
made simple program for xCORE-200 MC AUDIO eval board. just coax spdif receiver (lib_spdif 2.0.2) with spdif handler task and debug task.
spdif handler task checks for left->right->left->right... sequence and counts the bad ones.
code is build with "-O3 -g -report " and using xscope for fast printfs.
Digirator DR2 set to 192kHz output is connected with coax to the eval board.
Here is the output:
Lost 8 samples in less than 2 hrs...
Any ideas / conclusions?
wbr
malo
made simple program for xCORE-200 MC AUDIO eval board. just coax spdif receiver (lib_spdif 2.0.2) with spdif handler task and debug task.
spdif handler task checks for left->right->left->right... sequence and counts the bad ones.
Code: Select all
#include <xs1.h>
#include <platform.h>
#include <stdio.h>
#include "spdif.h"
#define MAIN_TILE 0
#define SPDIF_TILE 1
port port_spdif_rx = on tile[SPDIF_TILE]: XS1_PORT_1P;
clock clk_spdif_rx = on tile[SPDIF_TILE]: XS1_CLKBLK_1;
#define DEFAULT_FREQ_HZ_SPDIF 192000
#define DEBUG_INTERVAL_S 10
#define S_TO_TIMER_TICKS(value_ms_) ((value_ms_) * XS1_TIMER_HZ)
typedef interface debug_if
{
void get_counts (unsigned int& count_, unsigned int& bad_count_);
} debug_if;
void debug_task (client interface debug_if i_debug_)
{
timer t_debug;
unsigned int next_debug = 0;
t_debug :> next_debug;
next_debug += S_TO_TIMER_TICKS (DEBUG_INTERVAL_S);
unsigned int count = 0;
unsigned int bad_count = 0;
unsigned int interval_count = 0;
while (1)
{
select
{
case t_debug when timerafter (next_debug) :> void:
next_debug += S_TO_TIMER_TICKS (DEBUG_INTERVAL_S);
i_debug_.get_counts (count, bad_count);
interval_count++;
printf ("%d s: %d/%d\n", interval_count * DEBUG_INTERVAL_S, count, bad_count);
break;
}
}
}
void spdif_handler_task (streaming chanend c_spdif_rx, server interface debug_if i_debug_)
{
unsigned int index = 0;
int32_t sample = 0;
unsigned int count = 0;
// 0: have received right - expecting left
// 1: have received left - expecting right
unsigned int expecting_channel = 0;
unsigned int bad_count = 0;
while (1)
{
select
{
case spdif_receive_sample(c_spdif_rx, sample, index):
// Check expectations
if (expecting_channel != index)
{
bad_count++;
}
else
{
expecting_channel ^= 1;
}
// Count stereo samples.
if (index)
{
count++;
}
break;
case i_debug_.get_counts (unsigned int& count_, unsigned int& bad_count_):
// Return to the debug task.
count_ = count;
bad_count_ = bad_count;
break;
}
}
}
int main()
{
interface debug_if i_debug;
streaming chan c_spdif_rx;
par
{
on tile [SPDIF_TILE]: spdif_rx (c_spdif_rx, port_spdif_rx, clk_spdif_rx, DEFAULT_FREQ_HZ_SPDIF);
on tile [SPDIF_TILE]: spdif_handler_task (c_spdif_rx, i_debug);
on tile [MAIN_TILE]: debug_task (i_debug);
}
return 0;
}
Digirator DR2 set to 192kHz output is connected with coax to the eval board.
Here is the output:
Code: Select all
10 s: 1920043/0
20 s: 3840086/0
30 s: 5760129/0
40 s: 7680172/0
50 s: 9600215/0
60 s: 11520258/0
70 s: 13440301/0
80 s: 15360344/0
90 s: 17280387/0
100 s: 19200431/0
110 s: 21120474/0
120 s: 23040517/0
130 s: 24960560/0
140 s: 26880603/0
150 s: 28800646/0
160 s: 30720689/0
170 s: 32640732/0
180 s: 34560775/0
190 s: 36480818/0
200 s: 38400861/0
210 s: 40320904/0
220 s: 42240947/0
230 s: 44160990/0
240 s: 46081033/0
250 s: 48001076/0
260 s: 49921119/0
270 s: 51841162/0
280 s: 53761205/0
290 s: 55681248/0
300 s: 57601291/0
310 s: 59521334/0
320 s: 61441377/0
330 s: 63361420/0
340 s: 65281463/0
350 s: 67201506/0
360 s: 69121549/0
370 s: 71041592/0
380 s: 72961635/0
390 s: 74881678/0
400 s: 76801721/0
410 s: 78721764/0
420 s: 80641806/1
430 s: 82561848/1
440 s: 84481891/1
450 s: 86401934/1
460 s: 88321977/1
470 s: 90242019/2
480 s: 92162062/2
490 s: 94082105/2
500 s: 96002148/2
510 s: 97922190/2
520 s: 99842233/2
530 s: 101762276/2
540 s: 103682319/2
550 s: 105602362/2
560 s: 107522405/2
570 s: 109442448/2
580 s: 111362490/2
590 s: 113282533/2
600 s: 115202576/2
610 s: 117122619/2
620 s: 119042662/2
630 s: 120962705/2
640 s: 122882748/2
650 s: 124802790/2
660 s: 126722833/2
670 s: 128642876/2
680 s: 130562919/2
690 s: 132482962/2
700 s: 134403004/2
710 s: 136323047/2
720 s: 138243090/2
730 s: 140163133/2
740 s: 142083175/2
750 s: 144003218/2
760 s: 145923261/2
770 s: 147843304/2
780 s: 149763346/2
790 s: 151683389/2
800 s: 153603432/2
810 s: 155523475/2
820 s: 157443517/2
830 s: 159363560/2
840 s: 161283603/2
850 s: 163203646/2
860 s: 165123689/2
870 s: 167043731/2
880 s: 168963774/2
890 s: 170883817/2
900 s: 172803860/2
910 s: 174723902/2
920 s: 176643945/2
930 s: 178563988/2
940 s: 180484031/2
950 s: 182404073/2
960 s: 184324116/2
970 s: 186244159/2
980 s: 188164202/2
990 s: 190084245/2
1000 s: 192004288/2
1010 s: 193924330/2
1020 s: 195844373/2
1030 s: 197764416/2
1040 s: 199684459/2
1050 s: 201604502/2
1060 s: 203524545/2
1070 s: 205444587/2
1080 s: 207364630/2
1090 s: 209284673/2
1100 s: 211204716/2
1110 s: 213124759/2
1120 s: 215044802/2
1130 s: 216964845/2
1140 s: 218884888/2
1150 s: 220804931/2
1160 s: 222724974/2
1170 s: 224645016/2
1180 s: 226565059/2
1190 s: 228485102/2
1200 s: 230405145/2
1210 s: 232325188/2
1220 s: 234245231/2
1230 s: 236165274/2
1240 s: 238085317/2
1250 s: 240005360/2
1260 s: 241925403/2
1270 s: 243845446/2
1280 s: 245765488/2
1290 s: 247685531/2
1300 s: 249605574/2
1310 s: 251525617/2
1320 s: 253445660/2
1330 s: 255365703/2
1340 s: 257285746/2
1350 s: 259205789/2
1360 s: 261125832/2
1370 s: 263045875/2
1380 s: 264965918/2
1390 s: 266885961/2
1400 s: 268806003/2
1410 s: 270726046/2
1420 s: 272646089/2
1430 s: 274566132/2
1440 s: 276486175/2
1450 s: 278406218/2
1460 s: 280326261/2
1470 s: 282246304/2
1480 s: 284166346/2
1490 s: 286086389/2
1500 s: 288006432/2
1510 s: 289926475/2
1520 s: 291846518/2
1530 s: 293766560/2
1540 s: 295686603/2
1550 s: 297606646/2
1560 s: 299526689/2
1570 s: 301446732/2
1580 s: 303366775/2
1590 s: 305286817/2
1600 s: 307206860/2
1610 s: 309126903/2
1620 s: 311046946/2
1630 s: 312966989/2
1640 s: 314887031/2
1650 s: 316807074/2
1660 s: 318727117/2
1670 s: 320647160/2
1680 s: 322567203/2
1690 s: 324487245/2
1700 s: 326407288/2
1710 s: 328327331/2
1720 s: 330247374/2
1730 s: 332167417/2
1740 s: 334087460/2
1750 s: 336007502/2
1760 s: 337927545/2
1770 s: 339847588/2
1780 s: 341767631/2
1790 s: 343687674/2
1800 s: 345607717/2
1810 s: 347527759/2
1820 s: 349447802/2
1830 s: 351367845/2
1840 s: 353287888/2
1850 s: 355207930/2
1860 s: 357127973/2
1870 s: 359048016/2
1880 s: 360968059/2
1890 s: 362888101/2
1900 s: 364808144/2
1910 s: 366728187/2
1920 s: 368648230/2
1930 s: 370568272/2
1940 s: 372488315/2
1950 s: 374408358/2
1960 s: 376328401/2
1970 s: 378248443/2
1980 s: 380168486/2
1990 s: 382088529/2
2000 s: 384008572/2
2010 s: 385928614/2
2020 s: 387848657/2
2030 s: 389768700/2
2040 s: 391688743/2
2050 s: 393608786/2
2060 s: 395528829/2
2070 s: 397448871/2
2080 s: 399368914/2
2090 s: 401288957/2
2100 s: 403209000/2
2110 s: 405129042/2
2120 s: 407049085/2
2130 s: 408969128/2
2140 s: 410889171/2
2150 s: 412809214/2
2160 s: 414729257/2
2170 s: 416649299/2
2180 s: 418569342/2
2190 s: 420489385/2
2200 s: 422409428/2
2210 s: 424329471/2
2220 s: 426249514/2
2230 s: 428169556/2
2240 s: 430089599/2
2250 s: 432009642/2
2260 s: 433929685/2
2270 s: 435849726/3
2280 s: 437769769/3
2290 s: 439689812/3
2300 s: 441609855/3
2310 s: 443529898/3
2320 s: 445449940/3
2330 s: 447369983/3
2340 s: 449290026/3
2350 s: 451210069/3
2360 s: 453130111/3
2370 s: 455050154/3
2380 s: 456970197/3
2390 s: 458890240/3
2400 s: 460810283/3
2410 s: 462730325/3
2420 s: 464650368/3
2430 s: 466570411/3
2440 s: 468490454/3
2450 s: 470410497/3
2460 s: 472330539/3
2470 s: 474250582/3
2480 s: 476170625/3
2490 s: 478090668/3
2500 s: 480010711/3
2510 s: 481930754/3
2520 s: 483850797/3
2530 s: 485770839/3
2540 s: 487690882/3
2550 s: 489610925/3
2560 s: 491530968/3
2570 s: 493451011/3
2580 s: 495371053/3
2590 s: 497291096/3
2600 s: 499211139/3
2610 s: 501131182/3
2620 s: 503051225/3
2630 s: 504971268/3
2640 s: 506891310/3
2650 s: 508811353/3
2660 s: 510731396/3
2670 s: 512651439/3
2680 s: 514571482/3
2690 s: 516491525/3
2700 s: 518411568/3
2710 s: 520331611/3
2720 s: 522251653/3
2730 s: 524171696/3
2740 s: 526091739/3
2750 s: 528011782/3
2760 s: 529931825/3
2770 s: 531851868/3
2780 s: 533771911/3
2790 s: 535691953/3
2800 s: 537611996/3
2810 s: 539532039/3
2820 s: 541452082/3
2830 s: 543372125/3
2840 s: 545292168/3
2850 s: 547212211/3
2860 s: 549132254/3
2870 s: 551052296/3
2880 s: 552972339/3
2890 s: 554892382/3
2900 s: 556812425/3
2910 s: 558732468/3
2920 s: 560652511/3
2930 s: 562572554/3
2940 s: 564492596/3
2950 s: 566412639/3
2960 s: 568332682/3
2970 s: 570252725/3
2980 s: 572172768/3
2990 s: 574092811/3
3000 s: 576012853/3
3010 s: 577932896/3
3020 s: 579852939/3
3030 s: 581772982/3
3040 s: 583693025/3
3050 s: 585613068/3
3060 s: 587533111/3
3070 s: 589453154/3
3080 s: 591373196/3
3090 s: 593293239/3
3100 s: 595213282/3
3110 s: 597133325/3
3120 s: 599053368/3
3130 s: 600973411/3
3140 s: 602893454/3
3150 s: 604813497/3
3160 s: 606733540/3
3170 s: 608653583/3
3180 s: 610573626/3
3190 s: 612493669/3
3200 s: 614413712/3
3210 s: 616333755/3
3220 s: 618253798/3
3230 s: 620173840/3
3240 s: 622093883/3
3250 s: 624013926/3
3260 s: 625933969/3
3270 s: 627854012/3
3280 s: 629774055/3
3290 s: 631694098/3
3300 s: 633614141/3
3310 s: 635534184/3
3320 s: 637454227/3
3330 s: 639374270/3
3340 s: 641294313/3
3350 s: 643214356/3
3360 s: 645134399/3
3370 s: 647054442/3
3380 s: 648974485/3
3390 s: 650894527/3
3400 s: 652814570/3
3410 s: 654734613/3
3420 s: 656654656/3
3430 s: 658574699/3
3440 s: 660494742/3
3450 s: 662414785/3
3460 s: 664334827/3
3470 s: 666254870/3
3480 s: 668174913/3
3490 s: 670094956/3
3500 s: 672014999/3
3510 s: 673935041/3
3520 s: 675855084/3
3530 s: 677775127/3
3540 s: 679695170/3
3550 s: 681615212/3
3560 s: 683535255/3
3570 s: 685455298/3
3580 s: 687375341/3
3590 s: 689295384/3
3600 s: 691215427/3
3610 s: 693135470/3
3620 s: 695055513/3
3630 s: 696975555/3
3640 s: 698895598/3
3650 s: 700815641/3
3660 s: 702735684/3
3670 s: 704655727/3
3680 s: 706575770/3
3690 s: 708495813/3
3700 s: 710415856/3
3710 s: 712335899/3
3720 s: 714255942/3
3730 s: 716175984/3
3740 s: 718096027/3
3750 s: 720016070/3
3760 s: 721936113/3
3770 s: 723856156/3
3780 s: 725776199/3
3790 s: 727696242/3
3800 s: 729616285/3
3810 s: 731536328/3
3820 s: 733456371/3
3830 s: 735376414/3
3840 s: 737296457/3
3850 s: 739216500/3
3860 s: 741136543/3
3870 s: 743056586/3
3880 s: 744976629/3
3890 s: 746896672/3
3900 s: 748816715/3
3910 s: 750736758/3
3920 s: 752656801/3
3930 s: 754576844/3
3940 s: 756496887/3
3950 s: 758416930/3
3960 s: 760336973/3
3970 s: 762257016/3
3980 s: 764177059/3
3990 s: 766097102/3
4000 s: 768017145/3
4010 s: 769937188/3
4020 s: 771857231/3
4030 s: 773777274/3
4040 s: 775697317/3
4050 s: 777617360/3
4060 s: 779537403/3
4070 s: 781457446/3
4080 s: 783377489/3
4090 s: 785297533/3
4100 s: 787217576/3
4110 s: 789137619/3
4120 s: 791057662/3
4130 s: 792977705/3
4140 s: 794897748/3
4150 s: 796817791/3
4160 s: 798737834/3
4170 s: 800657877/3
4180 s: 802577920/3
4190 s: 804497964/3
4200 s: 806418007/3
4210 s: 808338050/3
4220 s: 810258093/3
4230 s: 812178136/3
4240 s: 814098180/3
4250 s: 816018223/3
4260 s: 817938266/3
4270 s: 819858309/3
4280 s: 821778352/3
4290 s: 823698395/3
4300 s: 825618438/3
4310 s: 827538482/3
4320 s: 829458525/3
4330 s: 831378568/3
4340 s: 833298611/3
4350 s: 835218654/3
4360 s: 837138697/3
4370 s: 839058741/3
4380 s: 840978784/3
4390 s: 842898827/3
4400 s: 844818870/3
4410 s: 846738913/3
4420 s: 848658956/3
4430 s: 850579000/3
4440 s: 852499043/3
4450 s: 854419086/3
4460 s: 856339129/3
4470 s: 858259172/3
4480 s: 860179215/3
4490 s: 862099258/3
4500 s: 864019301/3
4510 s: 865939345/3
4520 s: 867859388/3
4530 s: 869779431/3
4540 s: 871699474/3
4550 s: 873619517/3
4560 s: 875539560/3
4570 s: 877459603/3
4580 s: 879379646/3
4590 s: 881299689/3
4600 s: 883219733/3
4610 s: 885139776/3
4620 s: 887059819/3
4630 s: 888979862/3
4640 s: 890899905/3
4650 s: 892819948/3
4660 s: 894739991/3
4670 s: 896660034/3
4680 s: 898580078/3
4690 s: 900500121/3
4700 s: 902420164/3
4710 s: 904340207/3
4720 s: 906260250/3
4730 s: 908180293/3
4740 s: 910100336/3
4750 s: 912020380/3
4760 s: 913940423/3
4770 s: 915860466/3
4780 s: 917780509/3
4790 s: 919700552/3
4800 s: 921620595/3
4810 s: 923540638/3
4820 s: 925460682/3
4830 s: 927380725/3
4840 s: 929300768/3
4850 s: 931220811/3
4860 s: 933140854/3
4870 s: 935060897/3
4880 s: 936980940/3
4890 s: 938900984/3
4900 s: 940821027/3
4910 s: 942741070/3
4920 s: 944661113/3
4930 s: 946581156/3
4940 s: 948501199/3
4950 s: 950421242/4
4960 s: 952341285/4
4970 s: 954261328/4
4980 s: 956181371/4
4990 s: 958101414/4
5000 s: 960021457/4
5010 s: 961941500/4
5020 s: 963861544/4
5030 s: 965781587/4
5040 s: 967701630/4
5050 s: 969621673/4
5060 s: 971541716/4
5070 s: 973461759/4
5080 s: 975381803/4
5090 s: 977301846/4
5100 s: 979221889/4
5110 s: 981141932/4
5120 s: 983061975/4
5130 s: 984982018/4
5140 s: 986902061/4
5150 s: 988822104/4
5160 s: 990742147/4
5170 s: 992662190/4
5180 s: 994582233/4
5190 s: 996502276/4
5200 s: 998422320/4
5210 s: 1000342363/4
5220 s: 1002262406/4
5230 s: 1004182449/4
5240 s: 1006102492/4
5250 s: 1008022533/4
5260 s: 1009942576/4
5270 s: 1011862619/4
5280 s: 1013782662/4
5290 s: 1015702705/4
5300 s: 1017622749/4
5310 s: 1019542792/4
5320 s: 1021462833/7
5330 s: 1023382876/7
5340 s: 1025302919/7
5350 s: 1027222962/7
5360 s: 1029143005/7
5370 s: 1031063049/7
5380 s: 1032983092/7
5390 s: 1034903135/7
5400 s: 1036823177/8
5410 s: 1038743220/8
5420 s: 1040663263/8
5430 s: 1042583307/8
5440 s: 1044503350/8
5450 s: 1046423393/8
5460 s: 1048343436/8
5470 s: 1050263479/8
5480 s: 1052183522/8
5490 s: 1054103565/8
5500 s: 1056023608/8
5510 s: 1057943651/8
5520 s: 1059863695/8
5530 s: 1061783738/8
5540 s: 1063703781/8
5550 s: 1065623824/8
5560 s: 1067543867/8
5570 s: 1069463910/8
5580 s: 1071383953/8
5590 s: 1073303996/8
5600 s: 1075224039/8
5610 s: 1077144082/8
5620 s: 1079064125/8
5630 s: 1080984168/8
5640 s: 1082904211/8
5650 s: 1084824254/8
5660 s: 1086744297/8
5670 s: 1088664340/8
Any ideas / conclusions?
wbr
malo
-
Verified
- Respected Member
- Posts: 347
- Joined: Wed Jan 27, 2016 5:21 pm
That number of errors suggest that there is too much jitter on the input pin to the xCORE for it to recover the signal at 192 kHz. That is unusual on coax.
It is possible that the SPDIF transmitter has added more jitter than is allowed, or maybe coax has added more jitter than expected.
It is worthwhile to put a scope on the RX signal and look at the signal with infinite persistence and post a picture. Do this both on the RX signal and on the TX signal on the other side (the producer). That will tell where the jitter has come from.
It is possible that the SPDIF transmitter has added more jitter than is allowed, or maybe coax has added more jitter than expected.
It is worthwhile to put a scope on the RX signal and look at the signal with infinite persistence and post a picture. Do this both on the RX signal and on the TX signal on the other side (the producer). That will tell where the jitter has come from.
-
- Active Member
- Posts: 33
- Joined: Fri Sep 16, 2016 9:03 pm
Hello Henk,
have had quite "bad" test run in the morning:
here is the picoscope 5444B screen in Persistence mode set to infinite, measured on C_RX test pad on xCORE-200 MC AUDIO eval board.

For me seems like well behaved spdif input...
wbr
malo
have had quite "bad" test run in the morning:
Code: Select all
10 s: 1920043/0
20 s: 3840086/0
30 s: 5760130/0
40 s: 7680174/0
50 s: 9600217/0
60 s: 11520261/0
70 s: 13440304/0
80 s: 15360348/0
90 s: 17280391/0
100 s: 19200435/0
110 s: 21120479/0
120 s: 23040522/0
130 s: 24960566/0
140 s: 26880609/0
150 s: 28800653/0
160 s: 30720697/0
170 s: 32640740/0
180 s: 34560784/0
190 s: 36480827/0
200 s: 38400871/0
210 s: 40320914/0
220 s: 42240958/0
230 s: 44161002/0
240 s: 46081045/0
250 s: 48001089/0
260 s: 49921132/0
270 s: 51841176/0
280 s: 53761219/0
290 s: 55681263/0
300 s: 57601307/0
310 s: 59521350/0
320 s: 61441394/0
330 s: 63361437/0
340 s: 65281481/0
350 s: 67201525/0
360 s: 69121568/0
370 s: 71041612/0
380 s: 72961655/0
390 s: 74881699/0
400 s: 76801742/0
410 s: 78721786/0
420 s: 80641829/0
430 s: 82561873/0
440 s: 84481916/0
450 s: 86401960/0
460 s: 88322003/0
470 s: 90242047/0
480 s: 92162090/0
490 s: 94082134/0
500 s: 96002178/0
510 s: 97922221/0
520 s: 99842265/0
530 s: 101762308/0
540 s: 103682352/0
550 s: 105602396/0
560 s: 107522439/0
570 s: 109442483/0
580 s: 111362526/0
590 s: 113282569/1
600 s: 115202612/1
610 s: 117122656/1
620 s: 119042699/1
630 s: 120962741/2
640 s: 122882785/2
650 s: 124802828/2
660 s: 126722872/2
670 s: 128642915/2
680 s: 130562959/2
690 s: 132483002/2
700 s: 134403046/2
710 s: 136323089/2
720 s: 138243133/2
730 s: 140163176/2
740 s: 142083220/2
750 s: 144003264/2
760 s: 145923307/2
770 s: 147843351/2
780 s: 149763394/2
790 s: 151683438/2
800 s: 153603481/2
810 s: 155523525/2
820 s: 157443568/2
830 s: 159363612/2
840 s: 161283655/2
850 s: 163203699/2
860 s: 165123742/2
870 s: 167043786/2
880 s: 168963829/2
890 s: 170883873/2
900 s: 172803916/2
910 s: 174723960/2
920 s: 176644003/2
930 s: 178564047/2
940 s: 180484090/2
950 s: 182404134/2
960 s: 184324177/2
970 s: 186244221/2
980 s: 188164264/2
990 s: 190084308/2
1000 s: 192004351/2
1010 s: 193924395/2
1020 s: 195844438/2
1030 s: 197764482/2
1040 s: 199684525/2
1050 s: 201604568/3
1060 s: 203524611/3
1070 s: 205444655/3
1080 s: 207364698/3
1090 s: 209284742/3
1100 s: 211204785/3
1110 s: 213124829/3
1120 s: 215044873/5
1130 s: 216964916/5
1140 s: 218884960/5
1150 s: 220805003/5
1160 s: 222725047/5
1170 s: 224645090/5
1180 s: 226565134/5
1190 s: 228485177/5
1200 s: 230405221/5
1210 s: 232325264/5
1220 s: 234245308/5
1230 s: 236165350/6
1240 s: 238085394/6
1250 s: 240005438/6
1260 s: 241925481/6
1270 s: 243845525/6
1280 s: 245765568/6
1290 s: 247685612/6
1300 s: 249605655/6
1310 s: 251525699/6
1320 s: 253445741/8
1330 s: 255365785/8
1340 s: 257285826/8
1350 s: 259205871/10
1360 s: 261125913/11
1370 s: 263045956/11
1380 s: 264966000/11
1390 s: 266886043/11
1400 s: 268806087/11
1410 s: 270726131/11
1420 s: 272646174/11
1430 s: 274566218/11
1440 s: 276486262/11
1450 s: 278406303/12
1460 s: 280326347/12
1470 s: 282246390/15
1480 s: 284166434/15
1490 s: 286086478/15
1500 s: 288006521/15
1510 s: 289926564/16
1520 s: 291846608/16
1530 s: 293766651/16
1540 s: 295686695/16
1550 s: 297606738/16
1560 s: 299526782/16
1570 s: 301446826/16
1580 s: 303366869/16
1590 s: 305286913/16
1600 s: 307206956/16
1610 s: 309127000/16
1620 s: 311047044/16
1630 s: 312967087/16
1640 s: 314887131/16
1650 s: 316807175/16
1660 s: 318727218/16
1670 s: 320647262/16
1680 s: 322567306/16
1690 s: 324487349/16
1700 s: 326407393/16
1710 s: 328327436/16
1720 s: 330247480/16
1730 s: 332167524/16
1740 s: 334087567/16
1750 s: 336007611/16
1760 s: 337927654/16
1770 s: 339847698/16
1780 s: 341767741/16
1790 s: 343687785/16
1800 s: 345607829/16
1810 s: 347527872/16
1820 s: 349447916/16
1830 s: 351367959/16
1840 s: 353288003/16
1850 s: 355208046/16
1860 s: 357128090/16
1870 s: 359048135/19
1880 s: 360968178/19
1890 s: 362888222/19
1900 s: 364808265/19
1910 s: 366728309/19

For me seems like well behaved spdif input...
wbr
malo
-
Verified
- Respected Member
- Posts: 347
- Joined: Wed Jan 27, 2016 5:21 pm
I am surprised that the falling edge has a much wider spread than the rising edge?
Also, the rising edge seems to be systematically ahead of the falling edge.
I thought that they would be more symmetrical on a coax connection?
Also, the rising edge seems to be systematically ahead of the falling edge.
I thought that they would be more symmetrical on a coax connection?
-
- Active Member
- Posts: 33
- Joined: Fri Sep 16, 2016 9:03 pm
Hello Henk,
do you have specs for spdif signal which xmos can reliably handle up to 192kHz?
Thinking to add spdif TX to my simple program to get rid of the Digirator.
Do you have xCORE-200 MC AUDIO eval board around that we can compare the results?
wbr
malo
do you have specs for spdif signal which xmos can reliably handle up to 192kHz?
Thinking to add spdif TX to my simple program to get rid of the Digirator.
Do you have xCORE-200 MC AUDIO eval board around that we can compare the results?
wbr
malo
-
- Active Member
- Posts: 33
- Joined: Fri Sep 16, 2016 9:03 pm
Hello,
added spdif TX into the test program. Even this is not the "real world" test since spdif TX and RX share the exactly the same clock:)
here is the code
and the results

is there somebody else with xCORE-200 MC AUDIO eval board to repeat the test? that we have more results to compare.
wbr
malo
added spdif TX into the test program. Even this is not the "real world" test since spdif TX and RX share the exactly the same clock:)
here is the code
Code: Select all
/*
* spdif-tx-rx-test.xc
*
* Created on: 13 Feb 2017
* Author: malo
*/
#include <xs1.h>
#include <platform.h>
#include <stdio.h>
#include "spdif.h"
#include "gpio.h"
#define MAIN_TILE 0
#define SPDIF_TILE 1
in port port_spdif_rx = on tile [SPDIF_TILE]: XS1_PORT_1P;
clock clk_spdif_rx = on tile [SPDIF_TILE]: XS1_CLKBLK_1;
out port port_spdif_tx = on tile [MAIN_TILE]: XS1_PORT_1D;
in port port_mclk_in = on tile [MAIN_TILE]: XS1_PORT_1F;
clock clk_audio = on tile [MAIN_TILE]: XS1_CLKBLK_1;
port port_audio_config = on tile [MAIN_TILE]: XS1_PORT_8C;
char pin_map_audio_cfg [2] = {5, 7};
#define DEFAULT_FREQ_HZ_SPDIF 192000
#define DEBUG_INTERVAL_S 10
#define S_TO_TIMER_TICKS(value_ms_) ((value_ms_) * XS1_TIMER_HZ)
typedef interface debug_if
{
void get_counts (unsigned int& count_, unsigned int& bad_count_);
} debug_if;
void debug_task (client interface debug_if i_debug_)
{
timer t_debug;
unsigned int next_debug = 0;
t_debug :> next_debug;
next_debug += S_TO_TIMER_TICKS (DEBUG_INTERVAL_S);
unsigned int count = 0;
unsigned int bad_count = 0;
unsigned int interval_count = 0;
while (1)
{
select
{
case t_debug when timerafter (next_debug) :> void:
next_debug += S_TO_TIMER_TICKS (DEBUG_INTERVAL_S);
i_debug_.get_counts (count, bad_count);
interval_count++;
printf ("%u s: %u/%d\n", interval_count * DEBUG_INTERVAL_S, count, bad_count);
break;
}
}
}
void spdif_rx_handler_task (streaming chanend c_spdif_rx_, server interface debug_if i_debug_)
{
unsigned int index = 0;
int32_t sample = 0;
unsigned int count = 0;
// 0: have received right - expecting left
// 1: have received left - expecting right
unsigned int expecting_channel = 0;
unsigned int bad_count = 0;
while (1)
{
select
{
case spdif_receive_sample(c_spdif_rx_, sample, index):
// Check expectations
if (expecting_channel != index)
{
bad_count++;
}
else
{
expecting_channel ^= 1;
}
// Count stereo samples.
if (index)
{
count++;
}
break;
case i_debug_.get_counts (unsigned int& count_, unsigned int& bad_count_):
// Return to the debug task.
count_ = count;
bad_count_ = bad_count;
break;
}
}
}
void spdif_tx_handler_task (chanend c_spdif_tx_)
{
int32_t sample = 0;
spdif_tx_reconfigure_sample_rate (c_spdif_tx_, 192000, 24576000);
while (1)
{
sample++;
spdif_tx_output (c_spdif_tx_, sample, sample + 1);
}
}
int main()
{
interface debug_if i_debug;
streaming chan c_spdif_rx;
chan c_spdif_tx;
interface output_gpio_if i_gpio [2];
par
{
on tile [MAIN_TILE]: output_gpio (i_gpio, 2, port_audio_config, pin_map_audio_cfg);
on tile [MAIN_TILE]: debug_task (i_debug);
on tile [MAIN_TILE]:
{
// PLL_SELECT, X0D31
i_gpio [0].output (0);
// MCLK_FSEL, X0D33
i_gpio [1].output (1);
// SPDIF TX, PLL_SELECT LO, MCLK_FSEL HI -> should have 24576000 Hz on port_mclk_in
configure_clock_src (clk_audio, port_mclk_in);
start_clock (clk_audio);
spdif_tx (c_spdif_tx, port_spdif_tx, clk_audio);
}
on tile [MAIN_TILE]: spdif_tx_handler_task (c_spdif_tx);
on tile [SPDIF_TILE]: spdif_rx (c_spdif_rx, port_spdif_rx, clk_spdif_rx, DEFAULT_FREQ_HZ_SPDIF);
on tile [SPDIF_TILE]: spdif_rx_handler_task (c_spdif_rx, i_debug);
}
return 0;
}
Scope measured on C_RX pin with infinite persistence....
17930 s: 3442559996/3
17940 s: 3444479996/3
17950 s: 3446399996/3
17960 s: 3448319996/3
17970 s: 3450239996/3
....
60720 s: 3068305401/4
60730 s: 3070225401/4
60740 s: 3072145401/4

is there somebody else with xCORE-200 MC AUDIO eval board to repeat the test? that we have more results to compare.
wbr
malo
-
- XCore Addict
- Posts: 144
- Joined: Wed Jun 29, 2016 8:59 am
Hi folks,
it's a old thread, but I think it's worth to comment it, anyway. I confirm, that the code of malo produces errors. On my board happens errors in less of a minute. I have verified the output with an external hardware and I have seen, that the output stutters! When I have disabled the "debug_task", it ran stutter free. In the next step, I have modified the output for compatibility reason with my external hardware. Now, I could verify, that the output is bit perfect. The next step was, to modify the "spdif_rx_handler_task". At first, I have used the coax in- and output. It rans perfect over night. When I switch to optical in- and output, it produced errors in less of a minute. Then, I tested opt -> coax and coax -> opt with an external converter. It also produces errors.
Conclusion so far: If I use an optical path in anyway, it fails. I guess, it is the jitter, the optical transceiver and/or cable produce.
Here my code:
it's a old thread, but I think it's worth to comment it, anyway. I confirm, that the code of malo produces errors. On my board happens errors in less of a minute. I have verified the output with an external hardware and I have seen, that the output stutters! When I have disabled the "debug_task", it ran stutter free. In the next step, I have modified the output for compatibility reason with my external hardware. Now, I could verify, that the output is bit perfect. The next step was, to modify the "spdif_rx_handler_task". At first, I have used the coax in- and output. It rans perfect over night. When I switch to optical in- and output, it produced errors in less of a minute. Then, I tested opt -> coax and coax -> opt with an external converter. It also produces errors.
Conclusion so far: If I use an optical path in anyway, it fails. I guess, it is the jitter, the optical transceiver and/or cable produce.
Here my code:
Code: Select all
/*
* spdif-tx-rx-test.xc
*
* Created on: 13 Feb 2017
* Author: malo
*/
#include <xs1.h>
#include <platform.h>
#include <stdio.h>
#include "spdif.h"
#include "gpio.h"
#define MAIN_TILE 0
#define SPDIF_TILE 1
in port port_spdif_rx = on tile [SPDIF_TILE]: XS1_PORT_1P;
clock clk_spdif_rx = on tile [SPDIF_TILE]: XS1_CLKBLK_1;
out port port_spdif_tx = on tile [MAIN_TILE]: XS1_PORT_1E;
in port port_mclk_in = on tile [MAIN_TILE]: XS1_PORT_1F;
clock clk_audio = on tile [MAIN_TILE]: XS1_CLKBLK_1;
port port_audio_config = on tile [MAIN_TILE]: XS1_PORT_8C;
char pin_map_audio_cfg [2] = {5, 7};
port port_LED = on tile [SPDIF_TILE]: XS1_PORT_8B;
#define DEFAULT_FREQ_HZ_SPDIF 192000
#define DEBUG_INTERVAL_S 10
#define S_TO_TIMER_TICKS(value_ms_) ((value_ms_) * XS1_TIMER_HZ)
typedef interface debug_if
{
void get_counts (unsigned int& count_, unsigned int& bad_count_);
} debug_if;
void debug_task (client interface debug_if i_debug_)
{
timer t_debug;
unsigned int next_debug = 0;
t_debug :> next_debug;
next_debug += S_TO_TIMER_TICKS (DEBUG_INTERVAL_S);
unsigned int count = 0;
unsigned int bad_count = 0;
unsigned int interval_count = 0;
while (1)
{
select
{
case t_debug when timerafter (next_debug) :> void:
next_debug += S_TO_TIMER_TICKS (DEBUG_INTERVAL_S);
i_debug_.get_counts (count, bad_count);
interval_count++;
printf ("%u s: %u/%d\n", interval_count * DEBUG_INTERVAL_S, count, bad_count);
break;
}
}
}
void spdif_rx_handler_task (streaming chanend c_spdif_rx_)
{
unsigned int index = 0;
int32_t sample = 0;
unsigned int expect;
unsigned int bad_count = 0;
while (1)
{
do {
spdif_receive_sample(c_spdif_rx_, sample, index);
sample = (sample >> 16) & 0xffff;
} while (sample != 0);
expect = 1;
while (1)
{
spdif_receive_sample(c_spdif_rx_, sample, index);
sample = (sample >> 16) & 0xffff;
if (sample != expect) {
printf("error %u != %u\n", sample, expect);
break;
}
expect++;
if (expect >= 65000) {
expect = 0;
}
if (expect >= 32000) {
port_LED <: 0x4;
} else {
port_LED <: 0x0;
}
}
}
}
void spdif_tx_handler_task (chanend c_spdif_tx_)
{
int32_t sample = 0;
spdif_tx_reconfigure_sample_rate (c_spdif_tx_, 192000, 24576000);
while (1)
{
spdif_tx_output (c_spdif_tx_, (sample << 16), (sample + 1) << 16);
sample+=2;
if (sample >= 65000) {
sample = 0;
}
}
}
int main()
{
interface debug_if i_debug;
streaming chan c_spdif_rx;
chan c_spdif_tx;
interface output_gpio_if i_gpio [2];
par
{
on tile [MAIN_TILE]: output_gpio (i_gpio, 2, port_audio_config, pin_map_audio_cfg);
on tile [MAIN_TILE]:
{
// PLL_SELECT, X0D31
i_gpio [0].output (0);
// MCLK_FSEL, X0D33
i_gpio [1].output (1);
// SPDIF TX, PLL_SELECT LO, MCLK_FSEL HI -> should have 24576000 Hz on port_mclk_in
configure_clock_src (clk_audio, port_mclk_in);
start_clock (clk_audio);
spdif_tx (c_spdif_tx, port_spdif_tx, clk_audio);
}
on tile [MAIN_TILE]: spdif_tx_handler_task (c_spdif_tx);
on tile [SPDIF_TILE]: spdif_rx (c_spdif_rx, port_spdif_rx, clk_spdif_rx, DEFAULT_FREQ_HZ_SPDIF);
// on tile [MAIN_TILE]: debug_task (i_debug);
on tile [SPDIF_TILE]: spdif_rx_handler_task (c_spdif_rx);
}
return 0;
}