各位前辈,我在做matlab与单片机的串口通信实验,要求用plot函数时时显示串口数据,中断函数有问题。。 5
我写的基本设置:.串口初始化:s.BytesAvailableFcnMode='byte's.inputBufferSize=5000s.BytesAvailableFc...
我写的基本设置:
.串口初始化:
s.BytesAvailableFcnMode='byte'
s.inputBufferSize=5000
s.BytesAvailableFcnCount=10
s.BaudRate=9600
s.BytesAvailableFcn=@instrcallback
存放在serial.m的文件中;
在命令执行栏中,可以看到:
BytesAvailable event occurred at 22:58:25 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:25 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:25 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:26 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:27 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:28 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:28 for the object: Serial-COM3.
~~~~
但问题是不会修改instrcallback回调函数,想在回调函数中写入plot函数,就可以直接显示数据了;在网上查找资料,知道instrcallback函数在toolbox\matlab\iofun\@instrument中,但我的目录没有这个文件夹,所以现在不知道从哪下手。。。(PS:下载过别人用matlab写的串口通信助手,可以运行) 展开
.串口初始化:
s.BytesAvailableFcnMode='byte'
s.inputBufferSize=5000
s.BytesAvailableFcnCount=10
s.BaudRate=9600
s.BytesAvailableFcn=@instrcallback
存放在serial.m的文件中;
在命令执行栏中,可以看到:
BytesAvailable event occurred at 22:58:25 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:25 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:25 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:26 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:27 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:28 for the object: Serial-COM3.
BytesAvailable event occurred at 22:58:28 for the object: Serial-COM3.
~~~~
但问题是不会修改instrcallback回调函数,想在回调函数中写入plot函数,就可以直接显示数据了;在网上查找资料,知道instrcallback函数在toolbox\matlab\iofun\@instrument中,但我的目录没有这个文件夹,所以现在不知道从哪下手。。。(PS:下载过别人用matlab写的串口通信助手,可以运行) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询