Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 29th March 2009, 01:58 AM   #1
Default rising edge trigger how to set up

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
tuanvoi is offline  
Reply

Tags
edge, rising, set, trigger

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
A Pulse from a rising edge & a Counter issue haxxx Electronic Projects Design/Ideas/Reviews 17 2nd March 2009 04:39 PM
Dollar down, Euro rising, Buying stuff from USA is cheaper ! Whats the catch ? TiagoSilva Micro Controllers 10 13th June 2008 06:44 PM
Edge trigger via loss of Vs on 555 help greg123 Electronic Projects Design/Ideas/Reviews 1 23rd March 2008 03:00 PM
edge detector abandon_soul Electronic Projects Design/Ideas/Reviews 0 11th February 2008 02:04 AM
RF rising falling edge visionpro General Electronics Chat 3 30th July 2004 08:09 AM



All times are GMT. The time now is 04:04 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker