Matlab SPI write with ESS
Posted: Mon Feb 20, 2012 9:23 pm
I'm having trouble using the .NET Matlab interface to write to the SPI interface using the extended mode (ESS). I verified the standard SPI write was working using the example code, then modified it to try ESS (see below). I get the error "No method 'SPI_Transfer_Ess' with matching signature found for class 'Xdimax.Sub20'
------------------------------------------------------------------------------------------------------
disp 'SUB-20 SPI sample. Configures SPI and exchanges data with SPI slave(SS=2)'
TransferSize = 3;
NET.addAssembly('C:\Program Files\SUB-20\bin\sub20dnc.dll');
sub20 = Xdimax.Sub20();
% Open first available SUB-20 device
if ~ sub20.Open(0)
break;
end
% Set SPI configuration
if ~ sub20.SPI_SetConfig(sub20.SpiEnable + sub20.SpiCpolRise + ...
sub20.SpiSmplSetup + sub20.SpiMsbFirst + sub20.SpiClk_4MHz )
break;
end
% Create .NET data array
Data = NET.createArray('System.Byte', TransferSize);
% Fill up the array with data bytes to be sent
Data.Set(0, hex2dec('2a'));
Data.Set(1, hex2dec('2b'));
Data.Set(2, hex2dec('2c'));
% Exchange data with SPI slave(SS=2). SS signal stays high
%if ~ sub20.SPI_Transfer(Data, 2, sub20.SpiSS_H)
% break;
%end
if ~ sub20.SPI_Transfer_Ess(Data, 2, '2L^-vL^-v')
break;
end
% Close SUB-20 device
sub20.Close()
------------------------------------------------------------------------------------------------------
disp 'SUB-20 SPI sample. Configures SPI and exchanges data with SPI slave(SS=2)'
TransferSize = 3;
NET.addAssembly('C:\Program Files\SUB-20\bin\sub20dnc.dll');
sub20 = Xdimax.Sub20();
% Open first available SUB-20 device
if ~ sub20.Open(0)
break;
end
% Set SPI configuration
if ~ sub20.SPI_SetConfig(sub20.SpiEnable + sub20.SpiCpolRise + ...
sub20.SpiSmplSetup + sub20.SpiMsbFirst + sub20.SpiClk_4MHz )
break;
end
% Create .NET data array
Data = NET.createArray('System.Byte', TransferSize);
% Fill up the array with data bytes to be sent
Data.Set(0, hex2dec('2a'));
Data.Set(1, hex2dec('2b'));
Data.Set(2, hex2dec('2c'));
% Exchange data with SPI slave(SS=2). SS signal stays high
%if ~ sub20.SPI_Transfer(Data, 2, sub20.SpiSS_H)
% break;
%end
if ~ sub20.SPI_Transfer_Ess(Data, 2, '2L^-vL^-v')
break;
end
% Close SUB-20 device
sub20.Close()