• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

rising edge trigger how to set up

Status
Not open for further replies.

tuanvoi

New Member
Hello,
Below is my interupt setup code, could you please check if it is correct? By the way, how to jump back to where the PIC was when the interrupt subroutine is done? Thanks
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
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top