完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我正在寻找一个示例代码,演示如何使用PIC18中的两个优先级(特别是PIC18F46K22)。
以上来自于百度翻译 以下为原文 Hello everyone I am looking for a sample code that shows how to use the two priority levels in PIC18 (Specially PIC18F46K22). Your help is highly appreciated. |
|
相关推荐
17个回答
|
|
用中断优先级解决什么问题?
以上来自于百度翻译 以下为原文 What problem are you trying to solve with interrupt priorities? |
|
|
|
没有任何问题要解决,但我必须向我的小同事演示这个特性。
以上来自于百度翻译 以下为原文 Not any problem to solve but I have to demonstrate this feature to my junior colleagues. |
|
|
|
编写两个ISR功能:启用IPEN位的中断优先级。用PIPX、PIX和IrpX寄存器设置中断操作。使用GIEH和GIL位启用全局中断。最后,读取PIC数据表的“中断”章节。
以上来自于百度翻译 以下为原文 Write two ISR functions: void interrupt high_priority high_isr(void) { } void interrupt low_priority low_isr(void) { } Enable interrupt priority with the IPEN bit. Setup interrupt operation with PIRx, PIEx, and IRPx registers. Enable global interrupts with GIEH and GIEL bits. Finally, read the "Interrupts" chapter of your PIC datasheet. |
|
|
|
没有任何问题要解决,但是我必须向我的小同事演示这个特性。既然你刚刚意识到了这一点的存在,并且你正在努力理解易变/原子访问问题,现在不是你展示任何相关特征的时候。我们的小同事阅读了你正在阅读的同一个论坛帖子,也许他们中的一些人可能比你更快地理解这些事情。
以上来自于百度翻译 以下为原文 Not any problem to solve but I have to demonstrate this feature to my junior colleagues. Since you've only just become aware of the existence of this, and you are struggling with understanding volatile / atomic access issues, now is not the time to for you be demonstrating any related feature. Have your junior colleagues read the same forum postings you are reading, and maybe some of them might come to understand these things more quickly than you. |
|
|
|
如果我使用ISR()来接收来自PIC18F46K22的两个UART端口的数据,其中一个波特率是9600,第二个是115200,如果我想使用2个优先级,一个应该是高优先级的,哪个是低的,还是更好的保持它们在相同的优先级上?
以上来自于百度翻译 以下为原文 If i am using ISR() to receive data from two UART ports of PIC18F46K22, where baud rate of one is 9600 and second is 115200, and if i want to use the 2 priority levels one for each then which one should be high priority and which lower or is it better to keep them both at same priority levels? |
|
|
|
对于这种情况,没有理由使用中断优先级。为什么你认为你需要它们?
以上来自于百度翻译 以下为原文 There is no reason to use interrupt priorities for that scenario. Why do you think you would need them? |
|
|
|
我完全同意这一点,但是,如果你要坚持使用优先中断这一点,那么就有一个你必须回答的一般问题:哪一个中断是紧急的,它可以等待,它可以被中断,并且不能中断。只有这样,你才能决定哪个是高的,哪个是低优先级(高可以中断低,而不是其他方式)。
以上来自于百度翻译 以下为原文 I totally agree with this however if you are going to insist on using priority interrupts for this then there is a general question you must answer for yourself: which interrupt is urgent and which can wait; which can be interrupted and which cannot. Only then can you decide which is high and which is low priority (high can interrupt low but not the other way). |
|
|
|
HiSure?我想说,第一步就是这个……然后是XC8编译器手册的“中断”部分,然后……你可以DIY!最佳选择
以上来自于百度翻译 以下为原文 Hi Sure ?! I would say that the very first step would be this one... Then the "interrupts" section of the XC8 compiler manual and then.........you can DIY! Best regards Jorge |
|
|
|
然后是“中断”部分的XC8编译器手册,然后……你可以DIY!同意。我知道有人会说什么。我在最后一秒添加了那行,在发布和实现之后,懒得编辑它。
以上来自于百度翻译 以下为原文 Then the "interrupts" section of the XC8 compiler manual and then.........you can DIY! Agree. I knew someone will say something. ;) I added that line at the last seconds and was too lazy to edit it after posting and realizing it. |
|
|
|
从9600波特的UART1接收到的1字节将从UART2接收到的大约1个MSEC1字节,它在115200波特上将占用大约0.1 MSECUART2数据速率比UART1快10倍。因此,如果UART1 ISR()正在执行,同时UART2开始接收数据,那么它也将被接收。如果要将iART1 ISR()作为低优先级中断和UART2 ISR()作为高优先级中断,那么即使UART1 ISR()正在执行,UART2数据也会被接收。如果我错了,请更正我。非常感谢你的帮助。
以上来自于百度翻译 以下为原文 1 byte received from UART1 which is at 9600 baud will take approx. 1 msec 1 byte received from UART2 which is at 115200 baud will take approx. 0.1 msec UART2 data rate is approx. 10 times faster than UART1. So if UART1 ISR() is executing and at the same time UART2 start to receive data also then it will have to store 10 bytes somewhere before it's ISR() can be serviced. If i make UART1 ISR() as low priority interrupt and UART2 ISR() as high priority interrupt then UART2 data will always be received even if UART1 ISR() is in execution. Please correct me if I am wrong here. Your help is highly appreciated. |
|
|
|
垃圾。你写你的ISR,所以它将一个字符保存到一个缓冲区中,并尽快退出。只要你的ISR代码运行速度比在115200接收一个字符快,那就没什么关系了。你的ISR需要更长的时间。
以上来自于百度翻译 以下为原文 Rubbish. You write your ISR so it saves one character into a buffer, and exits as quickly as possible. It doesn't matter if one is interrupting ten times faster than the other, so long as your ISR code runs faster than it takes to receive one character at 115200. You are doing something very wrong in your ISR if it takes longer than that. |
|
|
|
好吧,我现在明白了。所以UART1@ 9600波特并不意味着它的ISR()将花费1毫秒来保存1字节,但仅仅是将其保存到缓冲器中的时间,这将是不多于几个汇编指令,@ 20 MHz时钟T将采取大约1 USEC(5指令只是猜测),看起来很好。加快IsR()退出的速度。如果我们把ISR()看作一个单独的执行线程,那么我们可以使用它作为正常线程运行并退出,然后进入等待状态,直到它再次调用吗?
以上来自于百度翻译 以下为原文 OK i get it now. So UART1 @9600 baud does not mean that its ISR() will take 1 msec to save 1 byte but only the amount of time to save it into buffer, which would be not more than few assembly instructions, and @20 MHz clock t would take approx. 1 usec (5 instructions just a guess), which looks fine. One more thing regarding that an ISR() exit as quickly as possible.. if we think of an ISR() as a separate thread of execution then can we use it as normal thread that runs and exits and then go into wait state until its called again? |
|
|
|
它将有超过5条指令,因为在IRS上退出时需要保存各种各样的东西,并在ISR退出时恢复,但不是很大。不,它不是处于“等待状态”。它运行和退出。它根本不存在,直到它必须再次运行。
以上来自于百度翻译 以下为原文 It will be more than 5 instructions, as various things have to be saved on entry and restored on exit from the ISR, but not hugely more. No, it is not in a "wait state". It runs and exits. It doesn't exist at all until it has to run again. |
|
|
|
不要气馁或任何事,但从你的帖子和问题在这个论坛上,我必须同意马克在第5页,你没有资格在这个问题上向任何人展示。
以上来自于百度翻译 以下为原文 Not to be discouraging or anything, but from your posts and questions in this forum, I'll have to agree with Mark in Post #5 that you're not qualified in this subject to demonstrate to anyone. |
|
|
|
不要气馁或任何事,但从你的帖子和问题在这个论坛上,我必须同意马克在第5页,你没有资格在这个主题向任何人演示。我做这些活动基本上是为了小组学习。很多时候我比别人学习得多。它节省了我很多时间,也让其他人也参与其中。在每一次会议上,我都会告诉大家我不是专家,但让我们聚在一起讨论我们遇到的任何一点。到目前为止,我认为这对我们是有益的。
以上来自于百度翻译 以下为原文 Not to be discouraging or anything, but from your posts and questions in this forum, I'll have to agree with Mark in Post #5 that you're not qualified in this subject to demonstrate to anyone. I do these activities voluntarily basically for group learning. Many times its me who is learning more than others. It saves me lot of time and keep others involved also. On every session I tell this to everyone that I am not an expert here but let us get together and talk about any point that has come across us. So far i think its been beneficial for us. |
|
|
|
通常,当有一个中断(并且只有一个)具有非常关键的时序要求时(例如,在非常精确的时间间隔内摇动输出引脚,不应该改变),以及具有较少关键时序的其他中断(如UART等),则需要中断优先级。当需要时,关键中断可以抢占那些不太重要的中断。
以上来自于百度翻译 以下为原文 Generally, interrupt priorities are needed when you have one interrupt (and only one) that has a very critical timing requirement (e.g., wagging an output pin at a very precise interval that should never vary), along with other interrupts that have less critical timing (such as UARTs, etc.). The critical interrupt can preempt the less critical ones when needed. |
|
|
|
正如其他人所说的,在关键时刻使用中断优先级。我曾经使用中断优先级的唯一时间是通过一个外部中断检测到一个电源到高优先级ISR,所以我可以保存设置到EEPROM之前,设备完全断电。这是这样做的,EEPROM只写一次每功率循环,因为它有有限的耐力。
以上来自于百度翻译 以下为原文 As others said, use interrupt priority for critical timing. The only time I ever used interrupt priority was to detect a power-down via an external interrupt vectored to the high-priority ISR, so I can save settings to EEPROM before the device completely power off. This was done so the EEPROM was written to only once per power cycle, as it has a limited endurance. |
|
|
|
只有小组成员才能发言,加入小组>>
5362 浏览 9 评论
2093 浏览 8 评论
1992 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3274 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2305 浏览 5 评论
870浏览 1评论
756浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
699浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
750浏览 0评论
644浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-2-24 03:57 , Processed in 1.460984 second(s), Total 109, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191