create unsigned char array to get the spi data from ADC , which is connected through usb to SPI converter to matlab
Afficher commentaires plus anciens
i am using a 24 bit ADC with SPI output, i need to interface it to MATLAB so im using MCP2210( usb to SPI converter working)
my board working and i am able to configure it.
Problem.... To receive SPI data from pc(matlab)<-converter<-ADC, i need to use TxferSpiData function in .dll of mcp2210.
below i have shown Coding in C++ to tx and Rx two 8-bit data.
how can i create this array in matlab to receive 27 bytes of data in 27 array(8 channel ADC of 24 bit resolution) , i have used cell to receive it not working.
i have added my code.m and Guide to use MCP2210 TxferSpiData function( page no 16) *
out = gcnew array<unsigned char>(2) {0x00,0x00};
in = gcnew array<unsigned char>(2) {0x00, 0x00};
intret = UsbSpi->Functions->TxferSpiData(out, in);
how to create a unsigned char array (similar to c++ code above in matlab) to receive this data into matlab with TxferSpiData function in dll. Guide page no:16
Thanks & Regards
Ikram khan.S.I
Réponses (1)
Walter Roberson
le 29 Mar 2013
0 votes
Receive unsigned char as uint8(), and then if necessary char() it to convert to characters.
2 commentaires
ikram khan
le 30 Mar 2013
Modifié(e) : ikram khan
le 30 Mar 2013
Walter Roberson
le 30 Mar 2013
buffer = uint8(28,1);
success = TxferSpiData(buffer);
if success == 0
spi_chars = char(buffer(1:27));
else
fprintf('TxferSpiData returned error: %d\n', success);
end
Catégories
En savoir plus sur Simulink dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!