shreyas_patel21
Full Member level 3

hello everyone,
how to enable external interrupt or IOC(interrupt on change) in pic18f46k22?
i am using microchip mplab c18 compiler.
here is the code which i tried:
thank you.
how to enable external interrupt or IOC(interrupt on change) in pic18f46k22?
i am using microchip mplab c18 compiler.
here is the code which i tried:
Code:
#include <stdio.h>
#include <p18f46k22.h>
#define LED PORTDbits.RD2
#define push_butten PORTDbits.RD5
void ioc(void);
#pragma code low_vector=0x18
void low_interrupt (void)
{
_asm GOTO ioc _endasm
}
#pragma code
#pragma interruptlow ioc
void ioc(void)
{
LED=push_butten;
}
void delay(int ms)
{
unsigned int x;
T1CON=0x00;
for(x=0;x<ms;x++)
{
TMR1L=0x00;
T1CON=0x33;
while(TMR1L<0xFA);
T1CON = 0x0000;
}
}
void main()
{
OSCCONbits.IRCF0 =1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF2 = 1;
OSCTUNEbits.PLLEN = 1;
ANSELA = 0x00;
ANSELB = 0x00;
ANSELC = 0x00;
ANSELD = 0x00;
ANSELE = 0x00;
TRISA=0x00;
TRISB=0X0000; //output
TRISC=0X0000; //output
TRISD=0X00; //output
TRISE=0X00; //output
LED=1;
IOCB=0xff;
INTCONbits.RBIE=1;
while(1)
{
push_butten=1;
delay(2500);
push_butten=0;
delay(2500);
}
}
thank you.