2012-04-03 50 views
3
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。在董事会我有bootloader在里面。当我发送一个b到板子后,它会在拍摄abs文件后闪动板子。它在超级终端中正常工作,但在matlab中运行时不闪烁。我是matlab新手。我的代码有什么问题吗?我不知道这是否适合提问。对不起,如果不是。matlab串行通讯

回答

0

您是否需要在b命令的结尾处发送换行符?像这样:

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