Search code examples
matlabserial-portembeddeduart

Data write over UART from Matlab to Embedded device


enter image description hereI am trying to write data from a file which contains hex values via UART using MATLAB to my embedded device. The code runs but the output which I am getting is not in hex.

The image shows the issue. The top of the image in numbers is the output I am getting; the below hex data is my input file and this should be my output also.

obj1 = instrfind('Type', 'serial', 'Port', 'COM9', 'Tag', '');
fopen(obj1);
A = fopen('C:\Users\admin\Workspace\STELLARIS-LM4F120_00_210214_104000_0001_temp_025.bin');
while ~feof(A)
    curr = fscanf(A,'%c',1);
% Communicating with instrument object, obj1.
binblockwrite(obj1, 'curr');
end  
% Disconnect from instrument object, obj1.
fclose(obj1);

Please let me know whats the issue here.

Thanks! Kashif


Solution

  • fopen(obj1);
    A = fopen('C:\Users\admin\Workspace\STELLARIS-LM4F120_00_210214_104000_0001_temp_025.bin');
    txdata = fread(A,inf,'uint8','ieee-be');
    for i = 1:32768
    fwrite(obj1,txdata(i),'uint8');
    end
    fclose(obj1);