无法在代码不起作用的情况下运行中断功能

时间:2019-01-23 02:46:36

标签: pic microchip mplab xc8

这部分代码有问题:void interrupt ISR_Timer0_Int

mplabs x ide 5.10显示错误:

  

newmain.c:26:6:错误:变量的类型不完整'void'
  newmain.c:26:15:错误:预期为';'在顶级声明符之后

我正在使用XC8 V2编译器,并将其插入PIC18f4550

代码:

void interrupt ISR_Timer0_Int()  // Timer0 Interrupt Service Routine (ISR)
{
    if (INTCONbits.TMR0IF) // TMR0IF:- Timer0 Overflow Interrupt Flag Bit
        // 1 = TMR0 reg has overflowed
        // 0 = TMR0 reg has not overflowed
    {
        TMR0H = 0xED; // Timer0 start value = 0x48E5 for 0.1 second
        TMR0L = 0x4C;
        if (j <= 7) { //limit up to 7

            j++; // Increase count by 1
            PORTD = j; // Output to Demultiplexer

        }
        else {

            j = 0; // Reset count aftwr it hit 7
            PORTD = j; // Output to Demultiplexer

        }
        INTCONbits.TMR0IF = 0; // Reset TMR0IF to "0" since the end of
        // the interrupt function has been reached
    }
}

1 个答案:

答案 0 :(得分:1)

语法随新编译器更改。 https://www.microforum.cc/topic/5-i-used-to-use-to-locate-variables-but-since-xc8-20-this-is-no-longer-working/

可以找到关于此的更多信息以及文档的链接。

通过将编译器设置回C90模式,或通过  使用新的中断语法。