完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用PIC16LF1618的RC7上的中断(运行在32兆赫)。以下是我用于I-O-C的初始化位:我能够使用RC7上的正触发器从断电模式(SLEEP)唤醒PIC。现在,我试图在执行期间以及使用中断使触发器可用,好像RC7上的任何正触发器都应该重置PIC并转到main()函数的第一行。下面是我正在使用的中断例程。我还在main()函数的开头启用GIE和PIE位,并在调用SLEEP函数之前禁用相同的GIE和PIE位。但是,在执行RESET()函数之后,需要大约425个人来清除所有中断例程并到达主函数的顶部。由于RC7上的中断可能发生在每15个美国,PIC无法捕获数据。有没有一种方法可以在执行期间捕获RC7上的中断,然后在休眠模式下使用RC7作为i-O-C?注:由于复位需要尽快发生,并且对于执行时间至关重要,我不能在主函数中添加多个if语句来检查RC7上的正触发器。在主循环中还有SPI例程,它消耗的时间超过15秒,因此使用if语句是没有用的。
以上来自于百度翻译 以下为原文 I am using Interrupt-On-Change on RC7 of PIC16LF1618 (running at 32 MHz). Here is the initialization bit that I use for I-O-C: void I_O_C_Initialize (void) { INTCONbits.IOCIF = 0; IOCCFbits.IOCCF7 = 0; INTCONbits.IOCIE = 1; IOCCP = 0x80; } I am able to wake the PIC from a Power-Down Mode (SLEEP) using a positive trigger on RC7. Now, I am trying to make the trigger available during execution time as well using interrupts, as if any positive trigger on RC7 should reset the PIC and go to the first line of the main() function. Here is the interrupt routine that I am using. void interrupt ISR (void) { if (RC7 == 1) { INTCONbits.GIE = 0; INTCONbits.PEIE = 0; IOCCF = ((IOCCF^0xFF)&IOCCF); RESET(); } } I am also enabling the GIE and PEIE bits in the start of the main() function and disabling the same before calling the SLEEP function. However, after executing the RESET() function, it takes around 425 us to clear all the interrupt routines and reach the top of the main function. Since the interrupts on RC7 could happen every 15 us, the PIC fails to capture the data. Is there a way that I could capture the interrupt on RC7 during execution time and then use RC7 as I-O-C during SLEEP mode? P.S: Since the reset needs to happen as quick as possible and is crucial to the execution time, I am unable to add multiple if statements inside the main function to check for the positive trigger on RC7. Also there are SPI routines within the main loop that consumes more time than 15 us and hence using if statements would not be helpful. Thanks |
|
相关推荐
2个回答
|
|
RC7上还有AN9,所以在检测到变化之前,您需要将引脚设置为“数字”模式。另外,您不应该在ISR中更改GIE和PIE位。如果你希望ISR是“一次性”中断,那么关闭特定的中断,而不是所有的中断。此外,这些位中的一些可以由硬件管理,同时保存和恢复ISR周围的上下文。对于这些只具有一个或2个中断向量的设备,您应该通过比较各自的IE位和中频位来检查哪个中断源是活动的。这会节省一些奇怪的问题,其中ISR被一个源调用,但通过另一个源来响应是触发。苏珊
以上来自于百度翻译 以下为原文 Also RC7 has AN9 on it so you need to set the pin to 'digital' mode before the change can be detected. Also you should not be changing the GIE and PEIE bits in the ISR. If you want the ISR to be a 'one off' interrupt, then turn off the specific interrupt and not all of them. Also some of these bits can be managed by the hardware while saving and restoring the context around the ISR. For these devices that only have one or 2 interrupt vectors, you should perform a check to see which interrupt source is active by comparing both the respective IE and IF bits. This saves strange problems where the ISR is called by one source but responds as through another source is the trigger. Susan |
|
|
|
在这里重复和讨论:HTTP://www. McCHIP.COM/FUMMS/FUNDSPE/949
以上来自于百度翻译 以下为原文 Duplicated and discussed here: http://www.microchip.com/forums/FindPost/949549 |
|
|
|
只有小组成员才能发言,加入小组>>
5162 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3172 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 04:07 , Processed in 1.508058 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号