[英]matlab serial communication
SerPIC = serial('COM10');
set(SerPIC,'BaudRate', 115200, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'software');
fopen(SerPIC); %--open the serial port to the PIC
fprintf(SerPIC, '%s', 'b');
fid = fopen('D:\pipt1.abs');
tline = fgets(fid);
while ischar(tline)
fprintf(SerPIC, '%s',tline )
tline = fgets(fid);
end
fclose(fid);
fclose(SerPIC) %--close the serial port when done
delete(SerPIC)
clear SerPIC
I am using Tms570ls20216 usb. 我使用的是Tms570ls20216 usb。 In the board i have bootloader in it. 在板上我有bootloader。 When i send ab to the board it'll flash the board after taking the abs file. 当我向板发送ab时,它会在获取abs文件后闪烁板。 Its working properly in hyperterminal but while running in matlab its not flashing. 它在超级终端中正常工作,但在matlab中运行时不会闪烁。 I am new to matlab. 我是matlab的新手。 Is there anything wrong in my code. 我的代码有什么问题。 I dont know whether this is a proper place to ask the question. 我不知道这是否是一个提出问题的适当场所。 Sorry if it is not. 对不起,如果不是。
Do you need to send a line-feed at the end of your b
command? 您是否需要在b
命令的末尾发送换行符? Like this: 像这样:
fprintf(SerPIC, 'b\n'); %add line feed, no need for %s from the original code
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.