rising edge trigger how to set up

Thread Starter

tuanvoi

Joined Oct 31, 2008
56
Hello,
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
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
 

thatoneguy

Joined Feb 19, 2009
6,359
Does it run in simulation?

Do you have an ICE or ICD? (In Circuit Emulator or In Circuit Debugger)

For PIC, it would be an ICExxxx unit, or for debuggers the ICD2 or PicKit 3
 
Top