完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一个ISR的问题,我真的需要正常工作,但可能需要一个小背景的项目。我正在编写一个代码,与无人驾驶飞机上的飞行控制器对话,我正在测试一个超声波传感器,并向下指向以帮助保持它的高度。我目前的问题是飞行控制器使用SBUS,一个在100K波特的倒置UART信号,这一切都很好,但是每个帧都是3ms长,它们需要在帧之间有相当接近6ms的延迟。我们编写的代码使用CyTrice(6000)运行正常,但因为它没有使用ISR,所以添加的任何代码都长了6Ms。不幸的是,如果它离那太远,飞行控制器会迷惑,并且摇晃晃晃(有可能意外地完全油门),我现在手上有一串缝线,当我的另一只手愈合时,我可能再也不会有一对指纹了。因此,我必须不断地使通信建立在同一时间运行。
我所面临的问题是,我把代码通过UART/SBUS发送到ISR中,但是它不像以前那样运行。插入断点,我可以看到它每次击中它,但它没有发送正确的值。我想知道是否允许我改变主函数中的变量,并让它们在ISR中使用?我还试图让ISR跳转到我们最初用于发送数据的函数,并将变量声明在函数之外,以便两者都可以使用它,但是这也不起作用。我一直在为此战斗了几天,还没有想出一个解决方案,其他的项目成员都在焦急地进行测试,但是不能,因为目前不安全。 我附加了存档文件,它具有ISR以及在主.c文件中发送UART/SUS的功能,因为我不确定哪种方法能更好地工作。 C.A. 2.4兆字节 以上来自于百度翻译 以下为原文 I am having trouble with an ISR that I really need to work properly, but a little background on the project might be needed. I am writing code to talk to a flight controller on a drone, and I am testing an ultrasonic sensor on it as well pointed down to help hold its altitude. The problem I have currently is that the flight controller uses SBUS, an inverted UART signal at 100k baud, which is all fine and well, but each frame is 3ms long and they need to have fairly closely to 6ms delay between frames. We had code written that worked ok using CyDelay(6000), but because it wasn't using an ISR, any code added made that 6ms longer. Unfortunately if it gets too far from that, the flight controller gets confused and tosses a wobbly (with the possibility of it going full throttle unexpectedly), and I now have a bunch of stitches in one hand, and when my other hand heals I will likely not have a couple fingerprints anymore. So its imperative that I get the communication set up to run at the same time constantly. The problem I am having is I moved the code for sending what is needed over the UART/SBUS into an ISR, however it does not function as it did before. Inserting breakpoints I can see it hitting it each time, but it is not sending correct values. I am wondering if I am allowed to change variables in the main function and also have them used in the ISR? I have also tried having the ISR just jump to the function we had originally for sending the data, and having the variables declared outside of the functions so both could use it, however that does not work either. I have been fighting with this for a few days and haven't come up with a solution, and other project members are getting antsy to test but can't because its unsafe to do so currently. I attached the archive file, it has the ISR as well as the function for sending over UART/SBUS in the main.c file as I am not sure which method will work better. |
|
相关推荐
1个回答
|
|
在主函数和ISR中使用全局变量作为易失性声明
以上来自于百度翻译 以下为原文 Declare the global variables as volatile which are being used in in the main function and in the ISR |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2071 浏览 1 评论
1827 浏览 1 评论
3639 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1761 浏览 6 评论
1513 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
511浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
361浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
858浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 10:02 , Processed in 1.299529 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号