hamidkavianathar
Member level 5
Hello guys
I am new to pic micro controllers. I have a problem with it. I have written a very simple code to test the external its interrupts. I don't know why it doesn't work. could you please tell me, what I should do?
this is block design of interrupt scheme of the micro controller:
and this my code:
thank you.
I am new to pic micro controllers. I have a problem with it. I have written a very simple code to test the external its interrupts. I don't know why it doesn't work. could you please tell me, what I should do?
this is block design of interrupt scheme of the micro controller:
and this my code:
Code:
#include <p18f4550.h>
#pragma config FOSC = INTOSCIO_EC //internal ocsillator
#pragma config WDT = OFF //turn off WDT
#pragma config LVP = OFF //turn off LVP
#pragma config BOR = ON //enable brownout reset
//----------------------------------------------------------------------------
void main (void);
void InterruptHandlerHigh (void);
void delay (void)
{
volatile int i;
for (i=0;i<10000;i++);
}
//----------------------------------------------------------------------------
// Main routine
char flag = 0;
void
main ()
{
INTCONbits.INT0IF = 0;
INTCONbits.INT0IE = 1;
INTCON2bits.INTEDG0 = 0;
ADCON0 = 0xFF;
INTCON2bits.RBPU = 1;
RCONbits.IPEN = 1;
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
TRISAbits.TRISA0 = 0;
TRISBbits.TRISB0 = 1;
while (1)
{
if (flag == 1)
{
LATAbits.LATA0 = 1;
delay();
LATAbits.LATA0 = 0;
delay();
}
else
LATAbits.LATA0 = 1;
}
}
#pragma code InterruptVectorHigh = 0x08
void
InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
//----------------------------------------------------------------------------
// High priority interrupt routine
#pragma code
#pragma interrupt InterruptHandlerHigh
void
InterruptHandlerHigh ()
{
if (INTCONbits.INT0F)
{
INTCONbits.INT0F = 0;
flag = 1;
}
}
thank you.