Hello,
Below is my code, PIC18F4550
Could you please check if my interrupt setup is correct? Thanks
By the way, how do you jump back to the subroutine that the PIC was running in C program?
Tom
Below is my code, PIC18F4550
Rich (BB code):
#include <p18f4550.h>
#include <usart.h>
#include <delays.h>
void LED1(void)
{
PORTDbits.RD0 = 0;
}
void main (void)
{
ADCON0bits.ADON=0;
ADCON1 = 0x07;
CMCON = 0x07;
//TRISA = 0x00;
TRISD = 0x00;
//PORTDbits.RD0 = 0;
//INTCON: INTERRUPT CONTROL REGISTER
TRISB = 0xFF;
INTCONbits.GIEH = 0; //clear interrupt
INTCONbits.GIEH = 1; //enable interrupt
INTCONbits.INT0IE = 1; //an external interrupt will occur when there is a change state in PORTB pins
//INTCONbits.RBIE = 0;
INTCONbits.RBIE = 1; //enables the RB port change interrupt
INTCONbits.INT0IF == 0;
INTCON2bits.INTEDG0 = 1; //interrupt will be triggered when on rising edge
//INTCONbits.INT0IF = 1;//enable interrupt on RB0
if(INTCONbits.INT0IF == 1)
//if(INTCONbits.RBIF == 1)
{
//INTCONbits.RBIF == 0; //interrupts for INTCON <7:4>
PORTDbits.RD0 = 1;
Delay10KTCYx(100);
PORTDbits.RD0 = 0;
Delay10KTCYx(100);
INTCONbits.INT0IF = 0;
}
else if (INTCONbits.INT0IF = 0)
{
LED1();
}
}//end of main
By the way, how do you jump back to the subroutine that the PIC was running in C program?
Tom