简体   繁体   English

执行运行时发生变化中断

[英]Interrupt-On-Change during execution runtime

I am using Interrupt-On-Change on RC7 of PIC16LF1618. 我正在PIC16LF1618的RC7上使用电平变化中断。 Here is the initialization bit that I use for IOC: 这是我用于IOC的初始化位:

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. 我可以使用RC7上的正触发将PIC从掉电模式(SLEEP)中唤醒。 However, I would like to have this trigger available during execution time as well, as if any positive trigger on RC7 should reset the PIC and go to the first line of the main() function. 但是,我也希望在执行期间也可以使用此触发器,就像RC7上的任何正触发器都应将PIC复位并转到main()函数的第一行一样。

Could you please let me know on how to achieve this? 您能否让我知道如何实现这一目标?

PS: 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. PS:由于重置需要尽快发生,并且对执行时间至关重要,因此我无法在主函数内添加多个if语句来检查RC7上的正触发。 Hence I am looking for an interrupt option to reset the PIC, even if it is executing a delay or function loops. 因此,即使它正在执行延迟或功能循环,我仍在寻找一个中断选项来复位PIC。

Thanks 谢谢

In most 8-bit PIC devices, and assuming you're using XC8, there is a definition that invokes the required assembly command: 在大多数8位PIC器件中,假设您使用的是XC8,则有一个定义可调用所需的汇编命令:

#define RESET() asm("reset")

So, in your interrupt handler, just insert this line of code: 因此,在您的中断处理程序中,只需插入以下代码行:

RESET();

The issue has now been resolved. 该问题现已解决。 After enabling GIE bit whenever I needed the Interrupt On Change (IOC) during runtime and using the below function, the IOC worked during runtime as well as Power-Down Mode (SLEEP). 在我在运行时需要中断变化时(IOC)并使用以下功能使能GIE位后,IOC在运行时以及掉电模式(SLEEP)期间都可以工作。

void interrupt ISR (void);

void interrupt ISR (void) { 
    if (RC7==1) {
        asm("pagesel foobar");
        asm("goto foobar");
    }
    else
        return;
} 


asm("foobar:");
while (1) {
    IOCCFbits.IOCCF7 = 0;
    INTCONbits.GIE = 1;

    . //Do the calculations here
    . //Here if any Interrupt On Change happens for RC7,
    . //the ISR routine would stop all calculations and
    . //would return to the start of the loop without
    . //resetting any of the registers.

    INTCONbits.GIE = 0;
    IOCCFbits.IOCCF7 = 0;
    SLEEP();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM