serial communication problems with 8051

2 次查看(过去 30 天)
hi,all i have a problem in serial communication my code below:
Matrix1=[10.0334 90.363 220.6947 234.4577 206.6082 142.7936 115.5005 99.0738 57.7875 31.6816 15.8035 ];
s=serial('com3','baudrate',9600);
set(s,'flowcontrol','none');
set(s,'parity','none');
set(s,'databit',8);
set(s,'stopbit',1);
fopen(s)
for i=1:length(Matrix1)
A=Matrix1(i) ;
fwrite(s,A,'int8')
pause(2)
end
the problem with this code only the five value of matrix1 will be send via serial port to 8051 ,so when i display the received values only the first five values of matrix1 displayed.the other values of the matrix not send whats the problem,please help, suggest, idea
thank in advance

采纳的回答

Walter Roberson
Walter Roberson 2013-4-3
All the values are going to be sent, but what is going to be sent is
10 90 127 127 127 127 116 99 58 32 16
When you ask to send as int8, the values are numerically converted to int8 first, discarding any fractions, and saturating at -128 or +127.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by