为什么Timer2中断没有启动?

为什么Timer2中断没有启动?,timer,embedded,interrupt,microcontroller,pic,Timer,Embedded,Interrupt,Microcontroller,Pic,我正在尝试启用timer2中断以将其用于PWM目的。在这种情况下,我只打开一个LED,当定时器2中断发生时,我将其关闭,但定时器中断从未发生。我觉得一切都很好,所以我不明白为什么Timer2没有启动。我使用的是PIC18F87J11,下面是 谢谢 发现了我的错误 PIE1bits.TMR2IE==1 它应该是PIE1bits.TMR2IE=1 打开编译器警告: /* File: main.c Date: 2011-SEP-4 Target: PIC18F87J11

我正在尝试启用timer2中断以将其用于PWM目的。在这种情况下,我只打开一个LED,当定时器2中断发生时,我将其关闭,但定时器中断从未发生。我觉得一切都很好,所以我不明白为什么Timer2没有启动。我使用的是PIC18F87J11,下面是

谢谢

发现了我的错误 PIE1bits.TMR2IE==1


它应该是PIE1bits.TMR2IE=1

打开编译器警告:
/*
     File: main.c
     Date: 2011-SEP-4
     Target: PIC18F87J11
     IDE: MPLAB 8.76
     Compiler: C18 3.40

 */

#include <p18cxxx.h>
#include<usart.h>
#include <pwm.h>
#include <delays.h>

#pragma config FOSC = INTOSC, WDTEN = OFF, XINST = OFF
#pragma interrupt HighISR




void main(void) {

  unsigned int i;
    /* set FOSC clock to 8MHZ */
    OSCCON = 0b01110000;

    /* turn off 4x PLL */
    OSCTUNE = 0x00;

    /* make all ADC inputs digital I/O */
    ANCON0 = 0xFF;
    ANCON1 = 0xFF;


    PR2 = 124;  // Period
    TMR2=0;

    // 1/16 prescalar
    T2CONbits.T2CKPS0 = 1;
    T2CONbits.T2CKPS1 = 0;

    PIE1bits.TMR2IE == 1; // Enables the TMR2 to PR2 match interrupt

    // Enable Timer 2
    T2CONbits.TMR2ON = 1;

    INTCONbits.PEIE = 1; // Enable Perpherial Interrupt
    INTCONbits.GIE = 1; // Enable Global Interrupt

    TRISDbits.TRISD6 = 0; // Turn on LED
    LATDbits.LATD6 = 1;



    while (1);


}


#pragma code highVector=0x08

void HighVector(void) {
    _asm goto HighISR _endasm
}
#pragma code /* return to default code section */


// Timer Interrupt

void HighISR(void) {

    if (PIR1bits.TMR2IF == 1) {
       LATDbits.LATD6 = 0; // Turn off LED to indicate it came thru
        PIR1bits.TMR2IF = 0;
    }


}