Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F45k20 External interrupt

Status
Not open for further replies.

abdulanr1

Newbie level 3
Newbie level 3
Joined
Jul 13, 2016
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
35

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define USE_OR_MASKS
#include <p18f45k20.h>
 
 
#pragma config FOSC = INTIO7, FCMEN = OFF, IESO = OFF                      // CONFIG1H
#pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 30                       // CONFIG2L
#pragma config WDTEN = OFF, WDTPS = 32768                                   // CONFIG2H
#pragma config LPT1OSC = ON, PBADEN = OFF, CCP2MX = PORTC                    // CONFIG3H
#pragma config STVREN = ON, LVP = OFF, XINST = OFF                          // CONFIG4L
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF                   // CONFIG5L
#pragma config CPB = OFF, CPD = OFF                                         // CONFIG5H
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF               // CONFIG6L
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF                           // CONFIG6H
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF           // CONFIG7L
#pragma config EBTRB = OFF   
#pragma code InterruptVectorHigh = 0x08
unsigned int data;
 
 
void main(void)
{
 
ANSEL = 0x00;
ANSELH = 0x00;
 
TRISD = 0b00000000;
PORTD=0x00;
OSCCONbits.IRCF0 = 0;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF2 = 1;
 
INTCONbits.INT0IF = 0;
 
INTCONbits.INT0IE     = 1;                 // Enable External interrupt
//INTCONbits.RBIE = 1;
RCONbits.IPEN=1;
INTCON2=0b10000000; 
INTCON2bits.RBPU    = 0;
INTCON2bits.INTEDG0 = 0; //falling edge
INTCONbits.GIE=1;    // Enable The Global Interrupt
INTCONbits.PEIE = 1;
 
TRISB = 0b00000001;
PORTB=0x00;
 
}
 
void InterruptVectorHigh(){
 
 
PORTD=0xFF;
 
INTCONbits.INT0IF = 0; 
}




external interrupt not working with above code can any one solve
 
Last edited by a moderator:

tried that also..need to change config
 

I don't know what compiler are you using, but isn't missing the infinite loop while(1) somewhere ?
 

interrupt flag is setting but not going inside the interrupt routine...am using while loop end of main
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top