I'm trying to compile this code to blink led with button interrupt, using xc8 compiler and PIC18F4550. I got those warning, so the code lines are ignored and the program doesn't work properly (by clinking on button nothing happens)
newmain.c:45: warning: (335) unknown pragma "code"
newmain.c:46: warning: (335) unknown pragma "interrupt"
newmain.c:65: warning: (335) unknown pragma "code"
program code
#define _XTAL_FREQ 4000000
#include <pic18f4550.h>
// BEGIN CONFIG
#pragma config OSC = HS
static int cpt = 1;
void IntExternal_INT(void) {
TRISB0 = 1; // PORT B0 as input
INT0E = 1;
INTCONbits.PEIE = 1; //enable periphyrical interrupts
INTCONbits.GIE = 1;
INTEDG0 = 0; //: Interrupt Edge Select bit : 1 = Interrupt on rising edge of RB0/INT pin
// 0 = interrupt on falling edge
INT0F = 0;
}
void delay() {
volatile int i, j;
for (i = 0; i < 2000; i++)
for (j = 0; j < 10; j++);
}
#pragma code isr = 0x08 // Store the below code at address 0x08
#pragma interrupt isr // let the compiler know that the function isr() is an interrupt handler
void iscr(void) {
cpt++;
if (INT0IF) //If External Edge INT Interrupt
{
LATDbits.LATD0 = 1; // RD-0 to High
LATDbits.LATD1 = 1; // RD-1 to High
delay();
LATDbits.LATD0 = 0; // RD-0 to LOW
LATDbits.LATD1 = 0; // RD-1 to LOW
delay();
INT0IF = 0; // clear the interrupt
}
}
#pragma code // Return to the default code section
void main(void) {
IntExternal_INT();
TRISD = 0xF0; // PORT B Setting: Set all the pins in port D to Output.
while (1) {
if (cpt % 2 == 0) {
delay();
LATDbits.LATD0 = 1; // RD-0 to High
LATDbits.LATD1 = 1; // RD-1 to High
delay();
LATDbits.LATD0 = 0; // RD-0 to LOW
LATDbits.LATD1 = 0; // RD-1 to LOW
}
}
}