完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在尝试将Fieltos实现到一个DSPIC33 EV微控制器,但是程序在任务切换时总是失败。这是一个问题,一个月以来,我一直在研究这个问题。在深入研究FRIERTOS源和DSPIC芯片的手册之后,我注意到的是,这些芯片的中断只把PC和SRL寄存器推到堆栈上,而另一个重要的寄存器则永远不会出现。EN被推到堆栈(W0~W15,CONCONE,DODEH,DODEL,DOSTARTH,DOSTARTL,DCOUNT,ACCBU,ACCBH,ACCU,ACCAH,ACCAH,ACCAL,TBLAPAG,RCOUNTetc)。我怀疑这些寄存器是否在中断路由中被更新,当中断返回时没有恢复它,这可能破坏工作。在中断中启动用户定义代码之前,是否需要将所有寄存器推到堆栈中?关于如何做到这一点还有什么建议吗?
以上来自于百度翻译 以下为原文 I'm trying to implementing the FreeRTOS into a dsPIC33EV Microcontroller, but the program always failed at task switching. and it turned out to be an AddressError, I have been stuck at this problem over a month. After dig into the FreeRTOS source and the dsPIC chip's manual, one thing I have noticed is the Interrupt of these chip only pushed the PC&SRL register to the stack, the other important register have never been pushed to the stack (W0~W15, CORCON, DOENDH, DOENDL, DOSTARTH, DOSTARTL, DCOUNT, ACCBU, ACCBH, ACCBL, ACCAU, ACCAH, ACCAL, TBLPAG, RCOUNT etc.) I doubt if those registers have been updated in the interrupt routing and didn't restore it back when the interrupt returned, that might destroy the working context. Is it a necessary to push all those registers into stack before start the user defined code in interrupt? Is there any exmple on how to do this? |
|
相关推荐
6个回答
|
|
IIRC的任务切换中断的启动调用汇编程序,保存所有这些寄存器有一个或两个例外(也许是doxxx)???)我知道汇编代码有一个条件来区分PIC24和dSPIC33 MCU,这样它就可以添加一些DSIC33特定寄存器(当然在以后恢复它们)。有一个限制,我遇到了在DSPIC33 EP设备上运行FRIERTOS,因为它不能再运行。一些注册是在非常特殊的情况下使用的,但我从来没有发现在我的申请中是个问题。我现在在工作(嘿老板:我的午餐休息好了!)我的代码在家里。如果有兴趣的话,我会在周末看看我能不能找到它。苏珊
以上来自于百度翻译 以下为原文 IIRC the start of the task switching interrupt calls an assembler routine that saves all of those registers with one or two exceptions (perhaps the DOxxx ones???). I know the assembler code had a conditional in it to differentiate the PIC24 from the dsPIC33 MCUs so that it would add in some of the dsPIC33 specific registers (and restore them later of course). There is a limitation I came across running FreeRTOS on a dsPIC33EP device in that it could not restore some register that was used in very specific situations, but I never found that was a problem in my application. I'm at work now (hey Boss: its my lunch break OK!) and the code I had is at home. I'll see if I can find it over the weekend if that is of interest. Susan |
|
|
|
嗨,苏珊,我刚才检查了汇编代码,我发现如果在函数或中断中使用了寄存器,编译器会生成汇编代码来将使用的寄存器保存到堆栈中。所以我以前的担心肯定不会是个问题。但我的项目目前还没有正常工作。如果您能与我分享您的工作自由港,这将是非常感谢!
以上来自于百度翻译 以下为原文 Hi Susan, I have checked the assembler code just now, I do found if the register was used in Functions or Interrupts the compiler will generate assembler code to save the used register into the stack. So my previous concern wouldn't be a problem for sure. But my project stills no working properly for now. If you can share me your working FreeRTOS port, that will be highly appreciated! |
|
|
|
很高兴…很快,有几个处理中断处理的步骤。在硬件层,PC和状态寄存器被保存在堆栈上,新的PC形成中断向量。如果ISR是用C写的(我知道XC16——其他可能不同),将节省ISR本身中使用的SFR。这可能只是W0和其他的,或者它可能是WN寄存器的完整集合,这取决于发生的事情:如果你在ISR中调用一个函数,那么它将节省很多“以防万一”,但是如果你只清除适当的IF标志(或者其他一些琐碎的情况),那么就不必费心去保存任何东西了。所有。当然,这一切都是在ISR退出之前解开的。如果ISR写的是汇编程序,那么就由作者来做任何需要的事情。我的记忆是,任务切换都是在汇编程序中编写的,就像主定时器ISR一样,因为它需要在切换时使用任务上下文块。形成一个任务到另一个任务,因此ISR可以返回一个与被调用的任务不同的任务。苏珊
以上来自于百度翻译 以下为原文 Happy to .... shortly. There are a couple of steps with processing an interrupt processing. At the hardware level, the PC and status register are saved on the stack and the new PC form the interrupt vector. If the ISR is written in C (I known XC16 - others may differ) will save the SFRs that are used within the ISR itself. This may be just W0 and others or it may be the complete set of Wn registers depending on what happens: if you call a function in the ISR then it will save the lot "just in case", but if you only clear the appropriate IF flag (or some other trivial cases) it may not bother to save anything much at all. Of course this is all unwound before the ISR is exited. If the ISR is written is assembler, then it is up to the author to do whatever is required. My memory is that the task switching is all written in assembler as is the main timer ISR as it needs to play with the task context blocks as it switches form one task to another and therefore the ISR can return into a different task than the one from which it was called. Susan |
|
|
|
与您所解释的一样,XC16编译器负责上下文保存和恢复,编译器将评估要选择的寄存器。谢谢您的帮助!
以上来自于百度翻译 以下为原文 Like what you explained, the XC16 compiler do take care of context saving and restoring, and the compiler will evaluate what register to choose. Thank you for your kindly help! |
|
|
|
这是我使用的文件。现在看,我并没有评论我所做的更改,主要是我自己的部分。希望这帮助苏珊。
以上来自于百度翻译 以下为原文 This is the file that I use. Looking at it now I didn't actually comment the changes that I've made - major oops on my part. Hope this helps Susan Attachment(s) portasm_dsPIC.S.txt (5.20 KB) - downloaded 124 times |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
4842 浏览 9 评论
1845 浏览 8 评论
1757 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2969 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2073 浏览 5 评论
467浏览 1评论
1122浏览 1评论
309浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
373浏览 0评论
270浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-5-9 17:51 , Processed in 1.150834 second(s), Total 88, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号