Serial port 8bit data read

20 views (last 30 days)
Ege Efekan Ceylaner
Ege Efekan Ceylaner on 23 Aug 2019
Hi. I am trying to read the 8 bit data that I send from basys 3 from the usb port of my pc. Looking at the simulation results of vivado the signal that I give to usb port is correct. But when I try to read it from matlab the numbers become meaningless. I also use anouther program to read the data from usb port. The results of that program is nearly same with the results of matlab but there are some differences. Do anyone has any suggestions?Adsız.jpgThis is the vivado simulation. The value that I am trying to send is buff_in. clk_boud is boud rate which is 115200. And txserialout is the output port.
THE MATLAB CODE
obj1 = instrfind('Type', 'serial', 'Port', 'COM13');
% Create the serial port object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = serial('COM13','BaudRate',115200,'StopBits',1,'ByteOrder','littleEndian');
else
fclose(obj1);
obj1 = obj1(1)
end
set(obj1,'InputBufferSize', 21);
fopen(obj1);
obj1.Timeout = 5;
data1 = fread(obj1)
% Disconnect from instrument object, obj1.
fclose(obj1);
% Clean up all objects.
delete(obj1);
RESULT OF THE MATLAB CODE
>> serialtx
data1 = 180 6 49 167 182 6 51 14 176 102 53 215 176 70 180 6 49 167 182 6 51

Answers (0)

Categories

Find more on Instrument Connection and Communication in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!