oops, the buffer size in the hardware is 1k-word (16-bit) each, not 1k byte as in my previous post.

Here is the matlab script I used which is a bit of messy, but got the answer for me.

% function pipeRWtest()

clear all;

%if ~libisloaded(‘okFrontPanel’)

% loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);

%end

addpath(‘C:\OK_tutorial\API\Matlab’);

xptr = gb_init();

gb_configFPGA(xptr, ‘C:\Program Files\Opal Kelly\FrontPanel\Samples\PipeTest\PipeTest-xem3010-1500.bit’);

%writeout = zeros(2048, 1);

%for i=1:2048

% writeout(i) = rand() & 255;

%end

epaddr = hex2dec(‘81’);

blksize = 1024;

% psize = 2048;

bsize = 4*2048;

psize = bsize;

n = 5;

writeout = ceil(n.*rand(2048,1));

epvalue = writeout’;

err = uint8(zeros(1,bsize));

gb_activatetriggerin(xptr, hex2dec(‘40’), 0);

gb_writetoblockpipein(xptr, epaddr, blksize, epvalue, psize);

pause(1);

gb_activatetriggerin(xptr, hex2dec(‘40’), 0);

readin = gb_readfromblockpipeout(xptr, hex2dec(‘a1’), blksize, bsize, psize);

fprintf(’\n’);

% datacop = [writeout readin]

nerr = 0;

for i = 0:psize-1

err(i+1) = writeout(mod((i),2048)+1)- readin(i+1);

fprintf(‘row ‘,num2str(i), ‘: ‘, num2str(writeout(mod((i),2048)+1)),’ ‘]);

fprintf([num2str(readin(i+1)),’ \n’]);

if err(i+1)~= 0

nerr = nerr + 1;

end

end

fprintf(’\n’);

display([num2str(nerr),’ errors found in BTPipe in/out data transfer.’]);

% test the configuration. It is OK during development.

fprintf(‘Test 1: SetWireInValue\n’);

fprintf(’\n’);

fprintf(‘Look at the LEDs on XEM3010 … \n’);

fprintf(‘LED bit turn on ‘]);

for i = 0:7

decimal_bitval=2^i; % the decimal(int32) value for each of the eight WireIns

% calllib(‘okFrontPanel’, ‘okUsbFrontPanel_SetWireInValue’,xptr, 0,decimal_bitval,65535); %decimal ‘0’ for ep00, decimal ‘65535’ for “update all bits”.

gb_setwireinvalue(xptr, 0, decimal_bitval,65535)

% calllib(‘okFrontPanel’, ‘okUsbFrontPanel_UpdateWireIns’,xptr);

gb_updatewireins(xptr)

fprintf(’, ‘, num2str(i)]);

pause(0.1);

end

fprintf(’\n’);

## gb_end(xptr);

function xptr = gb_init()

%if ~libisloaded(‘okFrontPanel’)

% loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);

%end

if ~libisloaded(‘okFrontPanel’)

loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);

end

xptr = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Construct’);