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.

Help regarding interrupt handling for PIC P18f1330

Status
Not open for further replies.

chelonia

Newbie level 2
Joined
Feb 17, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
Hello. I am new to using PIC 18F1330 micro-controller. Below is my sample code for INT1. when i try to debug/simulate using ICD-2 and MPLAB-IDE V8.63. the cursor does'nt enter in main() function directly cursor control goes to InterruptVectorHigh isr i.e. program execution start from ISR not from main().
i try many things and please tell me solution for this situation.


#include <p18f1330.h>
#include <capture.h>
#include <timers.h>
#include <stdlib.h>
#include <delays.h>
#include <ctype.h>
#pragma config OSC = INTIO2
#pragma config WDT = OFF


int flag = 0;
void InterruptHandlerHigh(void) ;

#pragma code
#pragma interrupt InterruptHandlerHigh

void InterruptHandlerHigh(void)
{
if (INTCON3bits.INT1IE && INTCON3bits.INT1IF )
{
LATAbits.LATA2 = 1;
Delay1KTCYx(20);
LATAbits.LATA2 = 0;
}
}

void main(void)
{
int result;
TRISA = 0b00000010;
LATAbits.LATA2 = 0;
INTCONbits.GIE = 1;
INTCON3bits.INT1IE = 1;
INTCON2bits.INTEDG1 = 1;
ADCON1bits.PCFG1 = 1;
while (1)
{
LATAbits.LATA0 = 1;
Delay1KTCYx(250);
LATAbits.LATA0 = 0;
Delay1KTCYx(250);
}
}


#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh (void)
{ _asm
goto InterruptHandlerHigh
_endasm }
 

Try this:

You have to clear the interrupt once it is serviced.

add INTCON3bits.INT1IF = 0;
after
LATAbits.LATA2 = 1;
Delay1KTCYx(20);
LATAbits.LATA2 = 0;
 

i tried this still facing same problem in execution start from ISR() and not from main().
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top