【问题标题】:matlab serial communicationmatlab串口通讯
【发布时间】:2014-11-24 04:26:19
【问题描述】:
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

我正在使用 Tms570ls20216 USB。在板上我有引导加载程序。当我将 b 发送到板时,它会在获取 abs 文件后闪烁板。它在超级终端中正常工作,但在 matlab 中运行时不闪烁。我是matlab的新手。我的代码有什么问题吗?我不知道这是否是一个合适的地方问这个问题。如果不是很抱歉。

【问题讨论】:

    标签: matlab serial-port


    【解决方案1】:

    您需要在b 命令的末尾发送换行符吗?像这样:

    fprintf(SerPIC, 'b\n');  %add line feed, no need for %s from the original code
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-01
      • 2013-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多