How to transmit 96 bits using RS232?

조회 수: 2 (최근 30일)
Ana
Ana 2015년 3월 31일
답변: Ana 2015년 4월 1일
I try to divide the 96 bits in groups of 8 bits and sent them using RS232, after the 96 bits have been sent to a FPGA and it done some operations, I need transmit from the fpga to a computer, a group of 32 bits. Somebody can help me. I try to use the following code in a loop
>>hpo=serial ('COM4','BaudRate',115200,'DataBits',8, 'Parity','none','StopBits',1,'ReadAsyncMode','continuous');
>>DataC=fread(hpo,1);
But I got the following error
Warning: Unsuccessful read: The specified amount of data was not returned within
Thanks

답변 (2개)

Ganesh Gaonkar
Ganesh Gaonkar 2015년 3월 31일
Some hardware requires hardware-handshaking for communication. This is done by setting the "flowcontrol" to hardware like below:
set(hpo,'FlowControl','hardware');
You can try adding this command after your first command and see if that can solve the issue.
  댓글 수: 1
Ana
Ana 2015년 4월 1일
Thanks Ganesh Gaonkar, I add the command but I get an error.

댓글을 달려면 로그인하십시오.


Ana
Ana 2015년 4월 1일
I need send 3 package of 32 bits to a FPGA and after few operations doing by the FPGA, I need transfer a package of 32 bits from the FPGA to my computer using RS232, now I have stored my data in a .txt and these data are in binary form, and I use the following command to separate the 3 first data of my .txt file
clear all;
close all;
clc;
Data1=['000000' data(j,:)];
After send the data, I need to receive in my computer 32 bits, and in the code to program the FPGA I resolve this problem sending 4 package of 8 bits, and in matlab I using the following command:
hpo=serial ('COM4','BaudRate',115200,'DataBits',8, 'Parity','none','StopBits',1,'ReadAsyncMode','continuous ');
DataC=fread(hpo,3);
for i=1:4
DataC=fread(hpo);
arr(i)=DataC
end
fclose(hpo);
delete(hpo);
clear hpo;
But when I communicate the PFGA and the computer I get the following error:
Unsuccessful read: The specified amount of data was not returned within the
Timeout period.
Please Can you Help me?

Community Treasure Hunt

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

Start Hunting!

Translated by