chelonia
Newbie level 2
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 }
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 }